OpenSprinkler › Forums › OpenSprinkler Unified Firmware › API – Station Status
- This topic has 5 replies, 2 voices, and was last updated 9 years, 2 months ago by Ray.
-
AuthorPosts
-
July 22, 2015 at 9:47 pm #39424
DaveCParticipantIs 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
July 25, 2015 at 12:08 am #39452
RayKeymaster/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-July 25, 2015 at 6:23 am #39460
DaveCParticipant…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.
July 25, 2015 at 10:38 am #39464
DaveCParticipantTrying 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.July 25, 2015 at 2:10 pm #39477
DaveCParticipantIts 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);July 26, 2015 at 10:57 am #39495
RayKeymasterYou 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.
-
AuthorPosts
- You must be logged in to reply to this topic.
OpenSprinkler › Forums › OpenSprinkler Unified Firmware › API – Station Status