39 if (device == NULL) {
return -1; }
63 static size_t index = 0;
89 ti = read(handle, &(buf[(*hw)]),
N2K_BUFF - (*hw));
93 if (errno != EAGAIN) {
94 fprintf(stderr,
"Unexpected error while reading from serial port (handle ID: 0x%02x)\n",
96 fprintf(stderr,
"read returned \"%s\" in readMessage\n", strerror(errno));
102 if (((*hw) ==
N2K_BUFF) && (*index) > 0 && (*index) > ((*hw) - 25)) {
105 memmove(buf, &(buf[(*index)]),
N2K_BUFF - (*index));
109 if (ti == 0) { out->
priority = 0xFD; }
125 if ((*hw) > 0 && ((*hw) >= (*index))) {
127 memmove(buf, &(buf[(*index)]),
N2K_BUFF - (*index));
#define N2K_BUFF
Default serial buffer allocation size.
bool n2k_act_readMessage(int handle, n2k_act_message *out)
Static wrapper around n2k_readMessage_buf.
void n2k_closeConnection(int handle)
Close N2K serial connection.
int n2k_openConnection(const char *device, const int baud)
Open connection to an N2K serial device.
bool n2k_act_readMessage_buf(int handle, n2k_act_message *out, uint8_t buf[N2K_BUFF], size_t *index, size_t *hw)
Read data from handle, and parse message if able.
int openSerialConnection(const char *port, const int baudRate)
Open a serial connection at a given baud rate.
bool n2k_act_from_bytes(const uint8_t *in, const size_t len, n2k_act_message **msg, size_t *pos, bool debug)
Convert a series of recieved bytes from ACT gateway devices into a message representation.
uint8_t priority
N2K Message priority value.