Invalid conversion from 'char' to 'char'


how can fix code?

// simple parse demo
char receivedchars[] = "this test, 1234, 45.3" ;
char byteread;
char messagefrompc[32] = {0};
int integerfrompc = 0;
float floatfrompc = 0.0;

char recvchar;
char endmarker = '>';
boolean newdata = false;


void setup() {
   serial.begin(9600);
   serial.println("<arduino ready>");
   
   parsedata();
   showparseddata();
}


void loop() {

    if (serial.available()) {
    /* read recent byte */
    byteread = serial.read();
}
}
   
void parsedata() {

    // split data parts
   
  char * strtokindx; // used strtok() index
 
  strtokindx = strtok(byteread,",");      // first part - string
  strcpy(messagefrompc, strtokindx); // copy messagefrompc
 
  strtokindx = strtok(null, ","); // continues previous call left off
  integerfrompc = atoi(strtokindx);     // convert part integer
 
  strtokindx = strtok(null, ",");
  floatfrompc = atof(strtokindx);     // convert part float

}


void showparseddata() {
   serial.print("message ");
   serial.println(messagefrompc);
   serial.print("integer ");
   serial.println(integerfrompc);
   serial.print("float ");
   serial.println(floatfrompc);
}


invalid conversion 'char' 'char'


thanks in advance

strtok() cannot work on single byte - think it. needs c char array, array of chars last character being '\0'. need create such array.


Arduino Forum > Using Arduino > Programming Questions > Invalid conversion from 'char' to 'char'


arduino

Comments

Popular posts from this blog

invalid use of void expresion in FlexiTimer2 library

error: a function-definition is not allowed here before '{' token

LED Strip Code