static void hx_tx_byte(hx_stream_t stream, uint8_t c) { switch (c) { case FBO: case CEO: hx_tx_raw(stream, CEO); c ^= 0x20; break; } hx_tx_raw(stream, c); }
int hx_stream_send(hx_stream_t stream, const void *data, size_t count) { int result; result = hx_stream_start(stream, data, count); if (result != OK) { return result; } int c; while ((c = hx_stream_send_next(stream)) >= 0) { hx_tx_raw(stream, c); } /* check for transmit error */ if (stream->tx_error) { stream->tx_error = false; return -EIO; } perf_count(stream->pc_tx_frames); return OK; }
int hx_stream_send(hx_stream_t stream, const void *data, size_t count) { union { uint8_t b[4]; uint32_t w; } u; const uint8_t *p = (const uint8_t *)data; unsigned resid = count; if (resid > HX_STREAM_MAX_FRAME) return -EINVAL; /* start the frame */ hx_tx_raw(stream, FBO); /* transmit the data */ while (resid--) hx_tx_byte(stream, *p++); /* compute the CRC */ u.w = crc32(data, count); /* send the CRC */ p = &u.b[0]; resid = 4; while (resid--) hx_tx_byte(stream, *p++); /* and the trailing frame separator */ hx_tx_raw(stream, FBO); /* check for transmit error */ if (stream->txerror) { stream->txerror = false; return -EIO; } perf_count(stream->pc_tx_frames); return 0; }