diff --git a/avr/send.c b/avr/send.c index 08c78ec..37dd210 100644 --- a/avr/send.c +++ b/avr/send.c @@ -12,13 +12,12 @@ static tabby_printer_packet header = { .size = 0 }; +static tabby_printer_response response; + static uint8_t body[TABBY_PRINTER_MAX_PACKET_SIZE]; static uint16_t sum = 0x0000; -static uint8_t device = 0x00, - status = 0x00; - /* * So like, we're abusing pins here. So badly, it's beyond. So here's what's * going down: We want to retain the same physical I/O connections between @@ -102,8 +101,8 @@ static void spi_send_packet() { (void)spi_send_byte( sum & 0x00ff); (void)spi_send_byte((sum & 0xff00) >> 8); - device = spi_send_byte(0); - status = spi_send_byte(0); + response.device = spi_send_byte(0); + response.status = spi_send_byte(0); _delay_us(270); } @@ -228,8 +227,8 @@ int main() { if (sum == checksum()) { spi_send_packet(); - uart_putchar(device, NULL); - uart_putchar(status, NULL); + uart_putchar(response.device, NULL); + uart_putchar(response.status, NULL); } } } diff --git a/include/tabby/printer.h b/include/tabby/printer.h index e12db5b..12243a2 100644 --- a/include/tabby/printer.h +++ b/include/tabby/printer.h @@ -31,6 +31,11 @@ typedef struct _tabby_printer_packet { }; } tabby_printer_packet; +typedef struct _tabby_printer_response { + uint8_t device; + uint8_t status; +} tabby_printer_response; + int tabby_printer_link_init(int fd); /* @@ -46,6 +51,6 @@ int tabby_printer_packet_recv(int fd, int tabby_printer_packet_send(int fd, tabby_printer_packet *header, void *body, - uint16_t *response); + tabby_printer_response *response); #endif /* _TABBY_PRINTER_H */ diff --git a/src/printer.c b/src/printer.c index 0d7c3bb..550eb93 100644 --- a/src/printer.c +++ b/src/printer.c @@ -110,7 +110,7 @@ error_io: int tabby_printer_packet_send(int fd, tabby_printer_packet *header, void *body, - uint16_t *response) { + tabby_printer_response *response) { uint16_t sum = checksum(header, body); if (write(fd, header, sizeof(*header)) < 0) {