Parsing ASCII data into an array
I am using the P2 to create a multi interface remote control terminal. It communicates with an ammeter using RS-232 that uses ASCII SCPI commands. I'm using a 1V 1kohm test just so I have some accurate data to work with. The flow is quite simple; The code sends in CONF:CURR:DC and READ? and the ammeter will send back +9.99538E-04. Except these are hex ASCII chars and I can't seem to parse out and format the number so I can use it for math and follow on communication. Additionally, I am using a Nextion NX8048P070_011 as the HMI for this. I need to be able to update either a text box or Xfloat with it for the user. This is done with an exact string statement like Current.val=####. The terminator for the RS-232 is a CR and for the nextion is an $FF. I am using a modified for my application version of jm_serial_bridge, which uses jm_fullserialduplex and jm_nstr. Using
I can send the entirety of the data to the PST and see the +9.99538E-04, I put a mask on the receive to get rid of the + and . , but I am at a complete loss for iterating the numbers into the desired array such as 9995.
I am just kind of at a deadend and I don't see the way forward. I've been in the P2 language documentation and on the OBEX looking for something that could point to a method or object that will handle this data. The code doesn't have a lot of attempts that I've tried already such as iterating a temp variable d[i] in an attempt to store each byte because those attempts got me further from what I am trying to do. Any help or direction is greatly appreciated.