Problem with reading negative values


#1

I’m using the Exosite Ready code with the WCM dev kit. I have modified the Microchip demo code to work with a custom application. I’m seeing a null string when I try to read an integer datapoint with a negative value from the cloud. Integers with a positive value read properly.

For example, I have a data point with the alias “diffOff” and a value of -1. I verify the read status is ERR_SUCCESS, but the string returned by the callback “static void on_read(int status, const char *alias, const char *value)” pointed to by value is ‘\0’. If I look at value + 1, I see “iffOff=-136.0” which looks like it received the proper reply (with some older data that wasn’t overwritten) but it didn’t properly handle the payload size (looks like it treated it as payload size 0). Of the 13 integer values I am trying to read the 11 positive values read correctly, but the 2 negative values both return a null string.


#2

Thanks for posting this and sorry you are running into this issue. I’ve pointed the ExositeReady SDK team at this to see if they can verify your issue, it sounds like it is not handling the URL decode properly for a negative value.


#3

Any update on this? It’s been almost a week and I need to get an updated demo in front of a customer. Currently, this is the only unresolved issue on the demo.


#4

There is a commit made on a ‘develop’ branch for the SDK. The change was made here:

This hasn’t been merged yet. Can you test out this change?
thanks,
-Mike


#5

Yes. I’ll let you know the results.

Thanks!


#6

I verified the fix resolves the issue.

Thanks for your help.


#7

I ran into a second issue that I think is related to the negative number handling. When I have a cloud float value between 0 and 1 (my value was set to 0.125), on_read returns 0. When I changed the value to 1, it returned the expected value. I’m guessing that it sees the leading zero and stops reading the string before seeing the decimal point. Can you verify this?


#8

Now that I’ve looked at it a little closer, It looks like it is ignoring the decimal point and any digits after, so it’s essentially rounding down any value I read from the cloud to an integer.


#9

Try this update: https://github.com/exositeready/er_sdk/commit/6ca60ff8ede71b58f7980ddfe49745fb82ce6b61
It’s still on develop branch. If there are any special characters in the string, it’ll pass it back as URL encoded right now and you’d have to decode in your application.