String comparison esp32

Any bugs you encounter with Flowcode should be discussed here.
Post Reply
mnfisher
Valued Contributor
Posts: 2179
http://meble-kuchenne.info.pl
Joined: Wed Dec 09, 2020 9:37 pm
Has thanked: 177 times
Been thanked: 1021 times

String comparison esp32

Post by mnfisher »

This had me scratching my head...

The Compare$ function on esp32 seems to return the wrong value.

So > returns 1, = returns 0 - but < doesn't return -1. It seems to return 255 (returns a signed byte? - but it doesn't get sign extended if assigned to an int, and FC a byte is unsigned (0..255))

The attached demonstrates - looking in CAL_STRING - Compare returns a MX_UINT8 (unsigned!) Changing this to an MX_SINT8 (or other signed type) should resolve this...

Martin
Attachments
comapre_test.fcfx
(10.35 KiB) Downloaded 178 times
(view online)

Steve-Matrix
Matrix Staff
Posts: 2032
Joined: Sat Dec 05, 2020 10:32 am
Has thanked: 306 times
Been thanked: 471 times

Re: String comparison esp32

Post by Steve-Matrix »

Yes, there is an issue we are aware of. I raised it recently here:
viewtopic.php?p=23402#p23402

I've asked Ben if it's worth making the change you have suggested. It should be ok, but there may be projects that are specifically looking for a return of 255 which would become broken if we made is change.

mnfisher
Valued Contributor
Posts: 2179
Joined: Wed Dec 09, 2020 9:37 pm
Has thanked: 177 times
Been thanked: 1021 times

Re: String comparison esp32

Post by mnfisher »

Thanks - I missed that post....

However - the tooltips (for example calculation-Function$) - show '-1' for less than - and simulation also returns -1 making the transfer to hardware more difficult?

Martin

Steve-Matrix
Matrix Staff
Posts: 2032
Joined: Sat Dec 05, 2020 10:32 am
Has thanked: 306 times
Been thanked: 471 times

Re: String comparison esp32

Post by Steve-Matrix »

I agree. The simulation has always used "-1" and on the face of it, it appears to be a bug in the CAL code. But we have to be careful when changing that because it can cause problems with existing projects which is why I didn't want to make the change without a wider internal discussion.

BenR
Matrix Staff
Posts: 2305
Joined: Mon Dec 07, 2020 10:06 am
Has thanked: 637 times
Been thanked: 847 times

Re: String comparison esp32

Post by BenR »

Thanks for letting us know and flagging the issue again.

I've rolled out the fix now so that v10 and v11 should now correctly return -1 instead of 255.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - My YouTube Channel

mnfisher
Valued Contributor
Posts: 2179
Joined: Wed Dec 09, 2020 9:37 pm
Has thanked: 177 times
Been thanked: 1021 times

Re: String comparison esp32

Post by mnfisher »

Thanks Steve/Ben,

Just tested - and there is sill a 255 lurking at line 517.

Martin

BenR
Matrix Staff
Posts: 2305
Joined: Mon Dec 07, 2020 10:06 am
Has thanked: 637 times
Been thanked: 847 times

Re: String comparison esp32

Post by BenR »

Aha good spot thanks, not sure how that one slipped through :D

Should be fully resolved now.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - My YouTube Channel

mnfisher
Valued Contributor
Posts: 2179
Joined: Wed Dec 09, 2020 9:37 pm
Has thanked: 177 times
Been thanked: 1021 times

Re: String comparison esp32

Post by mnfisher »

Thanks - just tested and all seems good now :-)

Post Reply