Fix CPM objID going oob
This commit is contained in:
parent
0fb45843d2
commit
258190395e
23
src/cpm.c
23
src/cpm.c
|
|
@ -318,7 +318,7 @@ void parse_can_data_tm(u_int32_t u32_can_id, int i32_can_len, u_int8_t* au8_can_
|
||||||
|
|
||||||
as_objects[u16_objectIndex].f_objectLength = (au8_can_data[6] >> 1) * 0.2f;
|
as_objects[u16_objectIndex].f_objectLength = (au8_can_data[6] >> 1) * 0.2f;
|
||||||
|
|
||||||
as_objects[u16_objectIndex].u8_objectID = au8_can_data[7];
|
as_objects[u16_objectIndex].u8_objectID = au8_can_data[7] & 0x7F;
|
||||||
} else if (s_objectControl.u8_objectData0Format == 4) {
|
} else if (s_objectControl.u8_objectData0Format == 4) {
|
||||||
as_objects[u16_objectIndex].f_xPoint = (au8_can_data[1] & 0x3F) << 7;
|
as_objects[u16_objectIndex].f_xPoint = (au8_can_data[1] & 0x3F) << 7;
|
||||||
as_objects[u16_objectIndex].f_xPoint += au8_can_data[0] >> 1;
|
as_objects[u16_objectIndex].f_xPoint += au8_can_data[0] >> 1;
|
||||||
|
|
@ -500,12 +500,12 @@ static void set_values(int i, int j, uint64_t timestamp, CPM_t* cpm_tx, long his
|
||||||
cpm_tx->cpm.cpmParameters.perceivedObjectContainer->list.array[j]->objectRefPoint = ObjectRefPoint_bottomMid;
|
cpm_tx->cpm.cpmParameters.perceivedObjectContainer->list.array[j]->objectRefPoint = ObjectRefPoint_bottomMid;
|
||||||
|
|
||||||
/* Fill History values */
|
/* Fill History values */
|
||||||
valid_array[(long)as_objects[i].u8_objectID] = 1; // Comparation Array
|
valid_array[as_objects[i].u8_objectID] = 1; // Comparation Array
|
||||||
history_list[(long)as_objects[i].u8_objectID][0] = (long)as_objects[i].f_xPoint * 100; // xPoint (Distance)
|
history_list[as_objects[i].u8_objectID][0] = (long)as_objects[i].f_xPoint * 100; // xPoint (Distance)
|
||||||
history_list[(long)as_objects[i].u8_objectID][1] = (long)as_objects[i].f_yPoint * 100; // yPoint (Distance)
|
history_list[as_objects[i].u8_objectID][1] = (long)as_objects[i].f_yPoint * 100; // yPoint (Distance)
|
||||||
history_list[(long)as_objects[i].u8_objectID][2] = (long)as_objects[i].f_xSpeed * 100; // xSpeed (Speed)
|
history_list[as_objects[i].u8_objectID][2] = (long)as_objects[i].f_xSpeed * 100; // xSpeed (Speed)
|
||||||
history_list[(long)as_objects[i].u8_objectID][3] = (long)as_objects[i].f_ySpeed * 100; // ySpeed (Speed)
|
history_list[as_objects[i].u8_objectID][3] = (long)as_objects[i].f_ySpeed * 100; // ySpeed (Speed)
|
||||||
history_timestamp[(long)as_objects[i].u8_objectID] = timestamp; // Time stamp of detected object
|
history_timestamp[as_objects[i].u8_objectID] = timestamp; // Time stamp of detected object
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -578,8 +578,7 @@ static int mk_cpm(facilities_t* facilities, uint8_t *bdr_oer, uint32_t *bdr_len,
|
||||||
memset(valid_array, 0, NOF_OBJECTS * sizeof(int));
|
memset(valid_array, 0, NOF_OBJECTS * sizeof(int));
|
||||||
|
|
||||||
for(int i = 0; i < cpm_tx->cpm.cpmParameters.perceivedObjectContainer->list.count;i++){
|
for(int i = 0; i < cpm_tx->cpm.cpmParameters.perceivedObjectContainer->list.count;i++){
|
||||||
syslog_err("oID = %d", as_objects[i].u8_objectID);
|
if(temp[as_objects[i].u8_objectID] == 0 ){ // The object is going to be added without comparison (It is a new object) (valid_array[id] = 0)
|
||||||
if(temp[(long)as_objects[i].u8_objectID] == 0 ){ // The object is going to be added without comparison (It is a new object) (valid_array[id] = 0)
|
|
||||||
set_values(i,j,generationDeltaTime,cpm_tx,history_list,valid_array,history_timestamp);
|
set_values(i,j,generationDeltaTime,cpm_tx,history_list,valid_array,history_timestamp);
|
||||||
j++;
|
j++;
|
||||||
|
|
||||||
|
|
@ -652,9 +651,9 @@ void *cp_service(void *fc){
|
||||||
u_int8_t au8_readBuffer[READ_BUFFER_SIZE];
|
u_int8_t au8_readBuffer[READ_BUFFER_SIZE];
|
||||||
u_int8_t au8_readTcp[READ_BUFFER_SIZE];
|
u_int8_t au8_readTcp[READ_BUFFER_SIZE];
|
||||||
bool is_radar_connected;
|
bool is_radar_connected;
|
||||||
static long history_list[NOF_OBJECTS][4];
|
long history_list[NOF_OBJECTS][4];
|
||||||
static int valid_array[NOF_OBJECTS];
|
int valid_array[NOF_OBJECTS];
|
||||||
static uint64_t history_timestamp[NOF_OBJECTS];
|
uint64_t history_timestamp[NOF_OBJECTS];
|
||||||
|
|
||||||
facilities_t *facilities = (facilities_t *) fc;
|
facilities_t *facilities = (facilities_t *) fc;
|
||||||
memset(history_list, 0, sizeof(history_list));
|
memset(history_list, 0, sizeof(history_list));
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue