Table of ContentsSerial Sensor Protocol V2 (EN)DescriptionI recently decided to revise the protocol i developed for the communication between a sensor board and a host. I want a protocol which is simple enough so i can communicate with the sensor board just with a terminal like minicom. This is a protocol based on human readable ASCII values. There are only two commands (get/set) and the transfer is synced by a CR character.As before the communication is always triggered by the server. Server-to-Client There are two kinds of command:
Note: Each command always ends with the SYNC byte (CR). GET CommandThe GET command has always a length of 2 bytes (incl. sync). Format: “g\n” Returns: The clients sends a list of comma separated values terminated with a CR. d:123, 1234, 5678, 4367, etc.
SET CommandSet value for a sensor. The SET command has a variable length depending on the actual value to be set. Note: It is not possible to set the 'startup count' value. Sensor # are starting from 1. Format: “s,[sensor n],[value]\n” Returns: The client (sensor board) will respond with “ok,[sensor n],[value]\n” or “fail\n” ExamplesRequesting sensor values: Server: "g\n" Client: "d:61,5367,547543,433,346,7923,643\n" Set value 1234 for sensor #2: Server: "s,2,1234\n" Client: "s:ok,2,1234\n" Set invalid value 12z34 for sensor v #3: Note: invalid digits are stripped out. Value 0 is initially assumed. Server: "s,2,12z34\n" Client: "s:ok,2,1234\n" Send invalid SET command: Server: "s,0,124\n" Client: "s:fail\n" Server: "s,100,124\n" Client: "s:fail\n" |