Process serial string input?
Just checking before reinventing some wheels...
Getting data input on a P2 pin as TTL serial text.
The data string looks like this:
VAC1=3.99e+01 VAC2=2.17e-01 VAC3=9.04e+02
Is there something already that can turn a string into a float?
Would also be convenient if something could parse this input, but guessing not...
Comments
This probably won't help -- but maybe it will inspire something. Last year I helped a friend who wanted to send floats through serial commands. I used my standard parser to get the chunks out of the string, and then this simple code to convert values from string to float. It doesn't support scientific notation though.
Thanks @JonnyMac, this does look like will help.
tokenizer seems to work.
Zero based token index.
Seems rigged to tokenize on white space.
got the input parsed into three strings now.
Close to having it done...
Actually want to process input from two serial ports. Don't want to waste cogs though.
Fortunately, found the @"Stephen Moraco" 8x serial input code in OBEX:
https://obex.parallax.com/obex/p2-high-speed-8-port-serial-subsystem/
You probably have this sorted, but I knocked this together while having lunch and waiting on the Zoom call. It will take a "parameter=value" string and breaks up the parts, filling strings you specify.
I almost have parsing an FP string in Scientific notation working.
This gets a little long, but -- so far -- seems to work. I added the ability to detect sci-notation and deal with the exponent. I checked the return values using this page:
-- https://www.h-schmidt.net/FloatConverter/IEEE754.html
For this app, there's a very limited range of exponents possible.
So, just did significand and exponent separately.
Also, turning this Torr floating point value into integer number of milliTorr....
Processed exponent like this:
Cool.