RASCII

Definition

The RASCII protocol uses HEXA for all fields except the prefix and remark text.

Command

Prefix Length Command Data Example
@ 00…FF 00…FF 0…n @040101

Response

Prefix Length Command Data Example
& 00…FF 00…FF 0…n

Event

Prefix Length Event Data Example
$ 00…FF 00…FF 0…n $100200010102030405

Info

Prefix Length Text Example
# 00…FF 0…n #0CRocDino V0.1

The info text may not contain any of the prefixes. This will make the message invalid and will be rejected.


HEXA

HEXA is the Hexadecimal-ASCII representation of a binary number.
A decimal value of 47, for example, is represented in HEXA as “2F”.

Code examples

Convert a HEXA string to a Byte value

Paratemers:

  • s = HEXA string

Returns: The byte value

byte HexA2Byte( const char* s ) {
  byte h, l, val;
  if( s[0] >= 'A' ) h = s[0] - 55;
  else h = s[0] -48; 
  if( s[1] >= 'A' ) l = s[1] - 55;
  else l = s[1] -48; 
  val = l + (h << 4);
  return val;
}

Convert a Byte value to a HEXA string

Paratemers:

  • b = Byte value
  • s = Buffer for receiving the HEXA string

Returns: The pointer to the HEXA string buffer

const char* Byte2HexA(byte b, char* s) {
  static char cHex[] = {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
  s[0] = cHex[(b&0xF0)>>4];
  s[1] = cHex[ b&0x0F    ];
  s[2] = '\0';
  return s;
}


Read sequence

  1. Read byte by byte until a prefix is detected.
  2. Read the next two HEXA characters and convert them to a number for the length.
  3. Read the number of bytes as set in the length field.
  4. Convert the HEXA to Bytes.
  5. Evaluate the message.
  6. Repeat.


Commands

Board # FF is broadcast.

Code Board Description Parameters Reply
0 # Get information none A remark with version information.
1 # Start none A remark.
2 # Stop none A remark.
3 # Get config none The board configuration response.
4 # Set config The board configuration.
5 # Reset config none
6 # Get CV CV number A CV value response.
7 # Set CV CV number, value A remark.
10 # Digital output Address, port, on/off -
11 # Analog output Address, Port, value -
126 # Poll RS485 none Queued event, reply or an ACK if the queue is empty.
127 # Acknowledge Code none


Events

Board # FF is broadcast.

Code Board Description Parameters Remark
1 # Occupancy Port, Status on/off
2 # RFID Port, RFID bytes All RFID bytes may be set zero to signal depart.
Sending a one byte zero ID will also be evaluated as departed.
3 # Digital input Port, on/off
4 # Analog input Port, value H/L

Events maybe acknowledged by the host program.


Libraries

Arduino

Trouble shooting

Windows crash nach Rocrail start

Some Windows configurations will crash at Rocrail server startup if the Arduino is connected by USB and the following option is not set:


Personal Tools