Skip to content

Commit

Permalink
Fix nasa#37, Offset the UDP base port per-CPU
Browse files Browse the repository at this point in the history
Avoid port conflicts when having more than one CPU within the same
mission load CI_LAB app.  Instead of binding to the port directly,
add the CPU number as an offset.  Subtract 1 so that CPU1 remains
at the same port (1234 by default) and cmdUtil is not affected.

NOTE: the "cpu number" can be overridden on the command line when
using the pc-linux PSP, thereby also permitting the listen point
to be tuned for each launch config, if necessary.
  • Loading branch information
jphickey committed Mar 12, 2020
1 parent 3ad9a10 commit daadfb5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
7 changes: 5 additions & 2 deletions fsw/src/ci_lab_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,8 @@ void CI_LAB_delete_callback(void)
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * **/
void CI_LAB_TaskInit(void)
{
int32 status;
int32 status;
uint16 DefaultListenPort;

memset(&CI_LAB_Global, 0, sizeof(CI_LAB_Global));

Expand All @@ -176,7 +177,8 @@ void CI_LAB_TaskInit(void)
else
{
OS_SocketAddrInit(&CI_LAB_Global.SocketAddress, OS_SocketDomain_INET);
OS_SocketAddrSetPort(&CI_LAB_Global.SocketAddress, cfgCI_LAB_PORT);
DefaultListenPort = CI_LAB_BASE_UDP_PORT + CFE_PSP_GetProcessorId() - 1;
OS_SocketAddrSetPort(&CI_LAB_Global.SocketAddress, DefaultListenPort);

status = OS_SocketBind(CI_LAB_Global.SocketID, &CI_LAB_Global.SocketAddress);

Expand All @@ -188,6 +190,7 @@ void CI_LAB_TaskInit(void)
else
{
CI_LAB_Global.SocketConnected = true;
CFE_ES_WriteToSysLog("CI_LAB listening on UDP port: %u\n", (unsigned int)DefaultListenPort);
}
}

Expand Down
6 changes: 3 additions & 3 deletions fsw/src/ci_lab_app.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@

/****************************************************************************/

#define cfgCI_LAB_PORT 1234
#define CI_LAB_MAX_INGEST 768
#define CI_LAB_PIPE_DEPTH 32
#define CI_LAB_BASE_UDP_PORT 1234
#define CI_LAB_MAX_INGEST 768
#define CI_LAB_PIPE_DEPTH 32

/************************************************************************
** Type Definitions
Expand Down

0 comments on commit daadfb5

Please sign in to comment.