Problem with uint16_t ZBRxIoSampleResponse::getAnalog

48 views
Skip to first unread message

Andrew Ragusa

unread,
Mar 31, 2010, 9:48:34 PM3/31/10
to xbee-api
Hi

I think I found a bug with the uint16_t ZBRxIoSampleResponse::getAnalog function

I noticed that if pin1 is not enabled for Analog that the returned by
this function is off by 1 pins worth of data. When pin 1 is enabled
everything worked fine. I finally noticed that this for loop has a
problem.

for (int i = 0; i < pin; i++) {
if (isAnalogEnabled(pin)) {
start+=2;
}
}

Instead of checking isAnalogEnabled(pin) it should be
isAnalogEnabled(i). If you have an analog ping enabled that is
greater than an analog pin that is disabled, this will cause all
enabled pins afterward to be returned incorrectly.

Let me know if i missed something, but I'm pretty sure that is a needed change.

--
AJ Ragusa

andrew

unread,
Mar 31, 2010, 10:54:37 PM3/31/10
to xbee-api
Hi, I just committed an update to fix this. It was also occurring for
series 1. Thanks for reporting.

Andrew Ragusa

unread,
Mar 31, 2010, 11:16:02 PM3/31/10
to xbee...@googlegroups.com
I guess I have another question as well, in your ZBRxIoSample_example code

for (int i = 0; i <= 4; i++) {
if (ioSample.isAnalogEnabled(i)) {
nss.print("Analog (AI");
nss.print(i, DEC);
nss.print(") is ");
nss.println(ioSample.getAnalog(i), DEC);
}
}

the case statement of the for loop should be

i<4

because we start at 0, and I believe a check for pin 7 should also be
in there because pin 7 may return the supply voltage for the XBee. I
don't think this matters as much, but it would be useful to prevent
confusion, and document the supply voltage part.

A.J.

> --
> You received this message because you are subscribed to the Google Groups "xbee-api" group.
> To post to this group, send email to xbee...@googlegroups.com.
> To unsubscribe from this group, send email to xbee-api+u...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/xbee-api?hl=en.
>
>

--
AJ Ragusa
ara...@indiana.edu
812-606-8516

Paolo Di Prodi

unread,
Apr 1, 2010, 4:04:59 AM4/1/10
to xbee...@googlegroups.com
Yes very good guys,
when I was polling the IO i was getting a nice null value after analog pin 0, well done!

Reply all
Reply to author
Forward
0 new messages