![]() |
Forum Index : Microcontroller and PC projects : Adding firmware version checks to programs
Author | Message | ||||
realmnm![]() Newbie ![]() Joined: 07/07/2020 Location: AustraliaPosts: 34 |
I tried to add a minimum firmware version check to my software and found that it doesn't work as well as I would have liked. This may just be floating point issue or ?I don't know what. Here is what I tried. dim MINFWVERSION as float dim CMM2VERSION as float MINFWVERSION=5.0505 CMM2VERSION=MM.INFO(VERSION) if CMM2VERSION < MINFWVERSION then print:print "Sorry, appear to be running firmware version "+str$(CMM2VERSION) print "You need to be running firmware version "+str$(MINFWVERSION)+" or higher.":print end endif Let me know your thoughts. Martin This signature intentionally left blank. |
||||
yock1960 Senior Member ![]() Joined: 18/08/2020 Location: United StatesPosts: 167 |
Have you tried subtracting one from the other to see if you get the expected result? Steve |
||||
CaptainBoing![]() Guru ![]() Joined: 07/09/2016 Location: United KingdomPosts: 2170 |
looks OK, fairly straightforward test what don't you like? what was the result of you running this? Need a bit more wood on the fire to help, print out the two variables so we can see what the If is working with. I do a similar thing on the Micromite/ArmiteF4/H7 paltform but I use the string form MM.DEVICE$. I am not familiar with the idiosyncrasies of the CMM2. Edited 2020-08-19 21:28 by CaptainBoing |
||||
Geoffg![]() Guru ![]() Joined: 06/06/2011 Location: AustraliaPosts: 3292 |
What is the problem? What is it that you "would have liked". Geoff Geoff Graham - http://geoffg.net |
||||
matherp Guru ![]() Joined: 11/12/2012 Location: United KingdomPosts: 10315 |
Just a standard floating point rounding issue Use MINFWVERSION=5.0504999999999 |
||||
realmnm![]() Newbie ![]() Joined: 07/07/2020 Location: AustraliaPosts: 34 |
That’s what I thought it might be. Thanks. This signature intentionally left blank. |
||||
realmnm![]() Newbie ![]() Joined: 07/07/2020 Location: AustraliaPosts: 34 |
Fireworks, Coins pouring out like I had won a Jackpot. ![]() This signature intentionally left blank. |
||||
mkopack73 Senior Member ![]() Joined: 03/07/2020 Location: United StatesPosts: 261 |
Yeah this, and a number of other “best practices” really should be used when writing programs for this computer. I’m starting to write these best practices up (literally started this morning) as a little book to help people write good, clean, portable and reusable code for the CMM2. |
||||
mkopack73 Senior Member ![]() Joined: 03/07/2020 Location: United StatesPosts: 261 |
To deal with the FP precision issue you could try to round it up to the nearest .000x before doing the comparison. |
||||
TassyJim![]() Guru ![]() Joined: 07/08/2011 Location: AustraliaPosts: 6283 |
if MM.INFO(VERSION) < (5.0505-0.0001) then print "too old" else print "All good" VK7JH MMedit |
||||
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |