Search code examples
creturn

Print the data and size from return call;


Here i need to print the data and the size of the data in this function call CDCDSerialDriver_Read() which is returning the status of the operation.

static inline uint32_t CDCDSerialDriver_Read(void *data, uint32_t size, TransferCallback callback, void *argument)
{
    printf("CDCDSerialDriver_Read:\n\r");
    return CDCDSerial_Read(data, size, callback, argument);
}

Is there any way to print the data & size before the return call in this function. Thanks in Advance,


Solution

  • As was suggested in comments to question - the easiest way is to save result after function call and then return it after print.

    static inline uint32_t CDCDSerialDriver_Read(void *data, uint32_t size, TransferCallback callback, void *argument)
    {
        printf("CDCDSerialDriver_Read:\n\r");
        uint32_t res = CDCDSerial_Read(data, size, callback, argument);
        // TODO: print everithing you want
        return res;
    }