remove manual maping off obd shm
This commit is contained in:
parent
bba3956aff
commit
6f0d771a35
|
|
@ -29,6 +29,7 @@ TARGET_LINK_LIBRARIES(it2s-itss-facilities
|
||||||
-lit2s-asn-tpm
|
-lit2s-asn-tpm
|
||||||
-lit2s-asn-vcm
|
-lit2s-asn-vcm
|
||||||
-lit2s-tender
|
-lit2s-tender
|
||||||
|
-lit2s-obd
|
||||||
-lm
|
-lm
|
||||||
-lrt
|
-lrt
|
||||||
)
|
)
|
||||||
|
|
|
||||||
23
src/cam.c
23
src/cam.c
|
|
@ -22,7 +22,7 @@
|
||||||
#include <it2s-tender/recorder.h>
|
#include <it2s-tender/recorder.h>
|
||||||
#include <it2s-tender/packet.h>
|
#include <it2s-tender/packet.h>
|
||||||
|
|
||||||
#include <it2s-obd/shmem.h>
|
#include <it2s-obd.h>
|
||||||
|
|
||||||
#define LEAP_SECONDS 5
|
#define LEAP_SECONDS 5
|
||||||
|
|
||||||
|
|
@ -86,17 +86,13 @@ static int permissions_check(int cid, uint8_t* permissions, uint8_t permissions_
|
||||||
static int mk_cam(uint8_t *cam_oer, uint32_t *cam_len) {
|
static int mk_cam(uint8_t *cam_oer, uint32_t *cam_len) {
|
||||||
int rv = 0;
|
int rv = 0;
|
||||||
int shm_fd, shm_valid = 0;
|
int shm_fd, shm_valid = 0;
|
||||||
decoded_can_values_shm* shared_message;
|
it2s_obd_data* shared_message;
|
||||||
|
|
||||||
lightship_t* lightship = &facilities.lightship;
|
lightship_t* lightship = &facilities.lightship;
|
||||||
|
|
||||||
if (lightship->use_obd){
|
if (lightship->use_obd){
|
||||||
shm_fd = shm_open("it2s-bluetooth-decoded", O_RDONLY, 0666);
|
it2s_obd_data* shared_message = malloc(sizeof(it2s_obd_data));
|
||||||
if(shm_fd == -1)
|
it2s_obd_read(shared_message);
|
||||||
log_error("failed to open CAN shared memory\n");
|
|
||||||
shared_message = (decoded_can_values_shm *)mmap(0, sizeof(decoded_can_values_shm), PROT_READ, MAP_SHARED, shm_fd, 0);
|
|
||||||
if(shared_message == MAP_FAILED)
|
|
||||||
log_error("failed to map CAN shared memory\n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CAM_t *cam = calloc(1, sizeof(CAM_t));
|
CAM_t *cam = calloc(1, sizeof(CAM_t));
|
||||||
|
|
@ -344,11 +340,8 @@ static int mk_cam(uint8_t *cam_oer, uint32_t *cam_len) {
|
||||||
}
|
}
|
||||||
*cam_len = (enc.encoded + 7) / 8;
|
*cam_len = (enc.encoded + 7) / 8;
|
||||||
|
|
||||||
if(lightship->use_obd){
|
if (lightship->use_obd)
|
||||||
munmap(shared_message, sizeof(can_values_shm));
|
free(shared_message);
|
||||||
if(close(shm_fd) == -1)
|
|
||||||
log_error("failed to close CAN shared memory\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
ASN_STRUCT_FREE(asn_DEF_CAM, cam);
|
ASN_STRUCT_FREE(asn_DEF_CAM, cam);
|
||||||
|
|
@ -367,12 +360,12 @@ int lightship_init() {
|
||||||
lightship->pos_history = malloc(POS_HISTORY_MAX_LEN * sizeof(void*));
|
lightship->pos_history = malloc(POS_HISTORY_MAX_LEN * sizeof(void*));
|
||||||
|
|
||||||
int shm_fd;
|
int shm_fd;
|
||||||
|
shm_fd = shm_open("it2s-obd", O_RDONLY, 0666);
|
||||||
shm_fd = shm_open("it2s-bluetooth-decoded", O_RDONLY, 0666);
|
|
||||||
if(shm_fd == -1){
|
if(shm_fd == -1){
|
||||||
log_debug("obd shmem not found\n");
|
log_debug("obd shmem not found\n");
|
||||||
lightship->use_obd = 0;
|
lightship->use_obd = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
else{
|
else{
|
||||||
log_debug("obd shmem found\n");
|
log_debug("obd shmem found\n");
|
||||||
lightship->use_obd = 1;
|
lightship->use_obd = 1;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue