Serial Sensor Protocol V2 (EN)

Description

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

  • 'g' (0x67) get sensor values command
  • 's' (0x73) set sensor value command

Note: Each command always ends with the SYNC byte (CR).

GET Command

The 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.
ValueDescription
Prefix“d:” stands for 'data'
1. Valuerestart count
2. Valuevalue of sensor 1
3. Valuevalue of sensor 2
n. valuevalue of sensor n

SET Command

Set 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”

Examples

Requesting 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"
 
 
technical/sensor_proto_v2.txt · Last modified: 2011/01/20 11:35 by adminuser
Recent changes RSS feed Creative Commons License Valid XHTML 1.0 Valid CSS Driven by DokuWiki
Drupal Garland Theme for Dokuwiki