From 6560ea3a0629c71f48ba2e2e47f0722172516d59 Mon Sep 17 00:00:00 2001 From: Skot Croshere Date: Tue, 30 May 2023 20:42:29 -0400 Subject: [PATCH] get rid of some old serial parsing functions --- components/bm1397/bm1397.c | 59 ------------------------------ components/bm1397/include/bm1397.h | 2 - components/bm1397/serial.c | 14 +++---- 3 files changed, 5 insertions(+), 70 deletions(-) diff --git a/components/bm1397/bm1397.c b/components/bm1397/bm1397.c index 685a5b66..3cded61d 100644 --- a/components/bm1397/bm1397.c +++ b/components/bm1397/bm1397.c @@ -39,65 +39,6 @@ void init_BM1397(void) { } -//parse job/nonce response -void parse_job_response(unsigned char *buf, int len) { - struct nonce_response * nonce; - - //get the response into the nonce struct - //memcpy((void *)&nonce, buf, len); - nonce = (struct nonce_response *)buf; - - printf("nonce: %08X @ %02X\n", flip32(nonce->nonce), nonce->job_id); - return; -} - -void parse_cmd_packet(unsigned char *buf, int len) { - printf("cmd packet\n"); -} - -//split the response packet into individual packets -void split_response(unsigned char *buf, int len) { - int i; - int packet_len; - int packet_start = 0; - - //split the response into individual packets - for (i = 1; i < len; i++) { - if ((buf[i] == 0xAA) && (buf[i+1] == 0x55)) { - packet_len = i - packet_start; - parse_packet(buf+packet_start, packet_len); - packet_start = i; - } - } - - //parse the last packet - packet_len = i - packet_start; - parse_packet(buf+packet_start, packet_len); -} - - -//parse incoming packets -void parse_packet(unsigned char *buf, int len) { - //response_type_t response_type; - - //debug the packet - printf("<-"); - prettyHex(buf, len); - printf("\n"); - - - //determine response type - if (buf[len-1] & RESPONSE_JOB) { - //response_type = JOB_RESP; - parse_job_response(buf, len); - } else { - //response_type = CMD_RESP; - parse_cmd_packet(buf, len); - } - -} - - /// @brief /// @param ftdi /// @param header diff --git a/components/bm1397/include/bm1397.h b/components/bm1397/include/bm1397.h index a5a68180..959e3172 100644 --- a/components/bm1397/include/bm1397.h +++ b/components/bm1397/include/bm1397.h @@ -55,8 +55,6 @@ struct __attribute__((__packed__)) nonce_response { void send_read_address(void); void send_init(void); void send_work(struct job_packet *job); -void parse_packet(unsigned char *buf, int len); -void split_response(unsigned char *buf, int len); void reset_BM1397(void); void init_BM1397(void); diff --git a/components/bm1397/serial.c b/components/bm1397/serial.c index 6447233d..d84662ed 100644 --- a/components/bm1397/serial.c +++ b/components/bm1397/serial.c @@ -55,11 +55,11 @@ int send_serial(uint8_t *data, int len, bool debug) { /// @return number of bytes read, or -1 on error int16_t serial_rx(uint8_t * buf) { int16_t bytes_read = uart_read_bytes(UART_NUM_1, buf, BUF_SIZE, 20 / portTICK_RATE_MS); - if (bytes_read > 0) { - printf("bm rx\n"); - prettyHex((unsigned char*) buf, bytes_read); - printf("\n"); - } + // if (bytes_read > 0) { + // printf("rx: "); + // prettyHex((unsigned char*) buf, bytes_read); + // printf("\n"); + // } return bytes_read; } @@ -73,10 +73,6 @@ void debug_serial_rx(void) { return; } - if (ret > 0) { - split_response(buf, ret); - } - memset(buf, 0, 1024); }