I am working on porting a scaled down version of a ip/socket based protocol that my company wrote for a *nix based operating system.
Despite the system being quite old it was written fairly well for portability. It uses Message IDs and has structures associated with them. I am porting just a small
subset of the message IDs to keep it as simple as possible. I have the basic connection, ack, nack and keep alive messages working. But when I call the function below the program crashes upon server.available() in the beginning of the program.
We have structures and we use macros to create tables of the elements. There are Pack and Unpack functions. I have used the Pack function with no problem, it is the Unpack function that is causing the issue.
acMidString - raw incoming ascii data
pvMid - message struct
Table - element table for that specific struct(offsets)
int FepMidUnpack(const char *acMidString, void *pvMID, const ST_FEP_MID_TABLE *pstTable, int iUseFieldIndex)
{
const ST_FEP_MID_TABLE *pstField = pstTable;
char acFieldNumStr[16];
int iFieldNum = 1;
int iRes = 1;
int iStringOfs = sizeof(ST_FEP_HDR_AC_W100);
while ((pstField->iSize != -1) && (iRes == 1))
{
if (iUseFieldIndex)
{
sprintf(acFieldNumStr, "%02d", iFieldNum);
if (strncmp(&acMidString[iStringOfs], acFieldNumStr, 2) != 0)
{
iRes = -1;
}
iStringOfs += 2;
}
if (iRes == 1)
{
strncpy((char *) pvMID + pstField->iOfs, &acMidString[iStringOfs], pstField->iSize);
iStringOfs += pstField->iSize;
}
pstField++;
iFieldNum++;
}
return iRes;
}
Here is my program and ram memory usage before and after including the call:
Program: 19432 bytes (59.3% Full)
Data: 1631 bytes (79.6% Full)
After
Program: 19524 bytes (59.6% Full)
Data: 1697 bytes (82.9% Full)
Is the problem that I am getting too close to the RAM cap? I would like to verify the source of the problem before upgrading to a Mega.
Any Ideas would be great.
Thanks