Page 1 of 1

String Conversion Issues

Posted: Sun Nov 06, 2022 2:29 pm
by p.erasmus
Hi All,
I am having 2 issues which I want to ask help please :oops:

I am reading in a string on the UART then I split the stings and take out the different strings and then convert the strings into float numbers

my problem is when the substring is a positive value it converts correctly however when the string contains a negative then it converts incorrect
example "001.10" Convert correctly as below


P3.JPG
P3.JPG (36.88 KiB) Viewed 1271 times
Here we can see the same sting now negative "-001.10" results in -429496xxx
What am I doing wrong :oops: The String RX_Data contains the string send by the instrument I am communicating with .RX_Data is declared as an String in FC.

P2.JPG
P2.JPG (34.17 KiB) Viewed 1271 times

I am also a bit confused in using that receive ByteArray macro from the UART component, I delare a byte array when I sue it in the macro parameters it generates an error as below Also here what am I doing wrong :oops:

P1.JPG
P1.JPG (93.09 KiB) Viewed 1271 times
Appreciate all help pointers as always :)

Peter

Re: String Conversion Issues

Posted: Sun Nov 06, 2022 3:43 pm
by mnfisher
Just pass:

ByteArrayData (not ByteArrayData[])

How are you converting the string top a float - seems correct in simulation using StringToFloat$() - am I alone in thinking some of these functions are misnamed - should be StringToFloat and FloatToString$)

Martin

Re: String Conversion Issues

Posted: Mon Nov 07, 2022 10:36 am
by p.erasmus
Thanks Martin will give it a try ,
These are the functions I am using FloatToString$)


Tahnks a million