customized SNICInterface
Fork of NySNICInterface by
Diff: SNIC/SNIC_UartMsgUtil.cpp
- Revision:
- 36:f33fcf5975ab
- Parent:
- 31:15c22824cc46
- Child:
- 38:f13e4e563d65
--- a/SNIC/SNIC_UartMsgUtil.cpp Tue Jun 10 10:19:48 2014 +0000 +++ b/SNIC/SNIC_UartMsgUtil.cpp Thu Jun 19 10:15:47 2014 +0000 @@ -21,32 +21,6 @@ { } -unsigned short C_SNIC_UartMsgUtil::makePayload( unsigned int cmd_len, unsigned char *cmd_p, unsigned char *payload_p ) -{ - unsigned short payload_len = 0; - int i; - - for( i = 0; i < cmd_len; i++, payload_p++, payload_len++ ) - { - /* check Escape code */ - if( ( cmd_p[i] == UART_CMD_SOM ) || ( cmd_p[i] == UART_CMD_EOM ) || ( cmd_p[i] == UART_CMD_ESC ) ) - { - /* Add ESC */ - *payload_p = UART_CMD_ESC; - payload_len++; - - payload_p++; - *payload_p = (0x80 | cmd_p[i]); - } - else - { - *payload_p = cmd_p[i]; - } - } - - return payload_len; -} - unsigned int C_SNIC_UartMsgUtil::makeRequest( unsigned char cmd_id,unsigned char *payload_p , unsigned short payload_len, unsigned char *uart_command_p ) { @@ -81,7 +55,6 @@ for( i = 0; i < payload_len; i++, uart_command_p++, uart_cmd_len++ ) { *uart_command_p = payload_p[i]; - check_sum += *uart_command_p; } // set Check sum @@ -100,7 +73,6 @@ , unsigned char *command_id_p, unsigned char *payload_p ) { unsigned short payload_len = 0; - unsigned int response_len = 0; unsigned char *buf = NULL; bool isESC = false; int i; @@ -116,31 +88,11 @@ // get payload data for( i = 0; i < payload_len; i++, buf++ ) { - if( isESC ) - { - *payload_p = (*buf & ~0x80); - payload_p++; - response_len++; - isESC = false; - } - else - { - // Check Escape code - if( *buf == UART_CMD_ESC ) - { - isESC = true; - continue; - } - else - { - *payload_p = *buf; - payload_p++; - response_len++; - } - } + *payload_p = *buf; + payload_p++; } - return response_len; + return payload_len; } int C_SNIC_UartMsgUtil::addrToInteger( const char *addr_p ) @@ -190,4 +142,4 @@ addr_array_p[1] = ((addr & 0xFF0000) >> 16 ); addr_array_p[2] = ((addr & 0xFF00) >> 8 ); addr_array_p[3] = ( addr & 0xFF); -} \ No newline at end of file +}