Hello All,
I am having an issue with the library where Socket Send function works as intended for a while but then once in a while it does not send the payload it is supposed to send and times out.
Subsequently the modem interpret the following messages as payload.
We are using Telit Cinterion PLS63 modem.
The way the write command works is the following:
We send the command and length and receive the length we are able to send as a response or we get CME Error to indicate sending is not available right now (socket closed etc.).
Here are the implementations for parsing and send functions:
static CellularPktStatus_t _Cellular_SocketSendDataPrefix( void * pCallbackContext,
char * pLine,
uint32_t * pBytesRead )
{
if( ( pLine == NULL ) || ( pBytesRead == NULL ) ) {
return CELLULAR_PKT_STATUS_BAD_PARAM;
}
// Clip anything that comes after ^SISW
const size_t clippingPoint = sizeof("^SISW")-1;
pLine[ clippingPoint ] = '\n';
*pBytesRead = clippingPoint+1;
return CELLULAR_PKT_STATUS_OK;
}
CellularError_t Cellular_SocketSend( CellularHandle_t cellularHandle,
CellularSocketHandle_t socketHandle,
const uint8_t * pData,
uint32_t dataLength,
// coverity[misra_c_2012_rule_8_13_violation]
uint32_t * pSentDataLength )
{
CellularContext_t * pContext = ( CellularContext_t * ) cellularHandle;
CellularError_t cellularStatus = _Cellular_CheckLibraryStatus( pContext );
if( cellularStatus != CELLULAR_SUCCESS ) {
return cellularStatus;
}
if( socketHandle == NULL ) {
return CELLULAR_INVALID_HANDLE;
}
switch( socketHandle->socketState ) {
case SOCKETSTATE_CONNECTED: {
break;
}
case SOCKETSTATE_ALLOCATED: // Intended fallthrough
case SOCKETSTATE_CONNECTING: {
return CELLULAR_SOCKET_NOT_CONNECTED;
}
case SOCKETSTATE_DISCONNECTED: {
return CELLULAR_SOCKET_CLOSED;
}
default: {
return CELLULAR_INTERNAL_FAILURE;
}
}
if( ( pData == NULL ) || ( pSentDataLength == NULL ) || ( dataLength == 0U ) ) {
return CELLULAR_BAD_PARAMETER;
}
if( dataLength > ( uint32_t ) CELLULAR_MAX_SEND_DATA_LEN ) {
dataLength = ( uint32_t ) CELLULAR_MAX_SEND_DATA_LEN;
}
char cmdBuf[ CELLULAR_AT_CMD_MAX_SIZE ] = { '\0' };
CellularAtReq_t atReqSocketSend = {
.pAtCmd = cmdBuf,
.atCmdType = CELLULAR_AT_NO_RESULT
};
if ( 0 > snprintf( cmdBuf,
CELLULAR_AT_CMD_MAX_SIZE,
"AT^SISW=%d,%d",
socketHandle->socketId,
dataLength ) ) {
return CELLULAR_INTERNAL_FAILURE;
}
CellularAtDataReq_t atDataReqSocketSend = {
.pData = pData,
.dataLen = dataLength,
.pSentDataLength = pSentDataLength,
};
const uint32_t atCommandTimeoutMs = CELLULAR_COMMON_AT_COMMAND_TIMEOUT_MS;
const uint32_t dataSendTimeoutMs =
socketHandle->sendTimeoutMs != 0 ?
socketHandle->sendTimeoutMs :
CELLULAR_COMMON_AT_COMMAND_TIMEOUT_MS;
const uint32_t delayBetweenAtAndDataCommandsMs = 0;
CellularPktStatus_t pktStatus = //_Cellular_AtcmdRequestWithCallback( pContext, atReqSocketSend );
_Cellular_AtcmdDataSend( pContext,
atReqSocketSend,
atDataReqSocketSend,
_Cellular_SocketSendDataPrefix,
socketHandle,
atCommandTimeoutMs,
dataSendTimeoutMs,
delayBetweenAtAndDataCommandsMs );
return _Cellular_TranslatePktStatus( pktStatus );
}
I have added the salae capture as a zip since sal files are not permitted:
CaptureShort.zip (109.3 KB)
First timestamp shows that response to write command is received but the payload is not sent by the library and timeout occurs after 20 seconds.
What could be the cause of library not sending the data?
Thank you,
Tuna