Bonjour, j'ai probleme pour caster une variable.
J'ai le prototype de fonction suivant:
void UART_puts(uart_id_e uart_id, uint8_t * str, uint8_t len)
Lorsque j'initialise comme cela:
Et que je cast la variable comme cela:
UART_puts(UART3_ID, (uint8_t*)str, sizeof(str)); //Send the message to UART3 (Sigfox module)
Je n'ai pas de probleme, cela fonctionne.
Cependant, quand j'initialise comme cela:
Je ne sais pas comment utiliser ma variable dans la fonction UART_puts.
Quand j'ecris cela:
UART_puts(UART2_ID, (uint8_t)c, sizeof(c)); //send frame to uart 2 (USB)
J'obtiens cette erreur:
../Src/main.c:306:25: warning: passing argument 2 of 'UART_puts' makes pointer from integer without a cast [-Wint-conversion]
UART_puts(UART2_ID, (uint8_t)c, sizeof(c)); //send frame to uart 2 (USB)
Quand j'ecris cela:
UART_puts(UART2_ID, (uint8_t*)c, sizeof(c)); //send frame to uart 2 (USB)
J'obtiens cette erreur:
../Src/main.c:306:25: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
UART_puts(UART2_ID, (uint8_t*)c, sizeof(c)); //send frame to uart 2 (USB)
^
Et quand j'ecris cela:
UART_puts(UART2_ID, c, sizeof(c)); //send frame to uart 2 (USB)
J'obtiens cette erreur:
../Src/main.c:306:25: warning: passing argument 2 of 'UART_puts' makes pointer from integer without a cast [-Wint-conversion]
UART_puts(UART2_ID, c, sizeof(c)); //send frame to uart 2 (USB)
^
Comment faire pour cette variable c soit "compatible" avec le prototype de fonction? Merci.
Partager