for EthernetInterface library compatibility.\\ ** Unoffical fix. may be a problem. **
Dependents: SNIC-httpclient-example SNIC-ntpclient-example
Fork of SNICInterface by
Revision 1:c6e5f49dce5f, committed 2014-03-07
- Comitter:
- kishino
- Date:
- Fri Mar 07 02:13:09 2014 +0000
- Parent:
- 0:61c402886fbb
- Child:
- 2:0ba43344c814
- Commit message:
- The method which gets Payload from received data was created.
Changed in this revision
| YDwifi/YDwifi_uartmsg.cpp | Show annotated file Show diff for this revision Revisions of this file |
| YDwifi/YDwifi_uartmsg.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/YDwifi/YDwifi_uartmsg.cpp Thu Mar 06 11:13:00 2014 +0000
+++ b/YDwifi/YDwifi_uartmsg.cpp Fri Mar 07 02:13:09 2014 +0000
@@ -78,3 +78,49 @@
return uart_cmd_len;
}
+
+unsigned int C_YD_UartMsg::getResponsePayload( unsigned int cmd_len, unsigned char *recvdata_p
+ , 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;
+
+ // get payload length
+ payload_len = ( ( (recvdata_p[1] & ~0x80) & 0xff) | ( ( (recvdata_p[2] & ~0xC0) << 7) & 0xff00) );
+
+ // get Command ID
+ *command_id_p = (recvdata_p[3] & ~0x80);
+
+ buf = &recvdata_p[4];
+
+ // get payload data
+ for( i = 0; i < payload_len; i++, buf++ )
+ {
+ if( isESC )
+ {
+ *payload_p = (*buf & ~0x80);
+ payload_p++;
+ response_len++;
+ }
+ else
+ {
+ // Check Escape code
+ if( *buf == UART_CMD_ESC )
+ {
+ isESC = true;
+ continue;
+ }
+ else
+ {
+ *payload_p = *buf;
+ payload_p++;
+ response_len++;
+ }
+ }
+ }
+
+ return response_len;
+}
\ No newline at end of file
--- a/YDwifi/YDwifi_uartmsg.h Thu Mar 06 11:13:00 2014 +0000
+++ b/YDwifi/YDwifi_uartmsg.h Fri Mar 07 02:13:09 2014 +0000
@@ -91,13 +91,26 @@
C_YD_UartMsg();
/** Make SNIC UART command payload.
+ @param cmd_len Command length
+ @param cmd_p Command pointer
+ @param payload_p Payload pointer[output]
+ @return payload length
*/
static unsigned short makePayload( unsigned int cmd_len, unsigned char *cmd_p, unsigned char *payload_p );
/** Make SNIC UART command.
+ @param cmd_id Command ID
+ @param payload_p Payload pointer
+ @param uart_command_p UART Command pointer [output]
+ @return UART Command length
*/
- static unsigned int makeRequest( unsigned char cmd_id,unsigned char *payload_p, unsigned short payload_len, unsigned char *uart_command_p );
+ static unsigned int makeRequest( unsigned char cmd_id, unsigned char *payload_p, unsigned short payload_len, unsigned char *uart_command_p );
+
+ /** Get uart command from receive data.
+ */
+ static unsigned int getResponsePayload( unsigned int cmd_len, unsigned char *recvdata_p
+ , unsigned char *command_id_p, unsigned char *payload_p );
protected:
};
ban4jp -
