Well, I'll probably write up a quick blog post on it tomorrow. So I can link it to others when / if needed to. How i setup the ADC and all that. In the mean time, you can read the last 5 posts I've made here: http://www.embeddedhobbyist.com/ . . .let me look . . .
Beaglebone black – Setup / customization guide which is actually very brief( I wanted to write more, but didnt have the time ) covers how to disable systemd. HOWEVER, I'd test with systemd, and maybe without. It may very well have no impact on code execution. I've disabled it because I'm used to the "old school" sysv init daemon. Beaglebone black – Updating device tree files is pretty close to an exact steps of how to upgrade to a newer kernel, and then recompile the peripheral device tree files. On Tue, Sep 29, 2015 at 10:53 PM, Rathin Dholakia <[email protected]> wrote: > Dear William, > > Amazing, i m awed by your rigorous treatment of the topic :-) and as you > said I ran a test of that program, which proved that you are correct!! the > program ( mine one) is taking 10.2% to 11% of CPU!! which proves that its > in blocking mode. > and I am not aware of O_NONBlOCK and mmap.. I will read it up and see but > for that do you recommend and preferred resources? > > and thanks for the code I will run it and let you know. but there are few > hick ups: > 1. My *uname -a out put is : *Linux beaglebone 3.8.13-bone72 #1 SMP Tue > Jun 16 21:36:04 UTC 2015 armv7l GNU/Linux > > > 2. your kernel has preemption i.e.. it is RT patched / enabled: mine is > not!! > > *So are you using official Debian image & patched it or r you using some > other image?* > > 3. I dont know how to turn off systemd? > can you guide me!! > > Once again thanks a LOT!! :-) > > On Wednesday, September 30, 2015 at 11:11:34 AM UTC+5:30, William Hermans > wrote: >> >> So, I got bored, and decided to do some "screwing around". But took me a >> while because I had not used, or setup the ADC peripheral before, but . . . >> here is some quick and dirty code, using std API stuff - Which breaks all >> the rules I spoke of in my second post heh. But still pretty darned fast. >> I'd be happier if I could use mmap() directly on >> /sys/bus/iio/devices/iio:device0/in_voltage0_raw, but either I've been >> trying to use an improper mode of operation. Or mmap() on that file >> location is not supported. So, might be forced to use mmap() on /dev/mem . >> ..ug! >> >> #include <unistd.h> >>> #include <sys/stat.h> >>> #include <fcntl.h> >>> #include <stdio.h> >>> #include <errno.h> >>> #include <stdlib.h> >>> >>> void read_adc(int fd) >>> { >>> char adc[5] = {0}; >>> int len = read(fd, adc, sizeof(adc - 1)); >>> adc[len] ='\0'; >>> printf("%s ", adc); >>> } >>> >>> int main() >>> { >>> const char *fname = >>> "/sys/bus/iio/devices/iio:device0/in_voltage0_raw"; >>> int count = 0; >>> >>> while( count++ <= 1000){ >>> int fd = open(fname, O_CREAT | O_RDONLY); >>> if(fd == -1){ >>> printf("error: %s\n", strerror(errno)); >>> exit(1); >>> } >>> >>> if(count % 15 == 0 && count != 0) >>> printf("\n"); >>> >>> read_adc(fd); >>> >>> close(fd); >>> } >>> printf("\n"); >>> >>> return 0; >>> } >>> >> >> Output: >> debian@beaglebone:~$ time ./test >> 4016 4020 4007 4010 4008 4010 4005 4005 4013 4015 4015 4011 4008 4001 >> 4010 4006 4006 4011 4007 4011 4003 4009 4006 4005 3995 3999 4005 4000 3997 >> 4008 4016 4009 3997 4008 4011 4013 4011 4012 4009 4006 3997 4007 4007 3999 >> 4014 4014 4007 4015 4008 4011 4012 4012 4007 4013 4016 4017 4016 4016 4013 >> 4006 4013 4015 4006 4013 4009 4003 4011 4011 4017 4015 4008 4005 3998 4000 >> 4002 4011 4012 4010 4013 4009 4010 4010 4010 4010 4011 4008 4007 4007 4007 >> 4013 3998 4006 4007 4003 3999 4009 4005 4013 4018 4019 4014 4012 4003 4008 >> 4010 4017 3999 4002 4008 4008 4008 4004 4010 4008 3996 4002 4009 4014 4011 >> 4012 4006 4007 4004 4000 4008 4008 4010 4008 4007 4006 4003 4007 4000 4008 >> 4003 4010 4003 4006 4006 3996 4001 4003 4000 4002 3996 4007 4003 4011 4013 >> 4012 4017 4013 4008 4002 4010 4005 4013 4016 4014 4012 4015 4013 4013 4007 >> 4011 4008 4010 4014 4016 4016 4015 4018 4013 4016 4005 3997 4007 3998 4007 >> 4002 4004 4009 4007 4010 4010 4001 4005 4008 4003 4010 4012 4013 4006 3994 >> 4014 4006 4008 4009 4014 4015 4012 4012 4013 4010 4012 4014 4015 4020 4017 >> 4017 4013 4010 4020 4014 4012 4010 4008 3997 4002 4001 4012 4010 4006 4016 >> 4010 4004 4004 4004 4003 4004 4004 3999 4003 4007 4008 4006 4005 4006 4007 >> 4013 4013 4011 4010 4010 4005 3996 4002 4008 4012 4012 4007 4006 4000 3999 >> 4009 4005 4013 4010 4008 4012 4011 4015 4016 4017 4013 4009 4008 4007 4006 >> 4015 4012 4010 4013 4011 4016 4012 4013 4012 4009 4007 3998 3995 3998 4004 >> 4003 4011 4009 4001 3998 4007 4008 4001 4008 4008 4012 4013 4007 3998 3999 >> 4015 4007 3997 4005 4009 4007 4002 4009 4015 4012 4007 4009 4013 4017 4015 >> 4010 4005 4011 4017 4015 4010 4013 4012 4004 4008 4012 4010 4014 4015 4013 >> 4016 4016 4016 4007 4009 4011 4010 4009 4010 4010 4004 4004 4002 4002 4011 >> 4008 4007 4004 4010 4006 4008 4007 4005 4006 4008 4002 4009 4013 4011 4006 >> 4010 4015 4014 4016 4018 4015 4017 4015 4015 4018 4016 4013 4011 4013 4016 >> 4017 3998 4012 4006 4008 4014 4011 4003 4012 4018 4014 4012 4005 3994 4000 >> 4004 4003 4007 4012 4012 4005 4005 4006 4008 4001 3999 4004 4000 4004 4000 >> 4011 4010 4005 4002 4009 4007 4002 4013 4015 4020 4012 4011 4011 4002 4011 >> 4008 4013 4009 4012 4006 4011 4009 4015 4013 4009 4003 4008 4003 4005 4009 >> 4017 4001 4010 4012 4009 4009 4007 4010 4007 4006 4004 4003 4008 4008 4003 >> 4012 4009 4007 4008 4005 4006 4000 3995 4000 4007 4006 4003 4004 4009 4004 >> 4008 4020 4010 4009 4006 4008 4015 4018 4017 4011 4014 4013 4010 4009 4012 >> 4011 4009 4016 4017 4016 4011 4005 4007 4012 4014 4014 4005 4004 3998 4000 >> 4009 4009 4005 3996 4006 3999 4002 4009 4014 4011 4009 4008 4008 4012 4013 >> 4003 4007 4010 4012 4012 4010 4010 4010 4014 4017 4016 4007 4020 4013 4007 >> 4019 4015 4014 4016 4016 4016 4009 4004 4000 4009 4012 4010 4015 4015 4015 >> 4016 4011 4013 4008 4012 4009 4007 4006 4005 4006 4012 4004 4011 4015 4009 >> 4010 4014 4004 3998 4008 4010 4004 4003 4008 4013 4013 4009 4007 4004 4009 >> 4014 4013 4016 4012 4010 4011 4013 4013 4013 4008 4017 4015 4015 4011 4014 >> 4016 4007 4013 4014 4009 3999 4008 4003 4005 4009 4014 4007 4003 3993 3999 >> 3999 4005 4013 4003 4011 4009 4011 4010 4006 4002 4006 3998 4001 4003 4009 >> 4011 4011 4016 4013 4018 4013 4010 4003 4000 4006 4015 4011 4017 4017 4016 >> 4010 4017 4017 4016 4012 4016 4015 4013 4012 4013 4009 4003 4010 4006 4012 >> 4004 4013 4001 4000 4005 3997 4004 4008 4012 4008 4005 3996 4003 3999 4006 >> 4016 4002 4000 4002 4008 4009 4006 3995 4005 4008 4013 4012 4012 4009 4007 >> 4013 4006 4018 4012 4005 4016 4014 4012 4011 4007 4014 4016 4015 4014 4013 >> 4005 4007 4013 4008 4009 4002 4012 4011 4015 4013 4012 4010 4004 4007 4005 >> 4013 4008 4013 4014 4014 4004 4012 4012 4012 4007 4009 4006 4010 4013 4014 >> 4015 4006 4008 4009 4007 4004 4011 4005 4009 4007 4020 4015 4012 4005 4008 >> 4021 4018 4016 4013 4003 4015 4015 4019 4014 4013 4003 4007 4009 4014 4015 >> 3999 4016 4007 4008 4004 4008 4011 4003 4011 4012 4009 4006 4009 4008 4005 >> 4002 4005 4011 4008 4011 4009 4016 4014 4010 4012 4016 4015 4011 4010 4009 >> 4010 4011 4019 4018 4015 4017 4010 4000 4009 4015 4017 4017 4013 4017 4012 >> 4011 4016 4014 3999 4008 4006 4006 4011 4010 4001 4000 4008 3998 4007 4013 >> 4008 4007 4011 4008 4011 4007 4013 4012 4014 4009 4006 4006 4007 4000 4002 >> 4012 4011 4008 4010 4004 4015 4013 4015 4014 4006 4019 4012 4007 4016 4016 >> 4005 4009 4011 4010 4010 4004 4013 4014 4015 4015 4016 4011 4014 4009 4004 >> 4015 4013 4009 4011 4009 4009 4006 4008 4005 3995 4001 4007 4007 4008 4008 >> 4008 4008 4004 4006 4011 4010 4002 4011 4013 4009 4003 4000 4006 4011 4010 >> 4015 4020 4016 4017 4017 4016 4016 4015 4014 4013 4010 4012 4006 4002 4000 >> 4017 4016 4013 4010 4013 4008 4011 4010 4006 4002 4007 4009 4010 4011 4007 >> 4011 4012 4014 4003 4003 4012 4010 4014 4013 4010 4007 3994 4000 4006 4002 >> 3999 4006 4004 4008 4011 4005 4005 4010 4008 4012 4014 4017 4015 4015 4001 >> 4011 4006 4015 4017 4013 4015 4014 4018 4016 4012 4011 4009 4011 4014 4015 >> 4008 4009 4009 4006 4011 4010 4008 4010 4005 4006 4005 4005 4009 4003 4009 >> 4008 4010 4011 4010 4012 4007 4009 4007 4000 4004 4008 4008 4013 4016 4017 >> 4019 4016 4021 4018 4018 4012 4009 4007 4015 4015 4012 4013 >> >> real 0m0.328s >> user 0m0.010s >> sys 0m0.250s >> >> >> That's actually not too bad for opening, and closing the file 1000 >> iterations, then using printf() to display the data to stdout. So, looks >> like 328ms for 1000 iterations on the same adc channel. >> >> debian@beaglebone:~$ uname -a >> Linux beaglebone 4.1.5-ti-rt-r10 #1 SMP PREEMPT RT Fri Aug 14 00:02:42 >> UTC 2015 armv7l GNU/Linux >> >> debian@beaglebone:~$ cat /etc/dogtag >> BeagleBoard.org Debian Image 2015-03-01 >> >> Meaning Wheezy 7.8, and systemd disabled - if the later maters at all. >> >> -- > For more options, visit http://beagleboard.org/discuss > --- > You received this message because you are subscribed to the Google Groups > "BeagleBoard" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > For more options, visit https://groups.google.com/d/optout. > -- For more options, visit http://beagleboard.org/discuss --- You received this message because you are subscribed to the Google Groups "BeagleBoard" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
