User Tools

Site Tools


rascii-en

RASCII

Setup

ASCII���Screenshot

Options

Ping

A Ping command will be sent with this interval in ms.
Disabled in case of zero.
The Ping can be used as "Dead man's switch".


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.

Serial Monitor

Serial monitor input is a way to provide easy setting up a unit, for example the WiFi settings.
The input should be read until a linefeed has been detected, and do not have a length field.

Help

Prefix Remark
? Should show help regarding monitor commands.

CV

Prefix Example Remark
* *ssid=myhome The help function should list up all possible settings.


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-High, CV-Low A CV number and value response.
7 # Set CV CV-High, CV-Low, value A remark.
10 # Digital output Address, port, on/off -
11 # Analog output Address, Port, value Value can be brightness, followed by three bytes RGB.
12 # Accessory Address, Port, aspect1) -
13 # Mobile speed Address-High, Address-Low, direction/speed2) -
14 # Mobile function Address-High, Address-Low, function, value, lights, fx Lights and FX(32bit) are for information only and optional.
37 # PT ON none A remark.
38 # PT OFF none A remark.
39 # Accessory CV get Address-High, Address-Low, CV-High, CV-Low A CV number and value response.
40 # Accessory CV set Address-High, Address-Low, CV-High, CV-Low, value A remark.


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

1)
0=straight, 1=turnout
2)
dir=0x80, speed=0x7F
rascii-en.txt · Last modified: 2022/12/11 00:48 by rainerk