get rid of some old serial parsing functions

This commit is contained in:
Skot Croshere 2023-05-30 20:42:29 -04:00 committed by johnny9
parent d23a55608c
commit 6560ea3a06
3 changed files with 5 additions and 70 deletions

View File

@ -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

View File

@ -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);

View File

@ -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);
}