Below is a code Snippet:
I am trying to pass pointers through a function; And I am trying to get back the results. Does not work at this time?
main() {
static UCHAR ucRcvAddress, *ucMBFrame, usLength;
eStatus = eMBRTUReceive( &ucRcvAddress, &ucMBFrame, &usLength );
}
eMBErrorCode eMBRTUReceive( UCHAR * pucRcvAddress, UCHAR ** pucFrame, USHORT * pusLength ) { BOOL xdata xFrameReceived = FALSE; eMBErrorCode xdata eStatus = MB_ENOERR; UCHAR test = 5;
ENTER_CRITICAL_SECTION(); assert( usRcvBufferPos < MB_SER_PDU_SIZE_MAX );
if( ( usRcvBufferPos >= MB_SER_PDU_SIZE_MIN ) && ( usMBCRC16( ( UCHAR * ) ucRTUBuf, usRcvBufferPos ) >= 0 ) ) { *pusLength = ( USHORT )( usRcvBufferPos - MB_SER_PDU_PDU_OFF - MB_SER_PDU_SIZE_CRC );
*pucFrame = ( UCHAR * ) & ucRTUBuf[MB_SER_PDU_PDU_OFF]; xFrameReceived = TRUE; } else { eStatus = MB_EIO; } EXIT_CRITICAL_SECTION( ); return eStatus; }
I am trying to pass a pointer to capture an array[] then pass it back.
Phil
if you READ the instructions above the message entry window, you would have a better chance of a reply.
Did what you enetered look OK on the preview? as it did not, why did you not fix it before posting?
Erik
ie, these instructions (click to view): www.danlhenry.com/.../keil_code.png
"Does not work at this time?
What does that mean?
""Does not work at this time?"
Does it work better if you run it at a different time?
If that time is after the time that the code gets fixed - Yes!
If I have a defined pointer, like *ucMBFrame.
I should be able to pass this as an argument to a function like eMBError Receive( &ucMBFrame);
on the other side I should be able to capture first position of the array.
Receive( **pucFrame) { *pucFrame = &ucMBRTUBuf[Buf_Size]; }
and return it to calling function.
The results should be first position of char ucMBRTUBuf[Buf_Size];
and if I went -- data = *ucMBFrame[1]; I should see second char in the array?
"The results should be first position of char ucMBRTUBuf[Buf_Size];"
No, assuming Buf_Size is as it's named, the result would be the address just past the end of the array.