6.4. COM

The com module is part of the Application layer.

The com module handles communication between the MCU and external devices. It makes use of different interfaces (e.g., uart module) for this purpose.

6.4.1. Module Files

  • embedded-software\mcu-primary\src\application\com\com.h (com.c)
  • embedded-software\mcu-primary\src\application\com\com.c (com.h)

6.4.2. Establishing Connection with PC

  1. Connect PC with USB cable to primary USB interface
  2. Start a terminal program (e.g., HTerm)
  3. Select correct COM Port
  4. Select following settings:
  • Baudrate: 115200 Bd
  • Databits: 8, Stopbits: 1, Parity: None
  • DTR: disabled, RTS: disabled
  • Send on enter: LF

6.4.3. Functionality

The com module provides possibilities for communication with external devices using UART. For incoming requests, it provides some kind of basic command parser/handler and access to the sys module. Furthermore, it provides the user with some information about the system and a testmode where the system settings can be alternated and basic system tests can be performed.

The com module can be enabled by using the BUILD_MODULE_ENABLE_COM define. Its handler needs to be called periodically (e.g., by using ENG_TSK_Cyclic_10ms()). Currently the COM_Decoder supports following commands:

Command Description
help get available command list
gettime get system time
getruntime get runtime since last reset
printdiaginfo get diagnosis entries of DIAG module (entries can only be printed once)
printcontactorinfo get contactor information (number of switches/hard switches) (entries can only be printed once)
teston enable testmode, testmode will be disabled after a predefined timeout of 30s when no new command is sent

Following commands are only available during enabled testmode:

Command Description
testoff disable testmode
settime YY MM DD HH MM SS set mcu time and date (YY-year, MM-month, DD-date, HH-hours, MM-minutes, SS-seconds)
reset enforces complete software reset using HAL_NVIC_SystemReset()
watchdogtest performs watchdog test, watchdog timeout results in system reset (predefined 1s)
setsoc xxx.xxx set SOC value (000.000% - 100.000%)
contactor enable X enables contactor number X (only possible if BMS is in no error state)
contactor disable X disables contactor number X (only possible if BMS is in no error state)