Skip to main content
antonius
Associate III
February 12, 2016
Question

Transmitting variable to UART ?

  • February 12, 2016
  • 1 reply
  • 480 views
Posted on February 12, 2016 at 06:02

Guys,

I want to transmit ''res'' into UART buffer :

FRESULT f_open (

 

    FIL* fp,            /* Pointer to the blank file object */

 

    const TCHAR* path,    /* Pointer to the file name */

 

    BYTE mode            /* Access mode and file open mode flags */

 

)

 

{

 

    FRESULT res;

 

 

I want to print ''res'' to UART buffer

void Transmit_String_ff(unsigned char *s)

 

{

 

  HAL_UART_Transmit(&huart1, s, strlen(s), 1000); // As a pointer, with a length

 

}

I can't do

Transmit_String_ff(res)

I got this error,

error:  #167: argument of type ''FRESULT'' is incompatible with parameter of type ''unsigned char *''

How can I fix it ? thanks
    This topic has been closed for replies.

    1 reply

    AvaTar
    Senior III
    February 12, 2016
    Posted on February 12, 2016 at 07:08

    The FatFS source file

    ff.h

    says:

    typedef enum {

        ....

    } FRESULT;

    Thus, just cast it; enum is usually (but not necessarily)

    int

    :

      sprintf (buf, ''%d'',

    (int)

    fres);

    That is more or less basic C stuff.