CPM thread control
This commit is contained in:
parent
180fd4766b
commit
c369f434d3
65
src/cpm.c
65
src/cpm.c
|
|
@ -509,31 +509,44 @@ void dissemination_reset_timer(dissemination_t* dissemination){
|
||||||
|
|
||||||
|
|
||||||
void *cp_service(void *fc){
|
void *cp_service(void *fc){
|
||||||
//roadRotationSin = sin(((config->applications.its_center.rotation + 90.0) * PI) / 180);
|
|
||||||
//roadRotationCos = cos(((config->applications.its_center.rotation + 90.0) * PI) / 180);
|
|
||||||
|
|
||||||
roadRotationSin = 0.8660; // Default values for A3 Configuration
|
|
||||||
roadRotationCos = -0.5000; // Default values for A3 configuration
|
|
||||||
|
|
||||||
|
|
||||||
facilities_t *facilities = (facilities_t *) fc;
|
/* Variables */
|
||||||
BTPDataRequest_t *bdr = calloc(1, sizeof(BTPDataRequest_t));
|
int i32_recv_bytes;
|
||||||
|
u_int8_t au8_readBuffer[READ_BUFFER_SIZE];
|
||||||
|
//void* message_data = malloc(1500);
|
||||||
|
uint8_t bdr_oer[2048];
|
||||||
|
bdr_oer[0] = 4; //Facilities
|
||||||
|
int is_radar_connected_error;
|
||||||
|
socklen_t len = sizeof(error);
|
||||||
|
|
||||||
/* Fill mandatory BTP Data Request parameters */
|
|
||||||
|
|
||||||
bdr->gnDestinationAddress.buf = malloc(6);
|
facilities_t *facilities = (facilities_t *) fc;
|
||||||
bdr->gnDestinationAddress.size = 6;
|
BTPDataRequest_t *bdr = calloc(1, sizeof(BTPDataRequest_t));
|
||||||
for(int i = 0; i < 6; i++)
|
|
||||||
|
//roadRotationSin = sin(((config->applications.its_center.rotation + 90.0) * PI) / 180);
|
||||||
|
//roadRotationCos = cos(((config->applications.its_center.rotation + 90.0) * PI) / 180);
|
||||||
|
|
||||||
|
|
||||||
|
roadRotationSin = 0.8660; // Default values for A3 Configuration
|
||||||
|
roadRotationCos = -0.5000; // Default values for A3 configuration
|
||||||
|
|
||||||
|
|
||||||
|
/* Fill mandatory BTP Data Request parameters */
|
||||||
|
|
||||||
|
bdr->gnDestinationAddress.buf = malloc(6);
|
||||||
|
bdr->gnDestinationAddress.size = 6;
|
||||||
|
for(int i = 0; i < 6; i++)
|
||||||
bdr->gnDestinationAddress.buf[i] = 0xff; //Broadcast addr
|
bdr->gnDestinationAddress.buf[i] = 0xff; //Broadcast addr
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bdr->btpType = BTPType_btpB; //BTP Type B is for non-interactive packet transport | BTP Type A is for interactive packet transport
|
bdr->btpType = BTPType_btpB; //BTP Type B is for non-interactive packet transport | BTP Type A is for interactive packet transport
|
||||||
//The former doesn't have a source port and the latter have
|
//The former doesn't have a source port and the latter have
|
||||||
|
|
||||||
bdr->destinationPort = Port_cpm; //CPM entity port for communication between Facilities and Transport
|
bdr->destinationPort = Port_cpm; //CPM entity port for communication between Facilities and Transport
|
||||||
bdr->gnPacketTransportType = PacketTransportType_shb; //shb = Single Hop Broadcast packet
|
bdr->gnPacketTransportType = PacketTransportType_shb; //shb = Single Hop Broadcast packet
|
||||||
bdr->gnTrafficClass = 2; //Identifier assigned to a GeoNetworking packet that expresses its requirements on data transport (WHY IS IT 2?)
|
bdr->gnTrafficClass = 2; //Identifier assigned to a GeoNetworking packet that expresses its requirements on data transport (WHY IS IT 2?)
|
||||||
bdr->data.buf = malloc(1500); // CPM Data to be sent to the Transport layer
|
bdr->data.buf = malloc(1500); // CPM Data to be sent to the Transport layer
|
||||||
|
|
||||||
if(facilities->use_security) {
|
if(facilities->use_security) {
|
||||||
|
|
@ -541,16 +554,6 @@ void *cp_service(void *fc){
|
||||||
*bdr->gnSecurityProfile = 1;
|
*bdr->gnSecurityProfile = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Not needed
|
|
||||||
read_config("/etc/it2s/itss.toml"); // To get the parameters of the broker
|
|
||||||
signal(SIGINT, interruption_handler); // In case Ctrl+C is sent to the process interruption_handler will be executed
|
|
||||||
setup_mec_server_connection();
|
|
||||||
init_tiles();
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
interface_connection(RADAR_IP,RADAR_PORT); // Create Radar listening socket
|
interface_connection(RADAR_IP,RADAR_PORT); // Create Radar listening socket
|
||||||
struct timespec* systemtime;
|
struct timespec* systemtime;
|
||||||
systemtime = (struct timespec*)malloc(sizeof(struct timespec));
|
systemtime = (struct timespec*)malloc(sizeof(struct timespec));
|
||||||
|
|
@ -560,23 +563,19 @@ void *cp_service(void *fc){
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Variables */
|
|
||||||
int i32_recv_bytes;
|
|
||||||
u_int8_t au8_readBuffer[READ_BUFFER_SIZE];
|
|
||||||
//void* message_data = malloc(1500);
|
|
||||||
uint8_t bdr_oer[2048];
|
|
||||||
bdr_oer[0] = 4; //Facilities
|
|
||||||
|
|
||||||
|
|
||||||
while(!facilities->exit){
|
while(!facilities->exit){
|
||||||
usleep(1000*50);
|
usleep(1000*50);
|
||||||
|
|
||||||
|
if(getsockopt(s_socket.i32_client, &) != 0)
|
||||||
|
syslog_err("--------------------Radar not connected-------------------");
|
||||||
|
|
||||||
if (dissemination_check(facilities->dissemination) && facilities->dissemination->active){
|
if (dissemination_check(facilities->dissemination) && facilities->dissemination->active){
|
||||||
/* Receive Data from radar interface */
|
/* Receive Data from radar interface */
|
||||||
CPM_t* cpm_tx = calloc(1, sizeof(CPM_t));
|
CPM_t* cpm_tx = calloc(1, sizeof(CPM_t));
|
||||||
i32_recv_bytes = recv(s_socket.i32_client, &au8_readBuffer, READ_BUFFER_SIZE, 0); //recv(socket,buffer,size,flags)
|
i32_recv_bytes = recv(s_socket.i32_client, &au8_readBuffer, READ_BUFFER_SIZE, 0); //recv(socket,buffer,size,flags)
|
||||||
|
|
||||||
|
|
||||||
if(i32_recv_bytes < 0){
|
if(i32_recv_bytes < 0){
|
||||||
syslog_debug("No data received from radar ...");
|
syslog_debug("No data received from radar ...");
|
||||||
break;
|
break;
|
||||||
|
|
@ -606,7 +605,7 @@ void *cp_service(void *fc){
|
||||||
pthread_cond_signal(&facilities->tx_queue->trigger);
|
pthread_cond_signal(&facilities->tx_queue->trigger);
|
||||||
|
|
||||||
|
|
||||||
/* Reset Timer for dissemination control */
|
/* Reset Timer for dissemination control */
|
||||||
|
|
||||||
dissemination_reset_timer(facilities->dissemination);
|
dissemination_reset_timer(facilities->dissemination);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -414,7 +414,8 @@ int main() {
|
||||||
pthread_create(&facilities.infrastructure_service, NULL, infrastructure_service, (void*) &facilities);
|
pthread_create(&facilities.infrastructure_service, NULL, infrastructure_service, (void*) &facilities);
|
||||||
|
|
||||||
// CPM
|
// CPM
|
||||||
pthread_create(&facilities.cp_service, NULL, cp_service, (void*) &facilities);
|
if(facilities.dissemination->active)
|
||||||
|
pthread_create(&facilities.cp_service, NULL, cp_service, (void*) &facilities);
|
||||||
|
|
||||||
uint8_t buffer[PACKET_MAX_LEN];
|
uint8_t buffer[PACKET_MAX_LEN];
|
||||||
syslog_info("[facilities] listening");
|
syslog_info("[facilities] listening");
|
||||||
|
|
@ -468,7 +469,8 @@ int main() {
|
||||||
pthread_join(facilities.ca_service, NULL);
|
pthread_join(facilities.ca_service, NULL);
|
||||||
pthread_join(facilities.den_service, NULL);
|
pthread_join(facilities.den_service, NULL);
|
||||||
pthread_join(facilities.infrastructure_service, NULL);
|
pthread_join(facilities.infrastructure_service, NULL);
|
||||||
pthread_join(facilities.cp_service, NULL);
|
if(facilities.dissemination->active)
|
||||||
|
pthread_join(facilities.cp_service, NULL);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue