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.h
Go to the documentation of this file.
1#ifndef ASCII_SERIAL_COM_DEVICE_H
2#define ASCII_SERIAL_COM_DEVICE_H
3
4/** \file ascii_serial_com_device.h
5 * \brief ASCII Serial Com Device
6 *
7 */
8
9#include "ascii_serial_com.h"
10
11/** \brief ASCII Serial Com Device Config Struct
12 *
13 * Use at initialization to configure a device
14 *
15 * Passed to ascii_serial_com_device_init
16 *
17 * Define like:
18 *
19 * ascii_serial_com_device_config dev_config = {.func_rw = myfunrw, .state_rw =
20 * myrwstate};
21 *
22 * All other members set to 0 (so null pointers).
23 *
24 */
26 void (*func_rw)(ascii_serial_com *, char, char, char, char *data, size_t,
27 void *); /**< called for r or w messages */
28 void (*func_s)(ascii_serial_com *, char, char, char, char *data, size_t,
29 void *); /**< called for s messages */
30 void (*func_nf)(ascii_serial_com *, char, char, char, char *data, size_t,
31 void *); /**< called for n and f messages */
32 void *state_rw;
33 void *state_s;
34 void *state_nf;
36
37/** \brief ASCII Serial Com Device State struct
38 *
39 * Keeps track of the state of the ASCII Serial Com device
40 *
41 * The functions take the stuff from
42 * ascii_serial_com_get_message_from_input_buffer plus a void pointer to
43 * possible state/configuration info. If the functions are null ptrs, an error
44 * message returned to host. This class owns the data buffer passed around.
45 */
47 ascii_serial_com asc; /**< used to receive messages and reply */
48 char ascVersion; /**< This and next 4 variables just hold results, putting
49 them here lets them be statically allocated */
50 char appVersion;
51 char command;
52 char dataBuffer[MAXDATALEN]; /**< data part of message received here */
53 size_t dataLen;
56
57/** \brief ASCII Serial Com Device init
58 *
59 * Initialize ASCII Serial Com device
60 *
61 * The functions take the stuff from
62 * ascii_serial_com_get_message_from_input_buffer plus a void pointer to
63 * possible state/configuration info. If the functions are null ptrs, an error
64 * message returned to host. This class owns the data buffer passed around.
65 *
66 */
69
70/** \brief ASCII Serial Com Device receive messages
71 *
72 * Receives ASCII Serial Com messages, and hands them over to the
73 * appropriate one of the functions
74 *
75 * /param ascd: initialized ascii_serial_com_device
76 *
77 */
79
80/** \brief ASCII Serial Com Device get input buffer
81 *
82 * MAKE SURE ascd IS ALREADY INITIALIZED!
83 *
84 * /param ascd: initialized ascii_serial_com_device
85 */
88
89/** \brief ASCII Serial Com Device get output buffer
90 *
91 * MAKE SURE ascd IS ALREADY INITIALIZED!
92 *
93 * /param ascd: initialized ascii_serial_com_device
94 */
97
98/** \brief ASCII Serial Com Device put a message in output buffer
99 *
100 * MAKE SURE ascd IS ALREADY INITIALIZED!
101 *
102 */
104 ascii_serial_com_device *ascd, char ascVersion, char appVersion,
105 char command, char *data, size_t dataLen);
106
107/** \brief ASCII Serial Com Device put a 's' message in output buffer
108 *
109 * MAKE SURE ascd IS ALREADY INITIALIZED!
110 *
111 */
113 ascii_serial_com_device *ascd, char ascVersion, char appVersion, char *data,
114 size_t dataLen);
115
116#endif
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.
struct __ascii_serial_com_device_config ascii_serial_com_device_config
ASCII Serial Com Device Config Struct.
struct __ascii_serial_com_device ascii_serial_com_device
ASCII Serial Com Device State struct.
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 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.
ASCII Serial Com Interface State struct.
circular buffer struct