ASCII Serial Com
Serial communication library between computers, microcontrollers, FPGAs, etc. Uses only ASCII. Not the most efficient protocol, but meant to be easy to read
Loading...
Searching...
No Matches
ascii_serial_com_device.c
Go to the documentation of this file.
2
3/** \file */
4
10
12
14 &ascd->asc, &ascd->ascVersion, &ascd->appVersion, &ascd->command,
15 ascd->dataBuffer, &ascd->dataLen);
16 if (ascd->command == '\0') { // no message in input buffer
17 // pass
18 } else if (ascd->command == 'r' || ascd->command == 'w') {
19 if (ascd->config->func_rw) {
20 ascd->config->func_rw(&ascd->asc, ascd->ascVersion, ascd->appVersion,
21 ascd->command, ascd->dataBuffer, ascd->dataLen,
22 ascd->config->state_rw);
23 } else {
25 &ascd->asc, ascd->ascVersion, ascd->appVersion, ascd->command,
26 ascd->dataBuffer, ascd->dataLen, ASC_ERROR_COMMAND_NOT_IMPLEMENTED);
27 }
28 } else if (ascd->command == 's') {
29 if (ascd->config->func_s) {
30 ascd->config->func_s(&ascd->asc, ascd->ascVersion, ascd->appVersion,
31 ascd->command, ascd->dataBuffer, ascd->dataLen,
32 ascd->config->state_s);
33 } else {
35 &ascd->asc, ascd->ascVersion, ascd->appVersion, ascd->command,
36 ascd->dataBuffer, ascd->dataLen, ASC_ERROR_COMMAND_NOT_IMPLEMENTED);
37 }
38 } else if (ascd->command == 'n' || ascd->command == 'f') {
39 if (ascd->config->func_nf) {
40 ascd->config->func_nf(&ascd->asc, ascd->ascVersion, ascd->appVersion,
41 ascd->command, ascd->dataBuffer, ascd->dataLen,
42 ascd->config->state_nf);
43 } else {
45 &ascd->asc, ascd->ascVersion, ascd->appVersion, ascd->command,
46 ascd->dataBuffer, ascd->dataLen, ASC_ERROR_COMMAND_NOT_IMPLEMENTED);
47 }
48 } else if (ascd->command == 'z') {
49 // pass this is noop
50 } else {
52 &ascd->asc, ascd->ascVersion, ascd->appVersion, ascd->command,
53 ascd->dataBuffer, ascd->dataLen, ASC_ERROR_COMMAND_NOT_IMPLEMENTED);
54 }
55}
56
61
66
68 ascii_serial_com_device *ascd, char ascVersion, char appVersion,
69 char command, char *data, size_t dataLen) {
71 &ascd->asc, ascVersion, appVersion, command, data, dataLen);
72}
73
75 ascii_serial_com_device *ascd, char ascVersion, char appVersion, char *data,
76 size_t dataLen) {
78 &ascd->asc, ascVersion, appVersion, data, dataLen);
79}
circular_buffer_uint8 * ascii_serial_com_get_output_buffer(ascii_serial_com *asc)
ASCII Serial Com get output buffer.
void ascii_serial_com_put_s_message_in_output_buffer(ascii_serial_com *asc, char ascVersion, char appVersion, const char *data, size_t dataLen)
ASCII Serial Com Pack and put 's' message in output buffer.
void ascii_serial_com_init(ascii_serial_com *asc)
ASCII Serial Com Interface init method.
void ascii_serial_com_put_message_in_output_buffer(ascii_serial_com *asc, char ascVersion, char appVersion, char command, const char *data, size_t dataLen)
ASCII Serial Com Pack and put message in output buffer.
void ascii_serial_com_get_message_from_input_buffer(ascii_serial_com *asc, char *ascVersion, char *appVersion, char *command, char *data, size_t *dataLen)
ASCII Serial Com pop message from input buffer and unpack.
void ascii_serial_com_put_error_in_output_buffer(ascii_serial_com *asc, char ascVersion, char appVersion, char command, char *data, size_t dataLen, enum asc_exception errorCode)
ASCII Serial Com put error message in out buffer.
circular_buffer_uint8 * ascii_serial_com_get_input_buffer(ascii_serial_com *asc)
ASCII Serial Com get input buffer.
circular_buffer_uint8 * ascii_serial_com_device_get_output_buffer(ascii_serial_com_device *ascd)
ASCII Serial Com Device get output buffer.
void ascii_serial_com_device_receive(ascii_serial_com_device *ascd)
ASCII Serial Com Device receive messages.
void ascii_serial_com_device_put_s_message_in_output_buffer(ascii_serial_com_device *ascd, char ascVersion, char appVersion, char *data, size_t dataLen)
ASCII Serial Com Device put a 's' message in output buffer.
circular_buffer_uint8 * ascii_serial_com_device_get_input_buffer(ascii_serial_com_device *ascd)
ASCII Serial Com Device get input buffer.
void ascii_serial_com_device_put_message_in_output_buffer(ascii_serial_com_device *ascd, char ascVersion, char appVersion, char command, char *data, size_t dataLen)
ASCII Serial Com Device put a message in output buffer.
void ascii_serial_com_device_init(ascii_serial_com_device *ascd, ascii_serial_com_device_config *config)
ASCII Serial Com Device init.
ASCII Serial Com Device.
ASCII Serial Com Device Config Struct.
void(* func_nf)(ascii_serial_com *, char, char, char, char *data, size_t, void *)
void(* func_s)(ascii_serial_com *, char, char, char, char *data, size_t, void *)
void(* func_rw)(ascii_serial_com *, char, char, char, char *data, size_t, void *)
ASCII Serial Com Device State struct.
circular buffer struct