CPM thread control
This commit is contained in:
parent
180fd4766b
commit
c369f434d3
67
src/cpm.c
67
src/cpm.c
|
|
@ -509,47 +509,50 @@ void dissemination_reset_timer(dissemination_t* dissemination){
|
|||
|
||||
|
||||
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
|
||||
/* 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
|
||||
int is_radar_connected_error;
|
||||
socklen_t len = sizeof(error);
|
||||
|
||||
|
||||
facilities_t *facilities = (facilities_t *) fc;
|
||||
BTPDataRequest_t *bdr = calloc(1, sizeof(BTPDataRequest_t));
|
||||
facilities_t *facilities = (facilities_t *) fc;
|
||||
BTPDataRequest_t *bdr = calloc(1, sizeof(BTPDataRequest_t));
|
||||
|
||||
/* Fill mandatory BTP Data Request parameters */
|
||||
//roadRotationSin = sin(((config->applications.its_center.rotation + 90.0) * PI) / 180);
|
||||
//roadRotationCos = cos(((config->applications.its_center.rotation + 90.0) * PI) / 180);
|
||||
|
||||
bdr->gnDestinationAddress.buf = malloc(6);
|
||||
bdr->gnDestinationAddress.size = 6;
|
||||
for(int i = 0; i < 6; i++)
|
||||
|
||||
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->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
|
||||
|
||||
bdr->destinationPort = Port_cpm; //CPM entity port for communication between Facilities and Transport
|
||||
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->destinationPort = Port_cpm; //CPM entity port for communication between Facilities and Transport
|
||||
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->data.buf = malloc(1500); // CPM Data to be sent to the Transport layer
|
||||
|
||||
if(facilities->use_security) {
|
||||
bdr->gnSecurityProfile = malloc(sizeof(long));
|
||||
*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
|
||||
struct timespec* systemtime;
|
||||
|
|
@ -559,23 +562,19 @@ void *cp_service(void *fc){
|
|||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
/* 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){
|
||||
usleep(1000*50);
|
||||
|
||||
|
||||
if(getsockopt(s_socket.i32_client, &) != 0)
|
||||
syslog_err("--------------------Radar not connected-------------------");
|
||||
|
||||
if (dissemination_check(facilities->dissemination) && facilities->dissemination->active){
|
||||
/* Receive Data from radar interface */
|
||||
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)
|
||||
|
||||
|
||||
if(i32_recv_bytes < 0){
|
||||
syslog_debug("No data received from radar ...");
|
||||
|
|
@ -606,7 +605,7 @@ void *cp_service(void *fc){
|
|||
pthread_cond_signal(&facilities->tx_queue->trigger);
|
||||
|
||||
|
||||
/* Reset Timer for dissemination control */
|
||||
/* Reset Timer for dissemination control */
|
||||
|
||||
dissemination_reset_timer(facilities->dissemination);
|
||||
|
||||
|
|
|
|||
|
|
@ -414,7 +414,8 @@ int main() {
|
|||
pthread_create(&facilities.infrastructure_service, NULL, infrastructure_service, (void*) &facilities);
|
||||
|
||||
// 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];
|
||||
syslog_info("[facilities] listening");
|
||||
|
|
@ -468,7 +469,8 @@ int main() {
|
|||
pthread_join(facilities.ca_service, NULL);
|
||||
pthread_join(facilities.den_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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue