Skip to content

Commit 766098b

Browse files
committed
Merge branch 'Jovan-ux-feature/minor_fixes'
Minor fixes.
2 parents 8426ba3 + b2d14d4 commit 766098b

4 files changed

Lines changed: 40 additions & 22 deletions

File tree

port/ssp_opt_cus.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,19 +48,19 @@
4848

4949
typedef enum
5050
{
51-
SSP_INVALID_PORT = 0, // Must be 0
52-
SSP_PORT1 = 1, /// @TODO: Define port ID's
53-
SSP_PORT2 = 2,
54-
SSP_MAX_PORTS
55-
} SspPortId;
51+
SSP_INVALID_PORT = 0, // Must be available and must be 0
52+
SSP_PORT1 = 1, // PORT1 (may be replaced....), must be 1
53+
SSP_PORT2 = 2, // PORT2 (may be replaced....)
54+
SSP_MAX_PORTS // Must be available and last no.
55+
} SspPortId; // Enum OBLIGATORY!
5656

5757
typedef enum
5858
{
59-
SSP_SOCKET_MIN = 0, // Must be 0
59+
SSP_SOCKET_MIN = 0, // Must be available and must be 0
6060
SSP_SOCKET_COMMAND = SSP_SOCKET_MIN, /// @TODO: Define socket ID's
6161
SSP_SOCKET_STATUS,
6262
SSP_SOCKET_LOG,
63-
SSP_SOCKET_MAX
64-
} SspSocketId;
63+
SSP_SOCKET_MAX // Must be available and last no.
64+
} SspSocketId; // Enum OBLIGATORY!
6565

6666
#endif //#ifndef SSP_OPT_CUS_H

ssp/ssp.c

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -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
99110
static 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)

ssp/ssp_com.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ typedef struct
7070
} SspComObj;
7171

7272
// Private module data
73-
static SspComObj self;
73+
static SspComObj self = {0};
7474

7575
// Private functions
7676
static UINT8 Checksum(const UINT8* data, UINT16 dataSize);
@@ -407,6 +407,7 @@ void SSPCOM_Term(void)
407407

408408
SSPHAL_Term();
409409
SSPOSAL_Term();
410+
self.initOnce = FALSE;
410411
}
411412

412413
/// Allocate packet body data.

ssp/ssp_opt.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
// Define to output log messages
4141
#define USE_SSP_TRACE
4242

43-
// Define uses fixed block allocator. Undefine uses malloc/free.
43+
// Define uses fixed block allocator. Undefine uses malloc/free.
4444
#define USE_FB_ALLOCATOR
4545

4646
// Arduino build options
@@ -73,20 +73,20 @@
7373

7474
typedef enum
7575
{
76-
SSP_INVALID_PORT = 0, // Must be 0
77-
SSP_PORT1 = 1, /// @TODO: Define port ID's
78-
SSP_PORT2 = 2,
79-
SSP_MAX_PORTS
80-
} SspPortId;
76+
SSP_INVALID_PORT = 0, // Must be available and must be 0
77+
SSP_PORT1 = 1, // PORT1 (may be replaced....), must be 1
78+
SSP_PORT2 = 2, // PORT2 (may be replaced....)
79+
SSP_MAX_PORTS // Must be available and last no.
80+
} SspPortId; // Enum OBLIGATORY!
8181

8282
typedef enum
8383
{
84-
SSP_SOCKET_MIN = 0, // Must be 0
84+
SSP_SOCKET_MIN = 0, // Must be available and must be 0
8585
SSP_SOCKET_COMMAND = SSP_SOCKET_MIN, /// @TODO: Define socket ID's
8686
SSP_SOCKET_STATUS,
8787
SSP_SOCKET_LOG,
88-
SSP_SOCKET_MAX
89-
} SspSocketId;
88+
SSP_SOCKET_MAX // Must be available and last no.
89+
} SspSocketId; // Enum OBLIGATORY!
9090

9191
#endif //#ifdef SSP_CONFIG
9292
#endif //#ifndef SSP_OPT_H

0 commit comments

Comments
 (0)