void vTestKernel(void *pvAddress) { char send_buf[BUF_SIZE]; char recv_buf[BUF_SIZE]; unsigned int rtn; char ch = 'A'; while (1) { send_buf[0] = ch; send_buf[1] = '\0'; ch = (char)((unsigned int)ch + 1); if(ch > 'Z') { ch = 'A'; } rtn = enet_send(send_buf); if (rtn > 0) { term_printf("<<<Task 1>>> sent by enet: %s\r\n", send_buf); vTaskDelay(500 / portTICK_RATE_MS); rtn = enet_recv(recv_buf, 1); if(rtn > 0) { term_printf("<<<Task 1>>> received by enet: %s\r\n", recv_buf); } else { term_printf("<<<Task 1>>> received nothing by enet!\r\n"); } } else { term_printf("<<<Task 1>>> failed to send data by enet!\r\n"); } } }
int dsmp_send(wnet_envar_t *p_wnet, wnet_txinfo_t *txinfo, uint8_t *pdata, uint32_t length) { int ret = 0; int len = 0; /* add dsmp header to pdata */ dsmp_hdr_t *p_dsmp_head = NULL; security_hdr_t *p_sec_head = NULL; len = DSMP_HEADER_LEN; pdata -= len; p_dsmp_head = (dsmp_hdr_t *)pdata; memset(p_dsmp_head, 0, len); /* Initial dsmp frame head domain. */ p_dsmp_head->version = DSMP_VERSION; p_dsmp_head->aid = cv_ntohl(WAVE_AID_vehicle_safety); p_dsmp_head->element_id = WAVE_ELEMENT_ID_WSM; p_dsmp_head->dsm_length = cv_ntohs((uint16_t)length); length += len; /* send to llc layer or encryption */ if (!txinfo->encryption) { /* add 1609.2 header. TBD */ len = SECURITY_HEADER_LEN; pdata -= len; length += len; p_sec_head = (security_hdr_t *)pdata; p_sec_head->version = SEC_VERSION; p_sec_head->security_type = 0; // ret = llc_send(p_wnet, txinfo, pdata, length); ret = enet_send(p_wnet, txinfo, pdata, length); } else { /* add dot2_hdr and security_hdt */ /* sent to enc module. enc_offset indicate the data need to be encrypted */ } return ret; }