Simulator: record serial data as comments, not as G-code.
We cheated before and sent the serial data in the simulator into the G-code reporter so it could be line-buffered and then recorded as comments in the trace-log. But this confuses the simulator console output and is harder to manage. Revert to sending serial-out data directly to the comment engine. Also be less chatty about startup when connecting to a UART.
This commit is contained in:
parent
503d2c75a1
commit
573dbfe576
|
|
@ -79,6 +79,20 @@ void record_pin(int pin, int32_t state, uint64_t t) {
|
||||||
values[pin] = state;
|
values[pin] = state;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static char cmt[300];
|
||||||
|
static char *pcmt=cmt;
|
||||||
|
void record_comment_stream(char ch) {
|
||||||
|
if (ch == '\r' || ch == '\n') {
|
||||||
|
record_comment(cmt);
|
||||||
|
pcmt = cmt;
|
||||||
|
*pcmt = 0;
|
||||||
|
}
|
||||||
|
else if (ch && pcmt < cmt+sizeof(cmt)-1) {
|
||||||
|
*pcmt++ = ch;
|
||||||
|
*pcmt = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void record_comment(const char * msg) {
|
void record_comment(const char * msg) {
|
||||||
if (!file) return;
|
if (!file) return;
|
||||||
fprintf(file, "# %s\n", msg);
|
fprintf(file, "# %s\n", msg);
|
||||||
|
|
|
||||||
|
|
@ -60,7 +60,6 @@ static void open_tty(const char *devname)
|
||||||
sim_assert(serial_fd != -1, "couldn't open serial port");
|
sim_assert(serial_fd != -1, "couldn't open serial port");
|
||||||
sim_assert(isatty(serial_fd), "not a TTY");
|
sim_assert(isatty(serial_fd), "not a TTY");
|
||||||
|
|
||||||
sim_info("configuring port");
|
|
||||||
// Get the current options for the port
|
// Get the current options for the port
|
||||||
if (tcgetattr(serial_fd, &options) != 0) {
|
if (tcgetattr(serial_fd, &options) != 0) {
|
||||||
sim_error("tcgetattr");
|
sim_error("tcgetattr");
|
||||||
|
|
@ -125,7 +124,7 @@ uint8_t serial_popchar(void) {
|
||||||
// send one character
|
// send one character
|
||||||
void serial_writechar(uint8_t data) {
|
void serial_writechar(uint8_t data) {
|
||||||
sim_assert(serial_initialised, "serial interface not initialised");
|
sim_assert(serial_initialised, "serial interface not initialised");
|
||||||
sim_gcode_ch(data);
|
record_comment_stream((char)data);
|
||||||
if (serial_fd) {
|
if (serial_fd) {
|
||||||
ssize_t count;
|
ssize_t count;
|
||||||
count = write(serial_fd, &data, 1);
|
count = write(serial_fd, &data, 1);
|
||||||
|
|
@ -137,7 +136,7 @@ void serial_writechar(uint8_t data) {
|
||||||
void serial_writestr(uint8_t *data) {
|
void serial_writestr(uint8_t *data) {
|
||||||
const char *str = (char *)data;
|
const char *str = (char *)data;
|
||||||
sim_assert(serial_initialised, "serial interface not initialised");
|
sim_assert(serial_initialised, "serial interface not initialised");
|
||||||
sim_gcode(str);
|
record_comment(str);
|
||||||
if (serial_fd) {
|
if (serial_fd) {
|
||||||
ssize_t count;
|
ssize_t count;
|
||||||
count = write(serial_fd, str, strlen(str));
|
count = write(serial_fd, str, strlen(str));
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue