You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

30 lines
614 B

/*
* command_interpreter.c
*
* Created on: Jul 10, 2021
* Author: Andreas Berthoud
*/
#include "usbd_cdc_if.h"
#include "commands.h"
void usb_receive(uint8_t *buf, uint32_t *len) {
CDC_Transmit_FS(buf, *len); // echo
if (*len < 5) {
return;
}
uint8_t command_id = buf[0];
uint16_t length = buf[1] << 8 | buf[2];
uint8_t * payload_ptr = buf + 4;
uint8_t stop_byte = 0x1;
if (*len >= 4 + length) {
stop_byte = buf[4+ length];
}
log_debug("received command, id: 0x%x", 1, command_id);
log_debug("length: %n", 1, length);
log_debug("stop_byte: 0x%x", 1, stop_byte);
}