New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NexNumber setValue, getValue not working correctly #36

Open
PaulChristopher opened this Issue Jan 22, 2017 · 1 comment

Comments

Projects
None yet
2 participants
@PaulChristopher

PaulChristopher commented Jan 22, 2017

MCU: Arduino ATMEGA 2560
Editor: V0.43
Library: V0.9.0

See attached test case: setValue and getValue do not work correctly for values bigger than 32767 on 8 bit systems.

To make at least setValue work correctly, I had to change NexNumber.cpp line 36 from 'utoa' to 'ultoa'. All in all, I am wondering if in setValue the size of the variable 'buffer' is big enough. The max value of uint32_t is supposed to be 4294967296. These are already 10 digits, and the string previx "obj.val=" is still missing. So 'buffer[10]' seems to be far too small and we are risiking a buffer overflow, aren't we?

With the above changes, I could make at least setValue work. But getValue still does not work although the code in NexHardware.cpp recvRetNumber, line 45 seems to be correct and ready for 4 byte uint32_t's. What's going on on the Nextion display side?

testNextionNumberBox.zip

@DrStein99

This comment has been minimized.

Show comment
Hide comment
@DrStein99

DrStein99 Jul 12, 2017

I would also like to add, that the NUMBER class on the device, I tested - works with SIGNED integers. Consider change to signed integer.

bool NexNumber::setValue(int32_t number)
sprintf(buf, "%03i", number);

DrStein99 commented Jul 12, 2017

I would also like to add, that the NUMBER class on the device, I tested - works with SIGNED integers. Consider change to signed integer.

bool NexNumber::setValue(int32_t number)
sprintf(buf, "%03i", number);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment