@@ -92,8 +92,19 @@ typedef struct
9292 SspData * sspDataForAckNak ;
9393} SspComObj ;
9494
95+
96+ /*
97+ SendTransId SSP transport protocol should be different from 0 (random value) after initialization (restart process).
98+ A weakness of the SSP protocol is that it is always started at 0.
99+ If the process restarts on the host side after the first transfer,
100+ is discarded on the embedded side if another protocol with a transfer counter of 0 is received after the first protocol.
101+
102+ qick fix - never reset the counter to 0 after initialization.
103+ */
104+ static UINT8 g_u8SendTransId = 0U ;
105+
95106// Private module data
96- static SspComObj self ;
107+ static SspComObj self = { 0 } ;
97108
98109// Private functions
99110static SendData * AllocSendData (UINT16 dataSize );
@@ -655,7 +666,7 @@ void SSP_Term(void)
655666 UINT16 portId ;
656667
657668 // Iterate over all ports
658- for (portId = SSP_PORT1 ; portId < SSP_MAX_PORTS ; portId ++ )
669+ for (portId = 1 ; portId < SSP_MAX_PORTS ; portId ++ )
659670 {
660671 // Remove all outgoing messages from list
661672 while ((sendData = ListFront (portId )) != NULL )
@@ -668,6 +679,11 @@ void SSP_Term(void)
668679 SSPOSAL_LockDestroy (self .hSspLock );
669680 self .hSspLock = SSP_OSAL_INVALID_HANDLE_VALUE ;
670681 SSPCOM_Term ();
682+ self .initOnce = FALSE;
683+
684+ #ifdef USE_FB_ALLOCATOR
685+ ALLOC_Term ();
686+ #endif
671687}
672688
673689/// Open a socket on a port. Each socket may only be opened one time. Socket ID's
@@ -771,7 +787,8 @@ SspErr SSP_SendMultiple(UINT8 srcSocketId, UINT8 destSocketId, INT16 numData,
771787 sendData -> sspData -> packet .header .bodySize = (UINT8 )dataSize ;
772788 sendData -> sspData -> packet .header .srcId = srcSocketId ;
773789 sendData -> sspData -> packet .header .destId = destSocketId ;
774- sendData -> sspData -> packet .header .transId = self .sendTransId ++ ;
790+ self .sendTransId = g_u8SendTransId ++ ;
791+ sendData -> sspData -> packet .header .transId = self .sendTransId ;
775792 sendData -> sspData -> packet .header .type = MSG_TYPE_DATA ;
776793
777794 // Insert the outgoing message into the list
@@ -867,7 +884,7 @@ void SSP_Process()
867884 BOOL powerSave = TRUE;
868885
869886 // Iterate over all ports
870- for (portId = SSP_PORT1 ; portId < SSP_MAX_PORTS ; portId ++ )
887+ for (portId = 1 ; portId < SSP_MAX_PORTS ; portId ++ )
871888 {
872889 // Is the port open?
873890 if (SSPCOM_IsPortOpen ((SspPortId )portId ) == TRUE)
0 commit comments