Writing SmartTraps to a file

Discussion to talk about software related topics only.
Post Reply
RickB
Posts: 4
Joined: Mon Jan 15, 2018 8:12 am

Writing SmartTraps to a file

Post by RickB »

I inherited oversight of a particular NetBurner project some time ago when the lead developer passed away. One thing that the late developer did was add the means of writing smart traps to a file before the reboot. There is some pretty extensive and advanced coding that went into this code and, frankly, I don't think the late developer had the level of understanding to accomplish what I am seeing. I know for sure that I do not have that level of understanding.

And so, my question: Is there a project, library, or coding example where someone has implemented the writing of smart traps to a file before the reboot? I'm hoping that I can look at the sample code and accompanying documentation and better understand what is going on.

TIA,
Rick
sulliwk06
Posts: 118
Joined: Tue Sep 17, 2013 7:14 am

Re: Writing SmartTraps to a file

Post by sulliwk06 »

I have been able to do this in some of my projects.

Basically I grabbed the entire EnableSmartTraps() function from the Netburner libraries and everything that came with it, and pasted it into my code under a different namespace. From there I just tweaked things a bit and sprintf the data into a global buffer. Then at the end I write that buffer to a file. Depending on the cause of the trap there have been some instances where it is unable to write it to file, but I think it works most of the time.
User avatar
pbreed
Posts: 1080
Joined: Thu Apr 24, 2008 3:58 pm

Re: Writing SmartTraps to a file

Post by pbreed »

I personally wrote smart traps, and I have no idea how to do this.
At the point smart traps goes off, you are really unsure about the state of the world.
Smarttrap runs at interrupt scope so all Interrupt driven I/O is a not usable....
You need to write polled versions of all i/o you want to use and do it with VERY little stack.
The I/o funcitons for the EFFS file system is interrupt driven, so can't use that.

One coudl setaside/reserve one sector of flash in the world and possibly get that to work.

I actually think the best solution is to set it up so the only traffic on one serial port is
smarttrap output and put something like the sparkfun serial logger on that port, any other solution is going to be 50% successful at best.
(https://www.sparkfun.com/products/13712)

Paul


BTW you should not need to change the name space, just put the modified file in your project and it will get linked before the libraries so that should just work...
Post Reply