13char dataBuffer[MAXDATALEN];
22 .state_rw = ®_block};
30int main(
int argc,
char *argv[]) {
33 if (strncmp(
"-h", argv[1], 2) == 0) {
35 "\n ascii_serial_com_dummy_register_device [-h] <infile> "
38 " If no filenames are provided, then stdin and stdout are used\n"
39 " -h: show help and exit\n"
44 if (argc != 3 && argc != 1) {
45 fprintf(stderr,
"Error: either 0 or 2 arguments required:\n");
46 fprintf(stderr,
"\n ascii_serial_com_dummy_register_device [-h] <infile> "
49 " If no filenames are provided, then stdin and stdout are used\n"
50 " -h: show help and exit\n"
60 const char *infilename = argv[1];
61 const char *outfilename = argv[2];
62 fprintf(stdout,
"infile: %s\noutfile: %s\n", infilename, outfilename);
64 infile = fopen(infilename,
"r");
66 perror(
"Error opening input file");
67 fprintf(stderr,
"Exiting.\n");
70 infileno = fileno(infile);
72 perror(
"Error getting infile descriptor");
73 fprintf(stderr,
"Exiting.\n");
76 outfile = fopen(outfilename,
"a+");
78 perror(
"Error opening output file");
79 fprintf(stderr,
"Exiting.\n");
82 outfileno = fileno(outfile);
84 perror(
"Error getting infile descriptor");
85 fprintf(stderr,
"Exiting.\n");
90 fprintf(stderr,
"infile: stdin\noutfile: stdout\n");
93 infileno = STDIN_FILENO;
94 outfileno = STDOUT_FILENO;
107 fprintf(stderr,
"Uncaught exception: %u, during init, exiting.\n", e);
114 if (poll_ret_code != 0) {
133 fprintf(stderr,
"Uncaught exception: %u, exiting.\n", e);
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.
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_init(ascii_serial_com_device *ascd, ascii_serial_com_device_config *config)
ASCII Serial Com Device init.
void ascii_serial_com_register_block_handle_message(ascii_serial_com *asc, char ascVersion, char appVersion, char command, char *data, size_t dataLen, void *register_block_state_vp)
ASCII Serial Com Register Block handle message.
void ascii_serial_com_register_block_init(ascii_serial_com_register_block *register_block_state, REGTYPE *block, uint16_t n_regs)
ASCII Serial Com Register Block init.
ASCII Serial Com Register Block.
bool circular_buffer_is_empty_uint8(const circular_buffer_uint8 *circ_buf)
circular buffer get if empty
uint8_t circular_buffer_io_fd_poll_do_poll(circular_buffer_io_fd_poll *cb_io, int timeout)
poll circular buffer IO with file descriptor polling object
void circular_buffer_io_fd_poll_init(circular_buffer_io_fd_poll *cb_io, circular_buffer_uint8 *in_buf, circular_buffer_uint8 *out_buf, int fd_in, int fd_out)
Initialize circular buffer IO with file descriptor polling object.
size_t circular_buffer_io_fd_poll_do_input(circular_buffer_io_fd_poll *cb_io)
circular buffer IO with file descriptor polling object: read from input fd
size_t circular_buffer_io_fd_poll_do_output(circular_buffer_io_fd_poll *cb_io)
circular buffer IO with file descriptor polling object: write to output fd
Circular buffer IO with file descriptor polling.
ASCII Serial Com Device Config Struct.
void(* func_rw)(ascii_serial_com *, char, char, char, char *data, size_t, void *)
ASCII Serial Com Device State struct.
ASCII Serial Com Register Block State struct.
Circular buffer IO with file descriptor polling struct.