Post
Topic
Board Hardware
Re: Klondike - 16 chip ASIC Open Source Board - Preliminary
by
kano
on 05/07/2013, 06:05:16 UTC
...
But with many devices attached it would probably be nice to give an array for each value eg.

"Temp": [ 65,54,65,78 ],
You can reply with a string or a number, but you can of course make your string look like an array of numbers Smiley

Quote
I noticed that using,

echo -n "{\"command\":\"stats\"}" | nc 127.0.0.1 4028

appends a trailing \0 to output. Is that expected/desired?
It breaks piping to a JSON parser. I use this,

echo -n "{\"command\":\"stats\"}" | nc 127.0.0.1 4028 |tr -d "\000" | jsgrep

to strip the \0 and it prints pretty with jsgrep.

The \0 is there on purpose.

You can of course
java API stats
which is also pretty Cheesy
Also reasonably pretty (but messes up if the data has a comma)
echo -n stats | nc 127.0.0.1 4028 | tr "|," "\n"

If you check the php and java I use the '\0' to identify the completion of data transfer.
It's a character that cannot be used anywhere else so it works well.

(a good example of complete failure in this regard is the BFL SC MCU where it uses a to terminate USB transfers ... except ... sometimes it's OK and sometimes it can be ... either ... with x-link which is a PITA Tongue)