-1

hi to all i have this problem i have a array of uint8_t

uint8_t command_Text[256]

i read some data from adc, i use snprintf for convert the data float in uint8_t

` float aux;
uint8_t value[4];  
aux=(float)(HAL_ADC_GetValue(&hadc))
 snprintf(value,4,"%.0f",aux);   //convert the data float to uint8_t
 strcat(command_Text, value);   //append data `

i see this Warning argument of type "uint8_t *" is incompatible with parameter of type "char const * i don't know manipolate the string in uint_8 data, i want read data e to append it in to array, can you help me?

OldProgrammer
  • 12,050
  • 4
  • 24
  • 45
Ant
  • 281
  • 1
  • 4
  • 19
  • snprintf takes a "char*" parameter, not "unsigned char*" – OldProgrammer Nov 06 '16 at 19:52
  • 2
    declare `value` as `char[4];` – selbie Nov 06 '16 at 19:55
  • 2
    That look slike for some embedded device. First rule is not to use flaoting point where avoidable. As your ADC most likely does not yield a floating point result, chances are pretty good you can use integers for the rest of your code, possibly emulating fractional or fixed-point arithmetics. Said that, you should also not use the `printf` and `scanf` family, as they are code-bloat. – too honest for this site Nov 06 '16 at 20:26

1 Answers1

0

Suggest something like:

uint8_t command_Text[256] = {'\0'};
....
uint8_t value[4] = {'\0'};  
snprintf(value,3,"%3.3u", atoi( HAL_ADC_GetValue( &hadc ) ) );   
strcat(command_Text, value);   //append data
user3629249
  • 16,402
  • 1
  • 16
  • 17