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_Core.cpp
- Revision:
- 36:f33fcf5975ab
- Parent:
- 35:e4e7f86fd975
- Child:
- 37:f3a2053627c2
--- a/SNIC/SNIC_Core.cpp Tue Jun 10 10:19:48 2014 +0000
+++ b/SNIC/SNIC_Core.cpp Thu Jun 19 10:15:47 2014 +0000
@@ -32,7 +32,6 @@
*/
unsigned char gUART_TEMP_BUF[UART_RECVBUF_SIZE] __attribute__((section("AHBSRAM1")));
unsigned char gUART_COMMAND_BUF[UART_REQUEST_PAYLOAD_MAX] __attribute__((section("AHBSRAM1")));
-unsigned char gPAYLOAD_ARRAY[UART_REQUEST_PAYLOAD_MAX] __attribute__((section("AHBSRAM1")));
/** MemoryPool for payload of UART response */
MemoryPool<tagMEMPOOL_BLOCK_T, MEMPOOL_PAYLOAD_NUM> mMemPoolPayload __attribute__((section("AHBSRAM1")));
/** MemoryPool for UART receive */
@@ -114,10 +113,8 @@
unsigned short payload_len;
unsigned int command_len = 0;
- // Make command payload
- payload_len = C_SNIC_UartMsgUtil::makePayload( req_buf_len, req_buf_p, gPAYLOAD_ARRAY );
// Make all command request
- command_len = C_SNIC_UartMsgUtil::makeRequest( cmd_id, gPAYLOAD_ARRAY, payload_len, command_p );
+ command_len = C_SNIC_UartMsgUtil::makeRequest( cmd_id, req_buf_p, req_buf_len, command_p );
// Set data for response
mUartCommand_p->setCommandID( cmd_id );
@@ -141,6 +138,7 @@
}
}
mUartMutex.unlock();
+
return ret;
}
@@ -215,17 +213,29 @@
gUART_RCVBUF_p->buf[ gUART_RCVBUF_p->size ] = (unsigned char)recvdata;
gUART_RCVBUF_p->size++;
- // Check received data is EOM.
- if( recvdata == UART_CMD_EOM )
+ if( gUART_RCVBUF_p->size == 3 )
{
- // Add queue
- mUartRecvQueue.put( gUART_RCVBUF_p );
+ // get demand size
+ unsigned short payload_len = ( ( (gUART_RCVBUF_p->buf[1] & ~0x80) & 0xff) | ( ( (gUART_RCVBUF_p->buf[2] & ~0xC0) << 7) & 0xff80) );
+ gUART_RCVBUF_p->demand_size = payload_len + 6;
+
+ }
+
+ if( gUART_RCVBUF_p->demand_size > 0 )
+ {
+ // Check size of received data.
+ if( gUART_RCVBUF_p->size >= gUART_RCVBUF_p->demand_size )
+ {
+ // Add queue
+ mUartRecvQueue.put( gUART_RCVBUF_p );
+
+ gUART_RCVBUF_p = NULL;
- gUART_RCVBUF_p = NULL;
-
- // set signal for dispatch thread
- instance_p->mUartRecvDispatchThread_p->signal_set( UART_DISPATCH_SIGNAL );
+ // set signal for dispatch thread
+ instance_p->mUartRecvDispatchThread_p->signal_set( UART_DISPATCH_SIGNAL );
+ }
}
+
}
else
{
@@ -234,6 +244,7 @@
{
gUART_RCVBUF_p = instance_p->allocUartRcvBuf();
gUART_RCVBUF_p->size = 0;
+ gUART_RCVBUF_p->demand_size = 0;
// get buffer for Uart receive
gUART_RCVBUF_p->buf[ 0 ] = (unsigned char)recvdata;
