OpenSprinkler Forums OpenSprinkler Unified Firmware API – Station Status

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #39424

    DaveC
    Participant

    Is there any difference in operational status between /jc sbits and /js sn? I understand that the data is encoded differently, but is it the same info?

    Thanks

    #39452

    Ray
    Keymaster

    /jc returns the controller status variables, and /js returns the station status variables. Specifics can be found in the API document:
    https://opensprinkler.freshdesk.com/solution/categories/5000022938/folders/5000147084/articles/5000632570-api-documentation-firmware-2-1-5-current-

    #39460

    DaveC
    Participant

    …but is the data returned by ‘sbits’ exactly the same as the data returned by ‘sn’ except that ‘sbits’ is packed 8 stations to a byte? My interpretation of the doc is that they are but I was looking to validate that. Having 2 fields encoded differently in 2 different messages makes me think there is something different about them, unless ‘sbits’ was added cut down on the number of message polls one would have to do. If they are the same it would be good if the doc said so.

    #39464

    DaveC
    Participant

    Trying to answer my own question:
    The data is not exactly the same. The number of stations returned is different.
    I have 24 zones.
    ‘/jn sn’ returns 24 zones worth of data (zone 11 active as expected)
    “sn”:[0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0]
    ‘/jc sbits’ returns 32 zones worth of data (zone 11 active as expected)
    “sbits”:[0,4,0,0]
    Why? Is it a bug?

    OK, so I can figure out how many zones I really have and ignore any extra zones that ‘sbits’ returns to work around this.
    When I get more time, I’ll try hunting the OS code to see if I can find out why.

    #39477

    DaveC
    Participant

    Its a bug…
    When processing ‘jc sbits’ an extra 0 is sent out after the last station status group.
    In server.cpp

    // print sbits
    for(bid=0;bid<os.nboards;bid++)
    bfill.emit_p(PSTR(“$D,”), os.station_bits[bid]);
    bfill.emit_p(PSTR(“0],\”ps\”:[“));

    should be something like:
    // print sbits
    for(bid=0;bid<os.nboards;bid++) {
    bfill.emit_p(PSTR(“$D”), os.station_bits[bid]);
    if(bid!=os.nboards-1) bfill.emit_p(PSTR(“,”));
    }
    bfill.emit_p(PSTR(“],\”ps\”:[“));

    This is similar to the way it is handled with ‘js sn’:

    for (sid=0;sid<os.nstations;sid++) {
    bfill.emit_p(PSTR(“$D”), (os.station_bits[(sid>>3)]>>(sid&0x07))&1);
    if(sid!=os.nstations-1) bfill.emit_p(PSTR(“,”));
    }
    bfill.emit_p(PSTR(“],\”nstations\”:$D}”), os.nstations);

    #39495

    Ray
    Keymaster

    You are right that “sn” from /jn has the same information as “sbits” from /jc in that sn shows the unpacked bits of sbits. You are also right that sbits has an extra 0 in the end (it’s from legacy code that I never bothered to change). Will fix this soon. Note that the ‘nbrd’ variable gives you the number of valid elements in sbits. This way if sbits has extra elements it shouldn’t matter.

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

OpenSprinkler Forums OpenSprinkler Unified Firmware API – Station Status