wip-behaviors #3
@@ -1,5 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <pico/stdio.h>
|
||||||
#include "crc.h"
|
#include "crc.h"
|
||||||
#include "stdio.h"
|
#include "stdio.h"
|
||||||
|
|
||||||
@@ -58,15 +59,22 @@ enum {
|
|||||||
TSTATE_BUILD_MSG,
|
TSTATE_BUILD_MSG,
|
||||||
};
|
};
|
||||||
|
|
||||||
inline void send_tRespState(tRespState *resp) {
|
static inline void write_raw(void* data, size_t n) {
|
||||||
|
const uint8_t* a = data;
|
||||||
|
for(size_t i = 0; i < n; i++){
|
||||||
|
putchar_raw(a[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void send_tRespState(tRespState *resp) {
|
||||||
resp->crc = crcFooter(*resp);
|
resp->crc = crcFooter(*resp);
|
||||||
fwrite(resp, 1, sizeof(tRespState), stdout);
|
write_raw(resp, sizeof(tRespState));
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void send_tRespEndCalib(tRespEndCalib *state) {
|
static inline void send_tRespEndCalib(tRespEndCalib *state) {
|
||||||
state->crc = crcFooter(*state);
|
state->crc = crcFooter(*state);
|
||||||
fwrite(state, 1, sizeof(tRespEndCalib), stdout);
|
write_raw(state, sizeof(tRespEndCalib));
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ static void stdio_dual_usb_out_chars(const char *buf, int length) {
|
|||||||
tud_task();
|
tud_task();
|
||||||
tud_cdc_n_write_flush(itf);
|
tud_cdc_n_write_flush(itf);
|
||||||
if (!stdio_dual_usb_connected() ||
|
if (!stdio_dual_usb_connected() ||
|
||||||
(!tud_cdc_write_available() &&
|
(!tud_cdc_n_write_available(itf) &&
|
||||||
time_us_64() >
|
time_us_64() >
|
||||||
last_avail_time[itf] + STDIO_DUAL_USB_STDOUT_TIMEOUT_US)) {
|
last_avail_time[itf] + STDIO_DUAL_USB_STDOUT_TIMEOUT_US)) {
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user