Open paynterf opened 4 years ago
Hi Frank. Did you get anywhere with this issue? I just had a look at the code also, and nothing stands out. But I can't say I understand the ins and outs of class logic and chaining. All I can think of atm is that it is because sinceLastCheckMsec
will return as a elapsedMillis
object, not as an unsigned long, hence the need to cast.
In order to be able to have any hope of reproducing the issue, what library are you using?
#include <print.h> //allows printf-style printout syntax
Anybody have any additional thoughts on this? I just spent two days chasing a bug which in the end was because I cast the result to (uint32_t) for a comparison and of course that had highly unpredictable results. An exceptionally useful code set otherwise!
Still none the wiser. It looks like the OP also tried to get some help on the Arduino forum, and they suggested it was either user error (i.e. giving the wrong format specifier to printf) or some obscure behaviour in the bowels of Arduino and Print libraries... https://forum.arduino.cc/t/printex-serial-printf-and-elapsedmillis-printing/670092/28
Another added complicated is that unsigned long is typically equialent to uint32_t
... but is not an absolute guarantee... I'm tempted to try switching this to uint32_t
instead of unsigning long
, and seeing what happens. First step will be to setup https://www.arduino.cc/reference/en/libraries/printex/ and try to reproduce the results, and then will see what happens...
I am having problems printing elapsedMillis object values to the serial port in Arduino avr code, and it appears that this is caused by the object not returning an unsigned long value. The following is a small program to illustrate the problem:
When this is run on an Arduino Mega, I get the following output:
I looked at the ellapsedMillis code, but I can't for the life of me see why a reference to an elapsedMillis object doesnt return an 'unsigned long' object, but I'm pretty sure that's what is happening. I use elapsedMillis objects a lot, and it would be nice if I didn't have to remember to always explicitely cast references to 'unsigned long'.
TIA
Frank