Fix OBU PZ saving
This commit is contained in:
parent
6a9f7a07bc
commit
a99a2e6dce
27
src/cam.c
27
src/cam.c
|
|
@ -280,7 +280,7 @@ cleanup:
|
|||
lightship_t* lightship_init() {
|
||||
lightship_t* lightship = (lightship_t*) calloc(1, sizeof(lightship_t));
|
||||
|
||||
lightship->pz = malloc(256 * sizeof(void*));
|
||||
lightship->pz = calloc(256 , sizeof(void*));
|
||||
pthread_mutex_init(&lightship->lock, NULL);
|
||||
|
||||
lightship->pos_history = malloc(POS_HISTORY_MAX_LEN * sizeof(void*));
|
||||
|
|
@ -508,7 +508,8 @@ enum CAM_CHECK_R check_cam(void* fc, BTPDataIndication_t *bdi, CAM_t* cam, it2s_
|
|||
if (cam->cam.camParameters.basicContainer.stationType == StationType_roadSideUnit &&
|
||||
cam->cam.camParameters.highFrequencyContainer.choice.rsuContainerHighFrequency.protectedCommunicationZonesRSU) {
|
||||
ProtectedCommunicationZonesRSU_t *pzs = cam->cam.camParameters.highFrequencyContainer.choice.rsuContainerHighFrequency.protectedCommunicationZonesRSU;
|
||||
if (pzs->list.count > 0 && pzs->list.count + lightship->pz_len < 256) {
|
||||
if (pzs->list.count > 0 && pzs->list.count + lightship->pz_len < 255) {
|
||||
|
||||
for (int k = 0; k < pzs->list.count; ++k) {
|
||||
|
||||
bool found = false;
|
||||
|
|
@ -521,23 +522,23 @@ enum CAM_CHECK_R check_cam(void* fc, BTPDataIndication_t *bdi, CAM_t* cam, it2s_
|
|||
}
|
||||
if (found) continue;
|
||||
|
||||
lightship->pz[k + lightship->pz_len] = calloc(1, sizeof(ProtectedCommunicationZone_t));
|
||||
lightship->pz[k + lightship->pz_len]->protectedZoneLatitude = pzs->list.array[k]->protectedZoneLatitude;
|
||||
lightship->pz[k + lightship->pz_len]->protectedZoneLongitude = pzs->list.array[k]->protectedZoneLongitude;
|
||||
lightship->pz[k + lightship->pz_len]->protectedZoneType = pzs->list.array[k]->protectedZoneType;
|
||||
lightship->pz[lightship->pz_len] = calloc(1, sizeof(ProtectedCommunicationZone_t));
|
||||
lightship->pz[lightship->pz_len]->protectedZoneLatitude = pzs->list.array[k]->protectedZoneLatitude;
|
||||
lightship->pz[lightship->pz_len]->protectedZoneLongitude = pzs->list.array[k]->protectedZoneLongitude;
|
||||
lightship->pz[lightship->pz_len]->protectedZoneType = pzs->list.array[k]->protectedZoneType;
|
||||
|
||||
if (pzs->list.array[k]->expiryTime) {
|
||||
lightship->pz[k + lightship->pz_len]->expiryTime->size = pzs->list.array[k]->expiryTime->size;
|
||||
lightship->pz[k + lightship->pz_len]->expiryTime->buf = malloc(pzs->list.array[k]->expiryTime->size);
|
||||
memcpy(lightship->pz[k + lightship->pz_len]->expiryTime->buf, pzs->list.array[k]->expiryTime->buf, pzs->list.array[k]->expiryTime->size);
|
||||
lightship->pz[lightship->pz_len]->expiryTime->size = pzs->list.array[k]->expiryTime->size;
|
||||
lightship->pz[lightship->pz_len]->expiryTime->buf = malloc(pzs->list.array[k]->expiryTime->size);
|
||||
memcpy(lightship->pz[lightship->pz_len]->expiryTime->buf, pzs->list.array[k]->expiryTime->buf, pzs->list.array[k]->expiryTime->size);
|
||||
}
|
||||
if (pzs->list.array[k]->protectedZoneID) {
|
||||
lightship->pz[k + lightship->pz_len]->protectedZoneID = malloc(8);
|
||||
*lightship->pz[k + lightship->pz_len]->protectedZoneID = *pzs->list.array[k]->protectedZoneID;
|
||||
lightship->pz[lightship->pz_len]->protectedZoneID = malloc(8);
|
||||
*lightship->pz[lightship->pz_len]->protectedZoneID = *pzs->list.array[k]->protectedZoneID;
|
||||
}
|
||||
if (pzs->list.array[k]->protectedZoneRadius) {
|
||||
lightship->pz[k + lightship->pz_len]->protectedZoneRadius = malloc(8);
|
||||
*lightship->pz[k + lightship->pz_len]->protectedZoneRadius = *pzs->list.array[k]->protectedZoneRadius;
|
||||
lightship->pz[lightship->pz_len]->protectedZoneRadius = malloc(8);
|
||||
*lightship->pz[lightship->pz_len]->protectedZoneRadius = *pzs->list.array[k]->protectedZoneRadius;
|
||||
}
|
||||
++lightship->pz_len;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue