Arduino code help needed
Posted: Sun Jan 03, 2016 4:49 pm
I have the following strings I need to parse but have not been unable to achieve some working code...
K1 => K 1 byte ,byte
K2 => K 2 byte, byte
K3 => K 3 byte, byte
K4xxx => K 4 xxx = 0-255 byte, byte, word or byte
K5xxx => K 4 xxx = 0-255 byte, byte, word or byte
ZAByyyyy Z A = 1-5 B=0-9 yyyyy = 0-65535 byte, byte, byte, word
I just cannot save 1 char from string using string.substring(x,y) I get errors trying char, byte etc...
have not tried saving the 0-255 or 0-65535 values yet....
Arduino: 1.6.5 (Windows 7), Board: "Generic ESP8266 Module, Serial, 80 MHz, 40MHz, DIO, 115200, 512K (64K SPIFFS), ck"
wifi-web-servad.ino.ino: In function 'void loop()':
wifi-web-servad.ino:156: error: cannot convert 'String' to 'char' in assignment
wifi-web-servad.ino:157: error: cannot convert 'String' to 'char' in assignment
cannot convert 'String' to 'char' in assignment
K1 => K 1 byte ,byte
K2 => K 2 byte, byte
K3 => K 3 byte, byte
K4xxx => K 4 xxx = 0-255 byte, byte, word or byte
K5xxx => K 4 xxx = 0-255 byte, byte, word or byte
ZAByyyyy Z A = 1-5 B=0-9 yyyyy = 0-65535 byte, byte, byte, word
I just cannot save 1 char from string using string.substring(x,y) I get errors trying char, byte etc...
have not tried saving the 0-255 or 0-65535 values yet....
Arduino: 1.6.5 (Windows 7), Board: "Generic ESP8266 Module, Serial, 80 MHz, 40MHz, DIO, 115200, 512K (64K SPIFFS), ck"
wifi-web-servad.ino.ino: In function 'void loop()':
wifi-web-servad.ino:156: error: cannot convert 'String' to 'char' in assignment
wifi-web-servad.ino:157: error: cannot convert 'String' to 'char' in assignment
cannot convert 'String' to 'char' in assignment
Code: Select all
else if (PayLD.indexOf("cx=") != -1) // insure cx= exist this PayLoad
{ int s_mit = (PayLD.indexOf("cx=")); // find cx= start position
String submit = PayLD.substring(s_mit+3); // save string
submit.toUpperCase(); // make upper case
cmx = "cx=" + submit; // display data
char Ax = 0;
char Axx = 0;
Ax = submit.substring(0,1); // K= Z=
Axx = submit.substring(1,2);
if (Ax == 75) // found k/75 in position 0 = good
{
Serial.println("K-");
Serial.println(submit);
cmx = "cx="+ submit; }
else if (Ax == 90) // found z/90 in position 0 = good
{Serial.println("Z-");
Serial.println(submit);
cmx = "cx="+ submit; }
else
{ Serial.println("!K/Z "+ submit); }
}