Hello all. I'm posting my first question here after having viewed many useful exchanges by others; it's very exciting! I'm thinking that this question will be fairly straightforward to answer, but I hope that someone can shed some light on it since its vexing me.
I have a function that accepts an array of bytes passed in as a byte pointer, multiple layers of the program lower. The variable is a member of the class defined as
m_GpsInputBuf[GpsInputBuflen];
The function in question receives a pointer to that array as shown in the code below. The function just shifts the bytes in the array to the left when the checksum for the packet is not validated and another sync character for the data packet is located within the body of the packet. All questions as to the purpose of the function aside though, the point that I'm interested in is the copying of the temp array to the parameter byte array pointer.
The copy to the pPacketbuf variable takes place just as I'd hoped, but when the function terminates, the pPacketbuf variable that exists at the calling level of the ScanAndShift() function is unaffected. This is related to the argument to ScanAndShift() being a copy of the pointer variable, I believe, but I'm too close to the problem to understand it right now. Any insight? Code below:
int CFlirPumpDlg::ScanAndShift(BYTE *pPacketbuf)
{
int idx3 = 0;
BYTE tempGpsInputBuf[GpsInputBuflen];
for(int idx = 1; idx < GpsInputBuflen; idx++)
{
if(pPacketbuf[idx] == CFlirPumpApp::GPS_Start)
{
idx3 = idx;
for(int idx2 = 0; idx2 < (GpsInputBuflen - idx); idx2++)
{
tempGpsInputBuf[idx2] = pPacketbuf[idx3++];
}
pPacketbuf = (BYTE *)&tempGpsInputBuf;
return (GpsInputBuflen - idx);
}
}
return 0;
}