Merge remote-tracking branch 'refs/remotes/origin/master'
This commit is contained in:
commit
73349e61d7
|
|
@ -8,7 +8,7 @@ stages:
|
||||||
|
|
||||||
.dependencies:
|
.dependencies:
|
||||||
before_script:
|
before_script:
|
||||||
- pacman -Sy zeromq it2s-config-git it2s-asn-git it2s-tender-git it2s-gps-git it2s-obd-git --overwrite=* --noconfirm
|
- pacman -Sy zeromq it2s-config-git it2s-asn-git it2s-tender-git mariadb it2s-gps-git it2s-obd-git --overwrite=* --noconfirm
|
||||||
|
|
||||||
build:
|
build:
|
||||||
stage: build
|
stage: build
|
||||||
|
|
|
||||||
11
src/cam.c
11
src/cam.c
|
|
@ -18,6 +18,7 @@
|
||||||
|
|
||||||
#include <it2s-tender/space.h>
|
#include <it2s-tender/space.h>
|
||||||
#include <it2s-tender/time.h>
|
#include <it2s-tender/time.h>
|
||||||
|
#include <it2s-tender/database.h>
|
||||||
|
|
||||||
#include <it2s-obd/shmem.h>
|
#include <it2s-obd/shmem.h>
|
||||||
|
|
||||||
|
|
@ -145,7 +146,7 @@ static int mk_cam(facilities_t* facilities, uint8_t *cam_oer, uint32_t *cam_len)
|
||||||
// bvc_hf_speed.speedConfidence = 1;
|
// bvc_hf_speed.speedConfidence = 1;
|
||||||
|
|
||||||
// Steering Wheel Angle
|
// Steering Wheel Angle
|
||||||
if(shared_message->w_angle_value != 1683){
|
if(shared_message->w_angle_value != 1683 && (now/1000 - shared_message->w_angle_timestamp) <= 1){
|
||||||
bvc_hf->steeringWheelAngle = calloc(1, sizeof(SteeringWheelAngle_t));
|
bvc_hf->steeringWheelAngle = calloc(1, sizeof(SteeringWheelAngle_t));
|
||||||
bvc_hf->steeringWheelAngle->steeringWheelAngleValue = shared_message->w_angle_value;
|
bvc_hf->steeringWheelAngle->steeringWheelAngleValue = shared_message->w_angle_value;
|
||||||
bvc_hf->steeringWheelAngle->steeringWheelAngleConfidence = 1;
|
bvc_hf->steeringWheelAngle->steeringWheelAngleConfidence = 1;
|
||||||
|
|
@ -153,7 +154,7 @@ static int mk_cam(facilities_t* facilities, uint8_t *cam_oer, uint32_t *cam_len)
|
||||||
// still missing temperature; where is de_temperature ?
|
// still missing temperature; where is de_temperature ?
|
||||||
|
|
||||||
// Acceleration Control (encondig failure)
|
// Acceleration Control (encondig failure)
|
||||||
if(shared_message->b_pedal_value != 1683 && shared_message->s_pedal_value != 1683){
|
if(shared_message->b_pedal_value != 1683 && shared_message->s_pedal_value != 1683 && (now/1000 - shared_message->b_pedal_timestamp) <= 1 && (now - shared_message->s_pedal_timestamp) <= 1){
|
||||||
if(shared_message->b_pedal_value)
|
if(shared_message->b_pedal_value)
|
||||||
ac = ac | 0x80;
|
ac = ac | 0x80;
|
||||||
if(shared_message->s_pedal_value)
|
if(shared_message->s_pedal_value)
|
||||||
|
|
@ -248,7 +249,7 @@ static int mk_cam(facilities_t* facilities, uint8_t *cam_oer, uint32_t *cam_len)
|
||||||
uint8_t el = 0x00;
|
uint8_t el = 0x00;
|
||||||
|
|
||||||
// Exterior Lights
|
// Exterior Lights
|
||||||
if(shared_message->lights_value != 1683){
|
if(shared_message->lights_value != 1683 && (now/1000 - shared_message->lights_timestamp) <= 1){
|
||||||
if(shared_message->lights_value)
|
if(shared_message->lights_value)
|
||||||
el = el | 0x80;
|
el = el | 0x80;
|
||||||
bvc_lf->exteriorLights.buf = malloc(sizeof(uint8_t));
|
bvc_lf->exteriorLights.buf = malloc(sizeof(uint8_t));
|
||||||
|
|
@ -760,6 +761,10 @@ void *ca_service(void *fc) {
|
||||||
memcpy(fmi->data.buf, bpr->data.buf, bpr->data.size);
|
memcpy(fmi->data.buf, bpr->data.buf, bpr->data.size);
|
||||||
fmi->data.size = bpr->data.size;
|
fmi->data.size = bpr->data.size;
|
||||||
|
|
||||||
|
if (facilities->logging) {
|
||||||
|
it2s_tender_db_add(&facilities->db, &facilities->epv, true, ItsPduHeader__messageID_cam, bpr->data.buf, bpr->data.size);
|
||||||
|
}
|
||||||
|
|
||||||
// Check if inside PZ
|
// Check if inside PZ
|
||||||
bpr->gn.communicationProfile = 0;
|
bpr->gn.communicationProfile = 0;
|
||||||
if (facilities->station_type != 15 && check_pz(facilities->lightship, &facilities->epv)) bpr->gn.communicationProfile = 1;
|
if (facilities->station_type != 15 && check_pz(facilities->lightship, &facilities->epv)) bpr->gn.communicationProfile = 1;
|
||||||
|
|
|
||||||
|
|
@ -193,6 +193,8 @@ int facilities_config(void* facilities_s) {
|
||||||
facilities->station_type = 5;
|
facilities->station_type = 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
facilities->logging = config->general.logging;
|
||||||
|
|
||||||
facilities->use_security = config->security.use_security;
|
facilities->use_security = config->security.use_security;
|
||||||
|
|
||||||
pthread_mutex_init(&facilities->id.lock, NULL);
|
pthread_mutex_init(&facilities->id.lock, NULL);
|
||||||
|
|
|
||||||
|
|
@ -722,6 +722,10 @@ void *cp_service(void *fc){
|
||||||
/* CPM build and encoding to BDR and FDI */
|
/* CPM build and encoding to BDR and FDI */
|
||||||
if(mk_cpm(facilities, bpr->data.buf, (uint32_t *) &bpr->data.size, fmi->data.buf, (uint32_t *) &fmi->data.size, history_list, valid_array, history_timestamp) == 1)
|
if(mk_cpm(facilities, bpr->data.buf, (uint32_t *) &bpr->data.size, fmi->data.buf, (uint32_t *) &fmi->data.size, history_list, valid_array, history_timestamp) == 1)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
if (facilities->logging) {
|
||||||
|
it2s_tender_db_add(&facilities->db, &facilities->epv, true, 14, bpr->data.buf, bpr->data.size);
|
||||||
|
}
|
||||||
|
|
||||||
/* Encode TransportRequest */
|
/* Encode TransportRequest */
|
||||||
asn_enc_rval_t enc_tdr = oer_encode_to_buffer(&asn_DEF_TransportRequest, NULL, tr, tr_oer+1, 2047);
|
asn_enc_rval_t enc_tdr = oer_encode_to_buffer(&asn_DEF_TransportRequest, NULL, tr, tr_oer+1, 2047);
|
||||||
|
|
|
||||||
|
|
@ -79,6 +79,7 @@ static int transport_indication(facilities_t *facilities, void* responder, void*
|
||||||
|
|
||||||
asn_TYPE_descriptor_t *its_msg_descriptor = NULL;
|
asn_TYPE_descriptor_t *its_msg_descriptor = NULL;
|
||||||
void *its_msg = NULL;
|
void *its_msg = NULL;
|
||||||
|
int its_msg_type = 0;
|
||||||
|
|
||||||
switch (tpi->present) {
|
switch (tpi->present) {
|
||||||
case TransportPacketIndication_PR_btp:
|
case TransportPacketIndication_PR_btp:
|
||||||
|
|
@ -89,42 +90,49 @@ static int transport_indication(facilities_t *facilities, void* responder, void*
|
||||||
case Port_cam:
|
case Port_cam:
|
||||||
its_msg_descriptor = &asn_DEF_CAM;
|
its_msg_descriptor = &asn_DEF_CAM;
|
||||||
its_msg = calloc(1, sizeof(CAM_t));
|
its_msg = calloc(1, sizeof(CAM_t));
|
||||||
|
its_msg_type = ItsPduHeader__messageID_cam;
|
||||||
handled_msg = true;
|
handled_msg = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Port_denm:
|
case Port_denm:
|
||||||
its_msg_descriptor = &asn_DEF_DENM;
|
its_msg_descriptor = &asn_DEF_DENM;
|
||||||
its_msg = calloc(1, sizeof(DENM_t));
|
its_msg = calloc(1, sizeof(DENM_t));
|
||||||
|
its_msg_type = ItsPduHeader__messageID_denm;
|
||||||
handled_msg = true;
|
handled_msg = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Port_ivim:
|
case Port_ivim:
|
||||||
its_msg_descriptor = &asn_DEF_IVIM;
|
its_msg_descriptor = &asn_DEF_IVIM;
|
||||||
its_msg = calloc(1, sizeof(IVIM_t));
|
its_msg = calloc(1, sizeof(IVIM_t));
|
||||||
|
its_msg_type = ItsPduHeader__messageID_ivim;
|
||||||
handled_msg = true;
|
handled_msg = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Port_cpm:
|
case Port_cpm:
|
||||||
its_msg_descriptor = &asn_DEF_CPM;
|
its_msg_descriptor = &asn_DEF_CPM;
|
||||||
its_msg = calloc(1, sizeof(CPM_t));
|
its_msg = calloc(1, sizeof(CPM_t));
|
||||||
|
its_msg_type = 14;
|
||||||
handled_msg = true;
|
handled_msg = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Port_saem:
|
case Port_saem:
|
||||||
its_msg_descriptor = &asn_DEF_SAEM;
|
its_msg_descriptor = &asn_DEF_SAEM;
|
||||||
its_msg = calloc(1, sizeof(SAEM_t));
|
its_msg = calloc(1, sizeof(SAEM_t));
|
||||||
|
its_msg_type = ItsPduHeader__messageID_saem;
|
||||||
handled_msg = true;
|
handled_msg = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 7011: /* tolling */
|
case 7011: /* tolling */
|
||||||
its_msg_descriptor = &asn_DEF_TPM;
|
its_msg_descriptor = &asn_DEF_TPM;
|
||||||
its_msg = calloc(1, sizeof(TPM_t));
|
its_msg = calloc(1, sizeof(TPM_t));
|
||||||
|
its_msg_type = 117;
|
||||||
handled_msg = true;
|
handled_msg = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2043: /* maneuvers */
|
case 2043: /* maneuvers */
|
||||||
its_msg_descriptor = &asn_DEF_PCM;
|
its_msg_descriptor = &asn_DEF_PCM;
|
||||||
its_msg = calloc(1, sizeof(PCM_t));
|
its_msg = calloc(1, sizeof(PCM_t));
|
||||||
|
its_msg_type = 43;
|
||||||
handled_msg = true;
|
handled_msg = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
@ -140,6 +148,10 @@ static int transport_indication(facilities_t *facilities, void* responder, void*
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (facilities->logging) {
|
||||||
|
it2s_tender_db_add(&facilities->db, &facilities->epv, false, its_msg_type, tpi->choice.btp.data.buf, tpi->choice.btp.data.size);
|
||||||
|
}
|
||||||
|
|
||||||
// Get permisisons
|
// Get permisisons
|
||||||
uint8_t* ssp = NULL;
|
uint8_t* ssp = NULL;
|
||||||
uint16_t ssp_len;
|
uint16_t ssp_len;
|
||||||
|
|
@ -708,10 +720,17 @@ int main() {
|
||||||
// Tolling
|
// Tolling
|
||||||
tolling_init(&facilities.tolling, facilities.zmq.ctx, facilities.zmq.security_address);
|
tolling_init(&facilities.tolling, facilities.zmq.ctx, facilities.zmq.security_address);
|
||||||
|
|
||||||
// DC
|
// PC
|
||||||
if (facilities.coordination.active)
|
if (facilities.coordination.active)
|
||||||
pthread_create(&facilities.pc_service, NULL, pc_service, (void*) &facilities);
|
pthread_create(&facilities.pc_service, NULL, pc_service, (void*) &facilities);
|
||||||
|
|
||||||
|
if (facilities.logging) {
|
||||||
|
if (it2s_tender_db_init(&facilities.db, "facilities", facilities.id.station_id)) {
|
||||||
|
syslog_err("[facilities] failed to initialize the database -> turning off logging");
|
||||||
|
facilities.logging = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void* security_socket = zmq_socket(facilities.zmq.ctx, ZMQ_REQ);
|
void* security_socket = zmq_socket(facilities.zmq.ctx, ZMQ_REQ);
|
||||||
int wait_ms = 1000;
|
int wait_ms = 1000;
|
||||||
zmq_setsockopt(security_socket, ZMQ_RCVTIMEO, &wait_ms, sizeof(int));
|
zmq_setsockopt(security_socket, ZMQ_RCVTIMEO, &wait_ms, sizeof(int));
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@
|
||||||
|
|
||||||
#include <it2s-tender/epv.h>
|
#include <it2s-tender/epv.h>
|
||||||
#include <it2s-tender/syslog.h>
|
#include <it2s-tender/syslog.h>
|
||||||
|
#include <it2s-tender/database.h>
|
||||||
|
|
||||||
enum ID_CHANGE_STAGE {
|
enum ID_CHANGE_STAGE {
|
||||||
ID_CHANGE_INACTIVE,
|
ID_CHANGE_INACTIVE,
|
||||||
|
|
@ -69,6 +70,10 @@ typedef struct facilities {
|
||||||
// PC
|
// PC
|
||||||
coordination_s coordination;
|
coordination_s coordination;
|
||||||
|
|
||||||
|
// Logging
|
||||||
|
bool logging;
|
||||||
|
it2s_tender_database_s db;
|
||||||
|
|
||||||
int station_type;
|
int station_type;
|
||||||
bool use_security;
|
bool use_security;
|
||||||
bool replay;
|
bool replay;
|
||||||
|
|
|
||||||
|
|
@ -320,6 +320,11 @@ void *sa_service(void *fc) {
|
||||||
if (bulletin->to_provide_len && sleep_ms*mk_saem_n_sleep >= 1000) {
|
if (bulletin->to_provide_len && sleep_ms*mk_saem_n_sleep >= 1000) {
|
||||||
rv = mk_saem(facilities, bpr->data.buf, (uint32_t *) &bpr->data.size);
|
rv = mk_saem(facilities, bpr->data.buf, (uint32_t *) &bpr->data.size);
|
||||||
if (!rv) {
|
if (!rv) {
|
||||||
|
|
||||||
|
if (facilities->logging) {
|
||||||
|
it2s_tender_db_add(&facilities->db, &facilities->epv, true, messageID_saem, bpr->data.buf, bpr->data.size);
|
||||||
|
}
|
||||||
|
|
||||||
asn_enc_rval_t enc = oer_encode_to_buffer(&asn_DEF_TransportRequest, NULL, tr, tr_oer+1, 1023);
|
asn_enc_rval_t enc = oer_encode_to_buffer(&asn_DEF_TransportRequest, NULL, tr, tr_oer+1, 1023);
|
||||||
if (enc.encoded == -1) {
|
if (enc.encoded == -1) {
|
||||||
syslog_err("[facilities] encoding TR for SAEM failed");
|
syslog_err("[facilities] encoding TR for SAEM failed");
|
||||||
|
|
|
||||||
|
|
@ -155,6 +155,10 @@ int tpm_pay(void* fc, uint8_t* neighbour) {
|
||||||
bpr->gn.trafficClass = 2;
|
bpr->gn.trafficClass = 2;
|
||||||
bpr->gn.packetTransportType = PacketTransportType_shb;
|
bpr->gn.packetTransportType = PacketTransportType_shb;
|
||||||
|
|
||||||
|
if (facilities->logging) {
|
||||||
|
it2s_tender_db_add(&facilities->db, &facilities->epv, true, 117, bpr->data.buf, bpr->data.size);
|
||||||
|
}
|
||||||
|
|
||||||
// encode TR
|
// encode TR
|
||||||
buf[0] = 4;
|
buf[0] = 4;
|
||||||
enc = oer_encode_to_buffer(&asn_DEF_TransportRequest, NULL, tr, buf+1, buf_len-1);
|
enc = oer_encode_to_buffer(&asn_DEF_TransportRequest, NULL, tr, buf+1, buf_len-1);
|
||||||
|
|
@ -319,6 +323,7 @@ static void rsu_handle_recv(facilities_t* facilities, TPM_t* tpm_rx, uint8_t* ne
|
||||||
}
|
}
|
||||||
size_t tpm_uper_len = (enc.encoded + 7) / 8;
|
size_t tpm_uper_len = (enc.encoded + 7) / 8;
|
||||||
|
|
||||||
|
|
||||||
// [transport] request (TR)
|
// [transport] request (TR)
|
||||||
tr = calloc(1, sizeof(TransportRequest_t));
|
tr = calloc(1, sizeof(TransportRequest_t));
|
||||||
tr->present = TransportRequest_PR_packet;
|
tr->present = TransportRequest_PR_packet;
|
||||||
|
|
@ -349,6 +354,10 @@ static void rsu_handle_recv(facilities_t* facilities, TPM_t* tpm_rx, uint8_t* ne
|
||||||
memcpy(bpr->gn.securityNeighbour->buf, neighbour, 8);
|
memcpy(bpr->gn.securityNeighbour->buf, neighbour, 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (facilities->logging) {
|
||||||
|
it2s_tender_db_add(&facilities->db, &facilities->epv, true, 117, bpr->data.buf, bpr->data.size);
|
||||||
|
}
|
||||||
|
|
||||||
// encode TR
|
// encode TR
|
||||||
buf[0] = 4;
|
buf[0] = 4;
|
||||||
enc = oer_encode_to_buffer(&asn_DEF_TransportRequest, NULL, tr, buf+1, buf_len-1);
|
enc = oer_encode_to_buffer(&asn_DEF_TransportRequest, NULL, tr, buf+1, buf_len-1);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue