String Conversion Issues

For general Flowcode discussion that does not belong in the other sections.
Post Reply
User avatar
p.erasmus
Posts: 434
http://meble-kuchenne.info.pl
Joined: Thu Dec 03, 2020 12:01 pm
Location: Russia / Россия
Has thanked: 104 times
Been thanked: 88 times

String Conversion Issues

Post 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 655 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 655 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 655 times
Appreciate all help pointers as always :)

Peter
Regards Peter - QME Electronics

mnfisher
Valued Contributor
Posts: 1024
Joined: Wed Dec 09, 2020 9:37 pm
Has thanked: 107 times
Been thanked: 532 times

Re: String Conversion Issues

Post 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

User avatar
p.erasmus
Posts: 434
Joined: Thu Dec 03, 2020 12:01 pm
Location: Russia / Россия
Has thanked: 104 times
Been thanked: 88 times

Re: String Conversion Issues

Post by p.erasmus »

Thanks Martin will give it a try ,
These are the functions I am using FloatToString$)


Tahnks a million
Regards Peter - QME Electronics

Post Reply