diff --git a/avr/main.c b/avr/main.c index 01fedfe..74a32be 100644 --- a/avr/main.c +++ b/avr/main.c @@ -44,6 +44,8 @@ static inline uint16_t checksum() { ISR(SPI_STC_vect) { uint8_t value = SPDR; + uart_putchar(value, NULL); + switch (i) { case 0: { if (value == 0x88) { @@ -131,8 +133,6 @@ ISR(SPI_STC_vect) { } } } - - uart_putchar(value, NULL); } static void setup_clock_external() { diff --git a/include/tabby/avr/uart.h b/include/tabby/avr/uart.h index 5bf5f07..55c34a1 100644 --- a/include/tabby/avr/uart.h +++ b/include/tabby/avr/uart.h @@ -1,7 +1,7 @@ #ifndef _TABBY_AVR_UART_H #define _TABBY_AVR_UART_H -#define TABBY_AVR_UART_BAUD 115200 +#define TABBY_AVR_UART_BAUD 57600 void uart_init(); diff --git a/include/tabby/link.h b/include/tabby/link.h index ce024c9..046deac 100644 --- a/include/tabby/link.h +++ b/include/tabby/link.h @@ -11,7 +11,7 @@ #include -#define TABBY_LINK_BAUD B115200 +#define TABBY_LINK_BAUD B57600 int tabby_link_open(const char *dev); diff --git a/src/printer.c b/src/printer.c index b2e7f4e..5b5b656 100644 --- a/src/printer.c +++ b/src/printer.c @@ -36,22 +36,19 @@ int tabby_printer_packet_recv(int fd, tabby_printer_packet_header *header, while ((len = tabby_link_recv(fd, &value, 1)) >= 0) { if (i == 0) { - if (value == 0x83) { + if (value == 0x88) { header->preamble[0] = value; i++; } else { - errno = EIO; - - goto error_io; + continue; } } else if (i == 1) { if (value == 0x33) { header->preamble[1] = value; i++; } else { - errno = EIO; i = 0; - goto error_io; + continue; } } else if (i == 2) { header->type = value; @@ -65,6 +62,7 @@ int tabby_printer_packet_recv(int fd, tabby_printer_packet_header *header, } else if (i == 5) { header->size |= value << 8; i++; + b = 0; } else if (b < header->size) { ((uint8_t *)body)[b++] = value;