fixed error on can parsing
This commit is contained in:
@@ -139,6 +139,10 @@ void byteToHex(uint8_t byte, char * hex) {
|
|||||||
hex[1] = hexLookup[byte & 0x0F];
|
hex[1] = hexLookup[byte & 0x0F];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static FDCAN_RxHeaderTypeDef RxHeader = {0};
|
||||||
|
static uint8_t RxData[8] = {0};
|
||||||
|
|
||||||
void CarCanTask_func(void *argument) {
|
void CarCanTask_func(void *argument) {
|
||||||
|
|
||||||
// for testing accept all messages from the car can bus
|
// for testing accept all messages from the car can bus
|
||||||
@@ -160,8 +164,7 @@ void CarCanTask_func(void *argument) {
|
|||||||
Error_Handler();
|
Error_Handler();
|
||||||
}
|
}
|
||||||
|
|
||||||
FDCAN_RxHeaderTypeDef RxHeader;
|
|
||||||
uint8_t RxData[8];
|
|
||||||
|
|
||||||
for(;;) {
|
for(;;) {
|
||||||
// wait for interrupt event on any fifo
|
// wait for interrupt event on any fifo
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ void Vehicle_Setup_CAN() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void rx_unlock(uint8_t * RxData ) {
|
static void rx_unlock_key(uint8_t * RxData ) {
|
||||||
if (RxData[1] == 0x04)
|
if (RxData[1] == 0x04)
|
||||||
{
|
{
|
||||||
// car was unlocked
|
// car was unlocked
|
||||||
@@ -47,6 +47,20 @@ static void rx_unlock(uint8_t * RxData ) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void rx_unlock_secure(uint8_t * RxData ) {
|
||||||
|
if ((RxData[0] & 0x0F) == 0x01) {
|
||||||
|
// car was unlocked
|
||||||
|
last_unlock_message_time = osKernelGetTickCount();
|
||||||
|
|
||||||
|
} else if ((RxData[0] & 0x0F) == 0x02) {
|
||||||
|
// car was locked
|
||||||
|
if (!BSP_GPIO_K15isSet()) {
|
||||||
|
NVIC_SystemReset();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
static void rx_speed(uint8_t * RxData) {
|
static void rx_speed(uint8_t * RxData) {
|
||||||
// speed signal
|
// speed signal
|
||||||
@@ -70,11 +84,11 @@ static void rx_brightness(uint8_t* RxData) {
|
|||||||
void Vehicle_Receive_CAN( FDCAN_RxHeaderTypeDef RxHeader, uint8_t* RxData) {
|
void Vehicle_Receive_CAN( FDCAN_RxHeaderTypeDef RxHeader, uint8_t* RxData) {
|
||||||
|
|
||||||
if(RxHeader.Identifier == 0x391) {
|
if(RxHeader.Identifier == 0x391) {
|
||||||
rx_unlock(RxData);
|
rx_unlock_key(RxData);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (RxHeader.Identifier == 0x395) {
|
if (RxHeader.Identifier == 0x395) {
|
||||||
rx_unlock(RxData);
|
rx_unlock_secure(RxData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -6,10 +6,10 @@ if __name__ == "__main__":
|
|||||||
ser = setup_connection()
|
ser = setup_connection()
|
||||||
# Create a message
|
# Create a message
|
||||||
request = UpdateDeviceSettings()
|
request = UpdateDeviceSettings()
|
||||||
request.device = 5
|
request.device = 0
|
||||||
request.type = Type.LIGHT
|
request.type = Type.COMMING_HOME
|
||||||
request.position.append(Position.RIGHT)
|
request.position.append(Position.LEFT)
|
||||||
request.position.append(Position.FLOOR)
|
request.position.append(Position.CENTER)
|
||||||
# Serialize the request to a bytearray
|
# Serialize the request to a bytearray
|
||||||
request_data = request.SerializeToString()
|
request_data = request.SerializeToString()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user