This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Trying to pass pointers as arguemnts to a function

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

Parents
  • 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?

Reply
  • 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?

Children