> -----Original Message----- > From: Michael Welling [mailto:mwelling79@xxxxxxxxx] On Behalf > Of Michael Welling > Sent: Thursday, August 20, 2015 12:23 PM > To: Greg Wilson-Lindberg > Cc: Daniel Baluta; linux-iio@xxxxxxxxxxxxxxx > Subject: Re: BBB IIO ADC access not working > > On Thu, Aug 20, 2015 at 11:41:03AM -0700, Greg Wilson-Lindberg wrote: > > > > > > > -----Original Message----- > > > From: Michael Welling [mailto:mwelling79@xxxxxxxxx] On Behalf Of > > > Michael Welling > > > Sent: Thursday, August 20, 2015 10:31 AM > > > To: Greg Wilson-Lindberg > > > Cc: Daniel Baluta; linux-iio@xxxxxxxxxxxxxxx > > > Subject: Re: BBB IIO ADC access not working > > > > > > On Thu, Aug 20, 2015 at 10:27:30AM -0700, Greg > Wilson-Lindberg wrote: > > > > > > > > > > > > > -----Original Message----- > > > > > From: Greg Wilson-Lindberg > > > > > Sent: Thursday, August 20, 2015 9:19 AM > > > > > To: 'Michael Welling' > > > > > Cc: Daniel Baluta; linux-iio@xxxxxxxxxxxxxxx > > > > > Subject: RE: BBB IIO ADC access not working > > > > > > > > > > > > > > > > > > > > > -----Original Message----- > > > > > > From: Michael Welling [mailto:mwelling79@xxxxxxxxx] On > > > Behalf Of > > > > > > Michael Welling > > > > > > Sent: Thursday, August 20, 2015 9:14 AM > > > > > > To: Greg Wilson-Lindberg > > > > > > Cc: Daniel Baluta; linux-iio@xxxxxxxxxxxxxxx > > > > > > Subject: Re: BBB IIO ADC access not working > > > > > > > > > > > > On Thu, Aug 20, 2015 at 08:50:28AM -0700, Greg > > > > > Wilson-Lindberg wrote: > > > > > > > > > > > > > > > > > > > > > > -----Original Message----- > > > > > > > > From: Michael Welling [mailto:mwelling79@xxxxxxxxx] On > > > > > Behalf Of > > > > > > > > Michael Welling > > > > > > > > Sent: Wednesday, August 19, 2015 2:43 PM > > > > > > > > To: Greg Wilson-Lindberg > > > > > > > > Cc: Daniel Baluta; linux-iio@xxxxxxxxxxxxxxx > > > > > > > > Subject: Re: BBB IIO ADC access not working > > > > > > > > > > > > > > > > On Wed, Aug 19, 2015 at 02:34:39PM -0700, Greg > > > > > > Wilson-Lindberg wrote: > > > > > > > > > > > > > > > > > > So, in that case, can I just open it once and > > > leave it open? > > > > > > > > > > > > > > > > Yes. > > > > > > > > > > > > > > > > > Is it reading from a buffer, or is it reading what is > > > > > > > > current in the ADC? > > > > > > > > > > > > > > > > It is the current reading. > > > > > > > > > > > > > > > > > Can I just set up a timer to get readings to > average then? > > > > > > > > > > > > > > > > Sure. > > > > > > > > > > > > > > > > Here are some helper functions: > > > > > > > > > > > > > > > > int iio_adc_open_channel(int dev_num, int chan_num) { > > > > > > > > char filename[255]; > > > > > > > > > > > > > > > > sprintf(filename, > > > > > > > > "/sys/bus/iio/devices/iio:device%d/in_voltage%d_raw", > > > > > > > > dev_num, chan_num); > > > > > > > > > > > > > > > > return open(filename, O_RDONLY); } > > > > > > > > > > > > > > > > int iio_adc_read_channel(int fd) { > > > > > > > > int count; > > > > > > > > char buffer[255]; > > > > > > > > int value = -1; > > > > > > > > > > > > > > > > lseek(fd,0,SEEK_SET); > > > > > > > > > > > > > > > > count = read(fd, buffer, 255); > > > > > > > > > > > > > > > > if (count > 0) > > > > > > > > value = strtoul(buffer, NULL, 10); > > > > > > > > > > > > > > > > return value; > > > > > > > > } > > > > > > > > > > > > > > > > Example usage: > > > > > > > > > > > > > > > > int fd; > > > > > > > > . > > > > > > > > . > > > > > > > > > > > > > > > > fd = iio_adc_open_channel(0, 4); . > > > > > > > > . > > > > > > > > > > > > > > > > while (1) > > > > > > > > { > > > > > > > > printf("ADC = %x\n", > iio_adc_read_channel(fd)); } > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > I converted to using this interface and left the > > > system running > > > > > > > overnight and the touch screen was locked up this morning. > > > > > > > > > > > > This is without any modifications to the kernel? > > > > > > > > > > > > > > > > This was still running the kernel modifications. I've > > > restarted it > > > > > this morning without the kernel modifications. > > > > > > > > I just dumped what I'm reading from the sys fs and all I'm > > > getting back is -1. > > > > > > Are you doing error checking on the file descriptor on open? > > > > > > > > > > > You were right, I had gone back to the original kernel that RCN > > shipped with the image and it doesn't export /sys/bus/iio. > > > > I rebuilt the 3.14.49-ti-r62 kernel, which is the same > release as the kernel in the image, but it does export > /sys/bus/iio, so that much is working better. > > > > But (there's always a but, isn't there), I'm reading three channels > > from the ADC, 4, 5, & 6. Channel 4 gets a good reading maybe 60% of > > the time I read it. Channel 5 gets a good reading maybe > every 40-50 tries. Channel 6 hardly ever gets a good reading. > > > > I guess I could just loop if I get a busy response, > although I don't > > know how many times I will get that return before I get a > good reading. > > > > What is the indicator that the reading is bad? > I get back -1 if the channel is busy. I just put in a loop and for channel 4 I get either 1 or 2 tries to get a good sample. Channels 5 & 6 are always returning a good sample on the second read. I'll have to leave this on for overnight to see if the touch screen will lock up. -- To unsubscribe from this list: send the line "unsubscribe linux-iio" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html