rascii-en
Differences
This shows you the differences between two versions of the page.
Previous revision | |||
— | rascii-en [2022/12/11 00:48] (current) – obsolete trouble shooting section removed rainerk | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== RASCII ====== | ||
+ | [[: | ||
+ | [[: | ||
+ | \\ | ||
+ | {{: | ||
+ | \\ | ||
+ | =====Setup===== | ||
+ | {{: | ||
+ | ====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 | '' | ||
+ | ====Response==== | ||
+ | ^ Prefix ^ Length ^ Command ^ Data ^ Example ^ | ||
+ | | & | 00...FF | 00...FF | 0...n | | | ||
+ | ====Event==== | ||
+ | ^ Prefix ^ Length ^ Event ^ Data ^ Example ^ | ||
+ | | $ | 00...FF | 00...FF | 0...n | '' | ||
+ | |||
+ | ====Info==== | ||
+ | ^ Prefix ^ Length ^ Text ^ Example ^ | ||
+ | | # | 00...FF | 0...n | ''# | ||
+ | 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 ^ | ||
+ | | * | '' | ||
+ | |||
+ | |||
+ | \\ | ||
+ | =====HEXA===== | ||
+ | HEXA is the Hexadecimal-ASCII representation of a binary number.\\ | ||
+ | A decimal value of 47, for example, is represented in HEXA as " | ||
+ | |||
+ | ====Code examples==== | ||
+ | ===Convert a HEXA string to a Byte value=== | ||
+ | Paratemers: | ||
+ | * s = HEXA string | ||
+ | Returns: The byte value\\ | ||
+ | <code C> | ||
+ | byte HexA2Byte( const char* s ) { | ||
+ | byte h, l, val; | ||
+ | if( s[0] >= ' | ||
+ | else h = s[0] -48; | ||
+ | if( s[1] >= ' | ||
+ | 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\\ | ||
+ | <code C> | ||
+ | const char* Byte2HexA(byte b, char* s) { | ||
+ | static char cHex[] = {' | ||
+ | s[0] = cHex[(b& | ||
+ | s[1] = cHex[ b& | ||
+ | s[2] = ' | ||
+ | return s; | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | \\ | ||
+ | |||
+ | =====Read sequence===== | ||
+ | - Read byte by byte until a prefix is detected. | ||
+ | - Read the next two HEXA characters and convert them to a number for the length. | ||
+ | - Read the number of bytes as set in the length field. | ||
+ | - Convert the HEXA to Bytes. | ||
+ | - Evaluate the message. | ||
+ | - 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, aspect((0=straight, | ||
+ | | 13 | # | Mobile speed | Address-High, | ||
+ | | 14 | # | Mobile function | Address-High, | ||
+ | | 37 | # | PT ON | none | A remark. | | ||
+ | | 38 | # | PT OFF | none | A remark. | | ||
+ | | 39 | # | Accessory CV get | Address-High, | ||
+ | | 40 | # | Accessory CV set | Address-High, | ||
+ | |||
+ | \\ | ||
+ | =====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==== | ||
+ | * https:// | ||
+ | * {{: | ||
+ | |||
+ | \\ |