SNIC UART Interface library for Murata Type-YD module
Dependents: WebSocketServerTest
Fork of SNICInterface_mod by
Diff: Socket/UDPSocket.cpp
- Revision:
- 38:f13e4e563d65
- Parent:
- 36:f33fcf5975ab
- Child:
- 39:a1233ca02edf
diff -r f3a2053627c2 -r f13e4e563d65 Socket/UDPSocket.cpp --- a/Socket/UDPSocket.cpp Tue Jun 24 06:24:23 2014 +0000 +++ b/Socket/UDPSocket.cpp Wed Jun 25 00:04:11 2014 +0000 @@ -52,10 +52,10 @@ // Get local ip address. // Get buffer for response payload from MemoryPool - tagMEMPOOL_BLOCK_T *payload_buf = snic_core_p->allocCmdBuf(); - if( payload_buf == NULL ) + tagMEMPOOL_BLOCK_T *payload_buf_p = snic_core_p->allocCmdBuf(); + if( payload_buf_p == NULL ) { - printf("UDP bind payload_buf NULL\r\n"); + printf("UDP bind payload_buf_p NULL\r\n"); return -1; } @@ -65,33 +65,33 @@ req.seq = mUartRequestSeq++; req.interface = 0; - unsigned char *command_array = snic_core_p->getCommandBuf(); + unsigned char *command_array_p = snic_core_p->getCommandBuf(); unsigned int command_len; // Preparation of command command_len = snic_core_p->preparationSendCommand( UART_CMD_ID_SNIC, req.cmd_sid, (unsigned char *)&req - , sizeof(C_SNIC_Core::tagSNIC_GET_DHCP_INFO_REQ_T), payload_buf->buf, command_array ); + , sizeof(C_SNIC_Core::tagSNIC_GET_DHCP_INFO_REQ_T), payload_buf_p->buf, command_array_p ); // Send uart command request - snic_core_p->sendUart( command_len, command_array ); + snic_core_p->sendUart( command_len, command_array_p ); // Wait UART response ret = uartCmdMgr_p->wait(); if( ret != 0 ) { printf( "UDP bind failed\r\n" ); - snic_core_p->freeCmdBuf( payload_buf ); + snic_core_p->freeCmdBuf( payload_buf_p ); return -1; } if( uartCmdMgr_p->getCommandStatus() != UART_CMD_RES_SNIC_SUCCESS ) { printf("UDP bind status:%02x\r\n", uartCmdMgr_p->getCommandStatus()); - snic_core_p->freeCmdBuf( payload_buf ); + snic_core_p->freeCmdBuf( payload_buf_p ); return -1; } - unsigned int local_addr = (payload_buf->buf[9] << 24) - | (payload_buf->buf[10] << 16) - | (payload_buf->buf[11] << 8) - | (payload_buf->buf[12]); + unsigned int local_addr = (payload_buf_p->buf[9] << 24) + | (payload_buf_p->buf[10] << 16) + | (payload_buf_p->buf[11] << 8) + | (payload_buf_p->buf[12]); C_SNIC_Core::tagSNIC_UDP_CREATE_SOCKET_REQ_T create_req; @@ -107,26 +107,26 @@ // Preparation of command command_len = snic_core_p->preparationSendCommand( UART_CMD_ID_SNIC, create_req.cmd_sid, (unsigned char *)&create_req - , sizeof(C_SNIC_Core::tagSNIC_UDP_CREATE_SOCKET_REQ_T), payload_buf->buf, command_array ); + , sizeof(C_SNIC_Core::tagSNIC_UDP_CREATE_SOCKET_REQ_T), payload_buf_p->buf, command_array_p ); // Send uart command request - snic_core_p->sendUart( command_len, command_array ); + snic_core_p->sendUart( command_len, command_array_p ); // Wait UART response ret = uartCmdMgr_p->wait(); if( ret != 0 ) { printf( "UDP bind failed\r\n" ); - snic_core_p->freeCmdBuf( payload_buf ); + snic_core_p->freeCmdBuf( payload_buf_p ); return -1; } if( uartCmdMgr_p->getCommandStatus() != 0 ) { printf("UDP bind status:%02x\r\n", uartCmdMgr_p->getCommandStatus()); - snic_core_p->freeCmdBuf( payload_buf ); + snic_core_p->freeCmdBuf( payload_buf_p ); return -1; } - mSocketID = payload_buf->buf[3]; + mSocketID = payload_buf_p->buf[3]; C_SNIC_Core::tagSNIC_UDP_START_RECV_REQ_T recv_start_req; @@ -139,27 +139,27 @@ // Preparation of command command_len = snic_core_p->preparationSendCommand( UART_CMD_ID_SNIC, recv_start_req.cmd_sid, (unsigned char *)&recv_start_req - , sizeof(C_SNIC_Core::tagSNIC_UDP_START_RECV_REQ_T), payload_buf->buf, command_array ); + , sizeof(C_SNIC_Core::tagSNIC_UDP_START_RECV_REQ_T), payload_buf_p->buf, command_array_p ); // Send uart command request - snic_core_p->sendUart( command_len, command_array ); + snic_core_p->sendUart( command_len, command_array_p ); // Wait UART response ret = uartCmdMgr_p->wait(); if( ret != 0 ) { printf( "UDP recv start failed\r\n" ); - snic_core_p->freeCmdBuf( payload_buf ); + snic_core_p->freeCmdBuf( payload_buf_p ); return -1; } if( uartCmdMgr_p->getCommandStatus() != 0 ) { printf("UDP recv start status:%02x\r\n", uartCmdMgr_p->getCommandStatus()); - snic_core_p->freeCmdBuf( payload_buf ); + snic_core_p->freeCmdBuf( payload_buf_p ); return -1; } - snic_core_p->freeCmdBuf( payload_buf ); + snic_core_p->freeCmdBuf( payload_buf_p ); return 0; } @@ -171,10 +171,10 @@ C_SNIC_UartCommandManager *uartCmdMgr_p = snic_core_p->getUartCommand(); // Get buffer for response payload from MemoryPool - tagMEMPOOL_BLOCK_T *payload_buf = snic_core_p->allocCmdBuf(); - if( payload_buf == NULL ) + tagMEMPOOL_BLOCK_T *payload_buf_p = snic_core_p->allocCmdBuf(); + if( payload_buf_p == NULL ) { - printf("connect payload_buf NULL\r\n"); + printf("connect payload_buf_p NULL\r\n"); return -1; } @@ -197,31 +197,31 @@ memcpy( send_buf_p, &req, req_size ); memcpy( &send_buf_p[req_size], packet, length ); - unsigned char *command_array = snic_core_p->getCommandBuf(); + unsigned char *command_array_p = snic_core_p->getCommandBuf(); unsigned int command_len; // Preparation of command command_len = snic_core_p->preparationSendCommand( UART_CMD_ID_SNIC, req.cmd_sid, (unsigned char *)send_buf_p - , req_size + length, payload_buf->buf, command_array ); + , req_size + length, payload_buf_p->buf, command_array_p ); // Send uart command request - snic_core_p->sendUart( command_len, command_array ); + snic_core_p->sendUart( command_len, command_array_p ); // Wait UART response int ret = uartCmdMgr_p->wait(); if( ret != 0 ) { printf( "send failed\r\n" ); - snic_core_p->freeCmdBuf( payload_buf ); + snic_core_p->freeCmdBuf( payload_buf_p ); return -1; } if( uartCmdMgr_p->getCommandStatus() != UART_CMD_RES_SNIC_SUCCESS ) { printf("send status:%02x\r\n", uartCmdMgr_p->getCommandStatus()); - snic_core_p->freeCmdBuf( payload_buf ); + snic_core_p->freeCmdBuf( payload_buf_p ); return -1; } - snic_core_p->freeCmdBuf( payload_buf ); + snic_core_p->freeCmdBuf( payload_buf_p ); // SNIC_SEND_FROM_SOCKET_REQ return 0;