more CLS device info
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
#include "firmware.pb.h"
|
||||
#include "cls_device.pb.h"
|
||||
#include "usb.pb.h"
|
||||
|
||||
#include "version_info.h"
|
||||
// Define thread flags
|
||||
#define FLAG_FDCAN_RX_FIFO0 (1<<0)
|
||||
#define FLAG_FDCAN_RX_FIFO1 (1<<1)
|
||||
@@ -133,22 +133,43 @@ extern uint8_t gCLS_DEVICE_ADDRESS;
|
||||
void DataClbk_cls_device_RequestList(void* msg, uint32_t length) {
|
||||
memset(&list,0,sizeof(list));
|
||||
// add yourself
|
||||
|
||||
CLS_Position_t position = CLS_BSP_GetPosition();
|
||||
CLS_Type_t type = CLS_BSP_GetDeviceType();
|
||||
uint32_t fw32 = (VERSION_INFO.major<<24) +(VERSION_INFO.minor<<16) + (VERSION_INFO.patch<<8) +VERSION_INFO.count ;
|
||||
uint16_t pos16 = (position.p1<< 4) + position.p0;
|
||||
uint16_t type16 = type;
|
||||
|
||||
list.devices[list.devices_count].available = true;
|
||||
list.devices[list.devices_count].canid = GENERATE_CLS_ADDRESS(CLS_CODE_STATUS, gCLS_DEVICE_ADDRESS, CLS_CH_STA_HEATBEAT);
|
||||
list.devices[list.devices_count].device = gCLS_DEVICE_ADDRESS;
|
||||
list.devices[list.devices_count].counter = (osKernelGetTickCount()/500)%256;
|
||||
list.devices[list.devices_count].type_position = (type16<<16) + pos16;
|
||||
list.devices[list.devices_count].fw_version = fw32;
|
||||
|
||||
list.devices_count++;
|
||||
|
||||
for (size_t i = 0; i < 16; i++)
|
||||
{
|
||||
uint16_t canid = (GENERATE_CLS_ADDRESS(CLS_CODE_STATUS, i, CLS_CH_STA_HEATBEAT));
|
||||
const CanDataMessage * msg =CanData_getDataMessage(canid);
|
||||
|
||||
if(msg) {
|
||||
if(msg->data_length > 0) {
|
||||
|
||||
CLS_HeatbeatData_t data = {0};
|
||||
memcpy(&data, msg->data, msg->data_length);
|
||||
|
||||
CLS_Position_t position = data.position;
|
||||
CLS_Type_t type = data.type;
|
||||
uint32_t fw32 = (data.firmware_version.major<<24) +(data.firmware_version.minor<<16) + (data.firmware_version.patch<<8) +data.firmware_version.count ;
|
||||
uint16_t pos16 = (position.p1<< 4) + position.p0;
|
||||
uint16_t type16 = type;
|
||||
|
||||
list.devices[list.devices_count].available = true;
|
||||
list.devices[list.devices_count].canid = canid;
|
||||
list.devices[list.devices_count].device = i;
|
||||
list.devices[list.devices_count].counter = msg->data[0];
|
||||
list.devices[list.devices_count].type_position = (type16<<16) + pos16;
|
||||
list.devices[list.devices_count].fw_version = fw32;
|
||||
list.devices_count++;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user