mirror of https://github.com/rusefi/canable-fw.git
Add firmware version reporting via V slcan message and via USB descriptor
This commit is contained in:
parent
0bc8ec5b42
commit
da4c91cbff
7
Makefile
7
Makefile
|
@ -85,14 +85,21 @@ INCLUDES += $(USER_INCLUDES)
|
|||
# macros for gcc
|
||||
DEFS = -D$(CORE) $(USER_DEFS) -D$(TARGET_DEVICE)
|
||||
|
||||
# Get git version and dirty flag
|
||||
GIT_VERSION := $(shell git describe --abbrev=4 --dirty --always --tags)
|
||||
GIT_REMOTE := $(shell git config --get remote.origin.url)
|
||||
|
||||
# compile gcc flags
|
||||
CFLAGS = $(DEFS) $(INCLUDES)
|
||||
CFLAGS += -mcpu=$(CPU) -mthumb
|
||||
CFLAGS += $(USER_CFLAGS)
|
||||
CFLAGS += -DGIT_VERSION=\"$(GIT_VERSION)\"
|
||||
CFLAGS += -DGIT_REMOTE=\"$(GIT_REMOTE)\"
|
||||
|
||||
# default action: build the user application
|
||||
all: $(BUILD_DIR)/$(TARGET).bin $(BUILD_DIR)/$(TARGET).hex
|
||||
|
||||
|
||||
flash: all
|
||||
sudo dfu-util -d 0483:df11 -c 1 -i 0 -a 0 -s 0x08000000 -D $(BUILD_DIR)/$(TARGET).bin
|
||||
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
#include "stm32f0xx_hal.h"
|
||||
#include "can.h"
|
||||
#include "slcan.h"
|
||||
#include "string.h"
|
||||
#include "usbd_cdc_if.h"
|
||||
|
||||
|
||||
// Parse an incoming CAN frame into an outgoing slcan message
|
||||
|
@ -170,6 +172,12 @@ int8_t slcan_parse_str(uint8_t *buf, uint8_t len)
|
|||
}
|
||||
return 0;
|
||||
|
||||
} else if (buf[0] == 'v' || buf[0] == 'V') {
|
||||
// Report firmware version and remote
|
||||
char* fw_id = GIT_VERSION " " GIT_REMOTE "\r";
|
||||
CDC_Transmit_FS((uint8_t*)fw_id, strlen(fw_id));
|
||||
return 0;
|
||||
|
||||
} else if (buf[0] == 't' || buf[0] == 'T') {
|
||||
// Transmit data frame command
|
||||
frame.RTR = CAN_RTR_DATA;
|
||||
|
|
|
@ -91,20 +91,11 @@
|
|||
* @brief Private defines.
|
||||
* @{
|
||||
*/
|
||||
#define STRINGIZE_(x) #x
|
||||
#define STRINGIZE(x) STRINGIZE_(x)
|
||||
|
||||
#if CANTACT_BUILD_NUMBER == 0
|
||||
#define CANTACT_SW_VER "dev"
|
||||
#else
|
||||
#define CANTACT_SW_VER "b" STRINGIZE(CANTACT_BUILD_NUMBER)
|
||||
#endif
|
||||
|
||||
#define USBD_VID 0xad50
|
||||
#define USBD_LANGID_STRING 1033
|
||||
#define USBD_MANUFACTURER_STRING "CANtact"
|
||||
#define USBD_PID_FS 0x60c4
|
||||
#define USBD_PRODUCT_STRING_FS "CANtact" " " CANTACT_SW_VER
|
||||
#define USBD_PRODUCT_STRING_FS "CANtact" " " GIT_VERSION " " GIT_REMOTE
|
||||
#define USBD_CONFIGURATION_STRING_FS "CDC Config"
|
||||
#define USBD_INTERFACE_STRING_FS "CDC Interface"
|
||||
|
||||
|
|
Loading…
Reference in New Issue