AJAX and the NetBurner Version 3

Post your example source code and application notes to share with others
Post Reply
User avatar
tod
Posts: 587
Joined: Sat Apr 26, 2008 8:27 am
Location: Southern California
Contact:

AJAX and the NetBurner Version 3

Post by tod » Fri Apr 26, 2013 5:32 pm

Updated to use jQuery, Knockout, Bootstrap, Modernizr and HTML5 with CSS3. The project includes all the minimized versions of the libraries. If you start a project from this you'll want to download the full debug versions. I wrote up a brief blog entry which also has an overview video. I took away Prototype and most of my custom JavaScript code. I added in C++ a dumbed down customized version of my JsonCreator class. The full library was not really written for public consumption but I didn't want to do another version where the JSON objects are all created by concatenating strings. Ideally, I'd like to take one of the public JSON creation/serializer libraries and make it work for the NetBurner.

Oh yeah it was written for the MOD5441x dev board, although it should work on other modules as well, but I suspect you'll have to turn off the A/D stuff.
Attachments
NBShell_V3.zip
(6.89 MiB) Downloaded 394 times

User avatar
dciliske
Posts: 614
Joined: Mon Feb 06, 2012 9:37 am
Location: San Diego, CA
Contact:

Re: AJAX and the NetBurner Version 3

Post by dciliske » Tue May 21, 2013 8:55 am

Hey Tod,

I'm having some issues building/running the project. I'm encountering the following error on boot:

Code: Select all

terminate called after throwing an instance of 'std::length_error'
                                                                    what():  basic_string::_S_create
I suspect that this is due to some constructor being called in the global/static context blowing up in my face. Have a guess where to look?

-Dan
Dan Ciliske
Project Engineer
Netburner, Inc

User avatar
dciliske
Posts: 614
Joined: Mon Feb 06, 2012 9:37 am
Location: San Diego, CA
Contact:

Re: AJAX and the NetBurner Version 3

Post by dciliske » Tue May 21, 2013 9:50 am

Oh joy... it works when compiled with NBEclipse, but not with Make... -.-

Guess I've got a new project coming up...

Edit: Nevermind... I shoulda known that it was a C++ism with one of Tod's projects. Aparently I need to turn on exceptions in the makefile; NBEclipse does that automagically for C++ projects.

Edit 2: ...And it was still different. It ended up being that the order of the make targets was the culprit, as that determined their link order and therefore the order of their static constructors.
Dan Ciliske
Project Engineer
Netburner, Inc

User avatar
tod
Posts: 587
Joined: Sat Apr 26, 2008 8:27 am
Location: Southern California
Contact:

Re: AJAX and the NetBurner Version 3

Post by tod » Tue May 21, 2013 10:49 am

First of all, glad I could help! :)

The resolution to the problem strikes me as somewhat strange. Eclipse does not (to the best of my knowledge) automatically turn on Exception handling. In fact, for this project under the project Properties->C/C++ Build->Settings->Gnu C++ Compiler-> Miscellaneous settings (see image) I have the checkbox enabled for No exceptions handling (-fno-exceptions).

My first course for Pluralsight looks like it's going to be an in depth tour of using Eclipse for C++ and Java. Maybe I'll entice Dan to switch over (you can still keep using MakeFiles in Eclipse).

Dan, if there's something in the code I could do that would have prevented this error (or at least made it more obvious what needed corrected) let me know.
Ajax3Settings.png
C/C++ Misc. Settings
Ajax3Settings.png (75.84 KiB) Viewed 5627 times
Tod

User avatar
tod
Posts: 587
Joined: Sat Apr 26, 2008 8:27 am
Location: Southern California
Contact:

Re: AJAX and the NetBurner Version 3

Post by tod » Tue May 21, 2013 12:42 pm

I would guess you're seeing the dependency of TcpServer on TcpServerReset. This is what I get for trying to upgrade old code instead of rewriting it. I might have others in there as well. Instantiating static objects like I'm doing here is a VERY BAD idea. I even talk about the dangers of non-local static objects (NLSOs) on the wiki. A case of do as I say not as I do.

The code should take a lazy loading approach and leave the statics null until requested (more of a standard singleton pattern). Not so much to save the cost of instantiation but to to defer the instantiation until after the program fully boots so that this type of linker dependency is avoided. When I get a chance I'll fix the code and reupload it.

Post Reply