From ae9194665e28194c03300caf125cc952136920fa Mon Sep 17 00:00:00 2001 From: Marco Date: Fri, 21 May 2021 14:50:19 +0100 Subject: [PATCH] Remove unnecessary variables and structures --- src/cpm.c | 2 +- src/cpm.h | 81 +++++++++++++++++++++---------------------------------- 2 files changed, 32 insertions(+), 51 deletions(-) diff --git a/src/cpm.c b/src/cpm.c index 77a09ba..12f09f1 100644 --- a/src/cpm.c +++ b/src/cpm.c @@ -371,7 +371,7 @@ void mk_cpm(facilities_t* facilities,CPM_t* cpm_tx, struct timespec* systemtime) cpm_tx->header.protocolVersion = PROTOCOL_VERSION; cpm_tx->header.messageID = MESSAGE_ID; - cpm_tx->header.stationID = STATION_ID; + cpm_tx->header.stationID = facilities->id.value; uint64_t generationDeltaTime = it2s_tender_get_clock(&facilities->epv) % 65536; // generationDeltaTime = TimestampIts mod 65 536 diff --git a/src/cpm.h b/src/cpm.h index 9a3e831..6fc5f0d 100644 --- a/src/cpm.h +++ b/src/cpm.h @@ -9,24 +9,17 @@ #include #include #include +#include +#include -#define LEAP_SECONDS 5 #define READ_BUFFER_SIZE 1024 // Buffer for Serial and Ethernet read function (Used in cp_service) -#define STATION_ID 10 +#define NOF_OBJECTS 127 // Number of Object UMRR-0C +#define ROAD_ANGLE 120 #define MESSAGE_ID 14 #define PROTOCOL_VERSION 1 -#define CAN_BUFFER_SIZE 24 // Send cmd Buffer -#define CAN_SMS_BUFFER_SIZE 25 // Send cmd Buffer for sms transport protocol -#define SERIAL_PORT_BUFFER 13 // string buffer serial interface -#define BAUDRATE B115200 // default Baudrate -#define CRC16_LENGTH 2 -#define CRC16_START_VALUE 0xFFFF // Start value CRC16 CCITT -#define NOF_OBJECTS 127 // Number of Object UMRR-0C -#define ROAD_ANGLE 120 - -#define RADAR_IP "11.11.11.13" // ITS-S interface connected to the radar -#define RADAR_PORT "55555" // Destination port from the radar +#define RADAR_IP "11.11.11.13" // ITS-S interface connected to the radar +#define RADAR_PORT "55555" // Destination port from the radar /* Structures */ @@ -35,7 +28,7 @@ typedef struct { int i32_socket; // Socket descriptor server int i32_client; // Socket descriptor UMRR-0C - int i32_port; // listen on Port + int i32_port; // Listen on Port bool b_moxa; struct sockaddr_in s_server; struct sockaddr_in s_client; @@ -43,10 +36,10 @@ typedef struct typedef struct { - int i32_fdSerial; //Serial Port descriptor - char c_portNumber; - struct termios s_config; -} S_SERIAL_T; + int raw_fd; + struct sockaddr_ll sll; + struct ifreq ifr; +} S_INTERFACE_CONNECTION_T; typedef struct { @@ -62,35 +55,6 @@ typedef struct u_int16_t u8_laneNumber; } S_PVR_T; -typedef struct -{ - u_int8_t u8_devid; - u_int8_t u8_partyp; - u_int8_t u8_parno; - int32_t i32_value; - float f_value; - u_int8_t u8_action; - u_int8_t u8_xor; - u_int8_t au8_can_cmd[CAN_BUFFER_SIZE]; - u_int8_t au8_can_cmd_SMS_TRANSPORT_PROTOCOL[CAN_SMS_BUFFER_SIZE]; -} S_COMMAND_T; - -typedef struct -{ - u_int16_t u16_startPattern; - u_int8_t u8_protocolVersion; - u_int8_t u8_headerLength; - u_int16_t u16_payloadLength; - u_int8_t u8_AppProtocolType; - u_int32_t u32_flags; - u_int16_t u16_headerCRC16; - u_int8_t au8_Payload[1024]; - u_int8_t au8_Header[1024]; - u_int16_t u16_PayloadCRC16; - u_int16_t u16_indexHeader; - u_int16_t u16_indexPayload; -} S_SMS_DATA_FRAME_T; - typedef struct { u_int8_t u8_sensorStatus; @@ -166,13 +130,31 @@ typedef struct uint64_t T_GenCpmMin; uint64_t T_GenCpmMax; - /* Position of the radar (Value from toml) */ +/* Position of the radar (Value from toml) */ + int8_t radar_rotation; } dissemination_t; /* Prototype Functions */ +/* +Summary : Waits for client to connect (Radar) +*/ + +bool waitingIncomingConnection(void); + + + +/* +Summary : Creation of socket and binding to the radar add and port + param [in] char* radar_ip: Radar IP + param [in] char* radar_port: Radar PORT +*/ + +bool initEthernetConnection(const char* radar_ip,const char* radar_port); + + /* Summary : Initialization for dissemination control. (Memory allocation and mutex init @@ -191,8 +173,7 @@ bool initEthernetConnection(const char* radar_ip,const char* radar_port); /* Summary: Read from Radar socket (s_socket.i32_socket) call the function to interpret data - param[in] void - + param[in] void */ void* cp_service(void* fc);