Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: MurataTypeYD_RPC_Sample
Fork of SNICInterface_mod by
Diff: SNIC/SNIC_UartMsgUtil.cpp
- Revision:
- 31:15c22824cc46
- Parent:
- 29:6a0ba999597d
- Child:
- 36:f33fcf5975ab
--- a/SNIC/SNIC_UartMsgUtil.cpp Tue May 27 01:33:04 2014 +0000
+++ b/SNIC/SNIC_UartMsgUtil.cpp Thu May 29 03:23:21 2014 +0000
@@ -141,4 +141,53 @@
}
return response_len;
+}
+
+int C_SNIC_UartMsgUtil::addrToInteger( const char *addr_p )
+{
+ if( addr_p == NULL )
+ {
+ printf("addrToInteger parameter error\r\n");
+ return 0;
+ }
+
+ unsigned char ipadr[4];
+ unsigned char temp= 0;
+ int i,j,k;
+
+ /* convert to char[4] */
+ k=0;
+ for(i=0; i<4; i ++)
+ {
+ for(j=0; j<4; j ++)
+ {
+ if((addr_p[k] > 0x2F)&&(addr_p[k] < 0x3A))
+ {
+ temp = (temp * 10) + addr_p[k]-0x30;
+ }
+ else if((addr_p[k] == 0x20)&&(temp == 0))
+ {
+ }
+ else
+ {
+ ipadr[i]=temp;
+ temp = 0;
+ k++;
+ break;
+ }
+ k++;
+ }
+ }
+
+ int addr = ( (ipadr[0]<<24) | (ipadr[1]<<16) | (ipadr[2]<<8) | ipadr[3] );
+
+ return addr;
+}
+
+void C_SNIC_UartMsgUtil::convertIntToByteAdday( int addr, char *addr_array_p )
+{
+ addr_array_p[0] = ((addr & 0xFF000000) >> 24 );
+ 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
