diff --git a/include/tabby/printer.h b/include/tabby/printer.h index dc1d3e6..e12db5b 100644 --- a/include/tabby/printer.h +++ b/include/tabby/printer.h @@ -31,6 +31,8 @@ typedef struct _tabby_printer_packet { }; } tabby_printer_packet; +int tabby_printer_link_init(int fd); + /* * For receiving printer data packets from a Game Boy Camera */ diff --git a/src/printer.c b/src/printer.c index e1eec6c..0d7c3bb 100644 --- a/src/printer.c +++ b/src/printer.c @@ -9,6 +9,23 @@ #define PACKET_RECV_ERROR_THRESHOLD 30 +int tabby_printer_link_init(int fd) { + uint8_t out = 'K', + in; + + while (1) { + read(fd, &in, 1); + + if (in == 'O') { + write(fd, &out, 1); + + break; + } + } + + return 0; +} + static uint16_t checksum(tabby_printer_packet *header, void *body) { uint16_t checksum = header->data[2] + header->data[3]