I receive strings over the serial port like so:
VLT=53.0, AMP=-30.2, AHR=-10, SOC=98, TMP=136, STS=192
I want to reduce the use of string functions with the idea of dropping all non-digits, keeping numbers dot and comma, to get this:
53.0,-30.2,-10,98,136,192
in an array and simple read [0], [1], etc.
Regular expressions would be idea, but do not exist like in PERL. Any hint would be much appreciated.
Relevant code used:
char inByte = SerialPortOne.read(); // read byte
strRecordIn.concat(inByte); // add byte to receive buffer
for (int i = 0; i <= 3; i++) { // VLT, AMP, AHR, SOC
strWord = getValue(strRecordIn, ',', i); // get data item from RecordIn array
strWord.remove(0, 4); // remove field identifier (1st 3 char plus =)
strRecordOut += ','; // add delimiter
strRecordOut += strWord; // add value
strWord = ""; // reset strWord
}
Ideally:
char inByte = SerialPortOne.read(); // read byte
if (inByte = [%d.,]+) {
strRecordIn.concat(inByte); // add byte to receive buffer
}