OpenSprinkler Forums OpenSprinkler Unified Firmware Programming question.

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #22431

    djagerif
    Participant

    Ok, 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,
    Ingo

    #23660

    Ray
    Keymaster

    Have 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.

    #23661

    djagerif
    Participant

    I thought it was a formatter of some sorts but wasn’t sure. I’ll look through their documentation for some pointers.

    Ingo

    #23662

    Ray
    Keymaster

    Yes, 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.

    #40598

    sakos
    Participant

    I 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?

    #40606

    Ray
    Keymaster

    Do 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.

    #40612

    sakos
    Participant

    Thanks 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.

Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.

OpenSprinkler Forums OpenSprinkler Unified Firmware Programming question.