|
rcbench
Servo and ESC test bench: panel, IOmcu and shared C
|
The card's side of the programmer for servos by Hitec: the text of the record of a write, which survives a restart of the panel, and its parse. More...
Go to the source code of this file.
Data Structures | |
| struct | hitec_card_record_t |
| A record of a write. More... | |
Enumerations | |
| enum | hitec_card_result_t { HITEC_CARD_OK = 0 , HITEC_CARD_NONE , HITEC_CARD_ERR_HEADER , HITEC_CARD_ERR_TRUNCATED , HITEC_CARD_ERR_CHECK , HITEC_CARD_ERR_FIELD } |
| What a parse found. More... | |
Functions | |
| unsigned | hitec_card_addrs (uint8_t series, uint8_t out[HITEC_C_BLOCK_LEN]) |
The addresses a record holds for series. | |
| size_t | hitec_card_text (const hitec_card_record_t *r, char *out, size_t n) |
The text of r, or of no record for NULL. | |
| hitec_card_result_t | hitec_card_parse (const char *text, size_t len, hitec_card_record_t *out) |
| Parse a text. | |
The card's side of the programmer for servos by Hitec: the text of the record of a write, which survives a restart of the panel, and its parse.
Hitec is a name or trademark of its owner; it is used here only to say which servos this module works with.
Before the first step of a write, hitec_prog.h records the servo's values, the values the write is to leave, the series, the port and the GPIO that port drives. With a card mounted the record goes to BENCH/HITEC/CONF/HITEC.TXT (CARD_HITEC_CONF) and is read again at the panel's next start. A write that ends verified clears it: the text then holds no record.
The record holds the addresses a write can change: classic cells 0x00 to 0x23 (hitec_writable() and the balance 0x1C), and the 21 D series registers of a full read (hitec_d_read_list()). The text, at most HITEC_CARD_TEXT_MAX bytes with its terminator, X a hexadecimal digit:
RCBENCH HITEC 1 series=C or D the series of the write port=X the programming port, from 0 pin=XX its GPIO, FF not known before=XX... classic: 36 cells of 2 digits; D target=XX... series: 21 registers of 4 digits, high digit first check=XXXX link_crc() of the bytes before
A text with no record is the first line and the check line. The digits are upper case. A text that does not end with its check line, whose check does not match, or whose lines are not these, is refused whole.
Pure C, no heap, no card access: the caller writes and reads the bytes.
SPDX-License-Identifier: MIT
| enum hitec_card_result_t |
| unsigned hitec_card_addrs | ( | uint8_t | series, |
| uint8_t | out[HITEC_C_BLOCK_LEN] ) |
The addresses a record holds for series.
| series | hitec_family_t. |
| out | Receives up to 36 addresses, ascending. |
| hitec_card_result_t hitec_card_parse | ( | const char * | text, |
| size_t | len, | ||
| hitec_card_record_t * | out ) |
Parse a text.
A record's images know the addresses hitec_card_addrs() names, nothing else. A pin above 47 reads as HITEC_CARD_NO_PIN.
| text | The text; it need not be terminated. |
| len | Its length in bytes. |
| out | Receives the record on HITEC_CARD_OK; untouched otherwise. |
| size_t hitec_card_text | ( | const hitec_card_record_t * | r, |
| char * | out, | ||
| size_t | n ) |
The text of r, or of no record for NULL.
Only the addresses hitec_card_addrs() names are written; a byte that is not known is written as its value all the same.
| r | The record; NULL for a text without one. |
| out | Receives the text, terminated. |
| n | Bytes at out, HITEC_CARD_TEXT_MAX or more. |
n is too small, r names a series other than classic and D, or a port above 15.