You know what? This, right here, fucking works

This commit is contained in:
XANTRONIX Development 2016-05-31 19:32:20 -05:00
parent ee796c04e2
commit 68852d460b
4 changed files with 8 additions and 10 deletions

View file

@ -44,6 +44,8 @@ static inline uint16_t checksum() {
ISR(SPI_STC_vect) { ISR(SPI_STC_vect) {
uint8_t value = SPDR; uint8_t value = SPDR;
uart_putchar(value, NULL);
switch (i) { switch (i) {
case 0: { case 0: {
if (value == 0x88) { if (value == 0x88) {
@ -131,8 +133,6 @@ ISR(SPI_STC_vect) {
} }
} }
} }
uart_putchar(value, NULL);
} }
static void setup_clock_external() { static void setup_clock_external() {

View file

@ -1,7 +1,7 @@
#ifndef _TABBY_AVR_UART_H #ifndef _TABBY_AVR_UART_H
#define _TABBY_AVR_UART_H #define _TABBY_AVR_UART_H
#define TABBY_AVR_UART_BAUD 115200 #define TABBY_AVR_UART_BAUD 57600
void uart_init(); void uart_init();

View file

@ -11,7 +11,7 @@
#include <tabby/clock.h> #include <tabby/clock.h>
#define TABBY_LINK_BAUD B115200 #define TABBY_LINK_BAUD B57600
int tabby_link_open(const char *dev); int tabby_link_open(const char *dev);

View file

@ -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) { while ((len = tabby_link_recv(fd, &value, 1)) >= 0) {
if (i == 0) { if (i == 0) {
if (value == 0x83) { if (value == 0x88) {
header->preamble[0] = value; header->preamble[0] = value;
i++; i++;
} else { } else {
errno = EIO; continue;
goto error_io;
} }
} else if (i == 1) { } else if (i == 1) {
if (value == 0x33) { if (value == 0x33) {
header->preamble[1] = value; header->preamble[1] = value;
i++; i++;
} else { } else {
errno = EIO;
i = 0; i = 0;
goto error_io; continue;
} }
} else if (i == 2) { } else if (i == 2) {
header->type = value; header->type = value;
@ -65,6 +62,7 @@ int tabby_printer_packet_recv(int fd, tabby_printer_packet_header *header,
} else if (i == 5) { } else if (i == 5) {
header->size |= value << 8; header->size |= value << 8;
i++; i++;
b = 0; b = 0;
} else if (b < header->size) { } else if (b < header->size) {
((uint8_t *)body)[b++] = value; ((uint8_t *)body)[b++] = value;