OpenSprinkler › Forums › OpenSprinkler Unified Firmware › Programming question.
- This topic has 6 replies, 3 voices, and was last updated 10 years, 7 months ago by
sakos.
-
AuthorPosts
-
May 14, 2013 at 5:34 pm #22431
djagerifParticipantOk, so I’ve got a backup hex file just in case and I decided to fiddle around the code a bit. Not being a micro controller programmer I am a bit lost but finding my way.
Can someone briefly explain the following line of code: bfill.emit_p(PSTR(“$D”), 0);
I want to know what is “$D” and where it comes from. If I want to add something to the output EG. another variable value “sid” how do I address the value of sid?
Thanks,
IngoMay 15, 2013 at 10:31 pm #23660
RayKeymasterHave you programmed in C or Java? The $D is similar to printf”%d”) in C, which means printing out an integer number. In any case, that part of the code uses Jeelab’s EtherCard library, and you may want to check their documentations and forum for answers to specific questions.
May 16, 2013 at 3:04 am #23661
djagerifParticipantI thought it was a formatter of some sorts but wasn’t sure. I’ll look through their documentation for some pointers.
Ingo
May 16, 2013 at 4:08 pm #23662
RayKeymasterYes, it is a formatter (those %d, %f, %u things in the printf function). The BufferFillter.emit_p function is designed to be similar to the printf.
October 23, 2015 at 7:01 am #40598
sakosParticipantI would like to play with the Opensprinkler code. I modified some minor things successfully however I got stuck. I need some debug info but printf command will not work. A printf (“echo” \n) has been put into main loop, however no output on linux console neither redirecting to a file works. Any hint?
October 24, 2015 at 4:49 pm #40606
RayKeymasterDo you have OpenSprinkler or OSPi/OSBo? To do debug with OpenSprinkler, you should uncomment the following line in defines.h:
https://github.com/OpenSprinkler/OpenSprinkler-Firmware/blob/master/defines.h#L283
which enables the SERIAL_DEBUG macro. Then you can either use Arduino’s standard Serial interface, such as Serial.print and Serial.println to print values, or use the macro defined DEBUG_PRINT() to print debug data. To use serial debug, you need a serial monitor, such as gtkterms in Linux, or Arduino’s Serial monitor to display the serial data.TO debug with OSPi/OSBo, make sure this line is enabled:
https://github.com/OpenSprinkler/OpenSprinkler-Firmware/blob/master/defines.h#L354
and then you can just use standard C printf — the data will be printed to the console where you run the firmware from.October 25, 2015 at 1:10 pm #40612
sakosParticipantThanks for your response Ray,
I have OSPi. Debug is enabled by default. I could not see debug info in console, neither was able to forward it into a file. However if I start the program directly and not using the init script the debug lines appear. It is good enough so far.
-
AuthorPosts
- You must be logged in to reply to this topic.
OpenSprinkler › Forums › OpenSprinkler Unified Firmware › Programming question.