ADC.setup() Prevents Python Program from Running at Autostart

118 views
Skip to first unread message

Tomas Medina

unread,
Sep 12, 2017, 1:35:33 PM9/12/17
to BeagleBoard

I am trying to write a program that reads the analog values of a sonar on the Beaglebone Black Wireless (Debian image 2017-07-01). The program runs fine if executed from the command line, but when I try to run it automatically at startup (using crontab), the program doesn't run at all (as indicated by a grep command). Here is the relevant code:

from time import sleep
import Adafruit_BBIO.ADC as ADC
ADC.setup()

while True:
    sonar = ADC.read(pin)
    print sonar
    sleep(.5)

Any help in this matter would be greatly appreciated.

Drew Fustini

unread,
Sep 12, 2017, 1:43:46 PM9/12/17
to Beagle Board

--
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 beagleboard+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/beagleboard/5caa2466-2fc0-44e3-a2a4-1ef707bac88d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Dennis Lee Bieber

unread,
Sep 12, 2017, 2:16:24 PM9/12/17
to beagl...@googlegroups.com
On Tue, 12 Sep 2017 12:43:26 -0500, Drew Fustini
<pdp7...@gmail.com> declaimed the following:

>Check out this example of how to run a script at startup:
>https://github.com/adafruit/adafruit-beaglebone-io-python/blob/master/doc/run_config-pin_during_startup.md
>
>On Sep 12, 2017 12:35 PM, "Tomas Medina" <to...@evatech.net> wrote:
>

>> from time import sleep
>> import Adafruit_BBIO.ADC as ADC
>> ADC.setup()
>> while True:
>> sonar = ADC.read(pin)
>> print sonar

I'd be concerned about that print statement... Where is stdout going
for a cron job?
--
Wulfraed Dennis Lee Bieber AF6VN
wlf...@ix.netcom.com HTTP://wlfraed.home.netcom.com/

Tomas Medina

unread,
Sep 12, 2017, 2:32:34 PM9/12/17
to BeagleBoard
I'm assuming you mean how I'm displaying the values. I'm not, but disabling the print statement didn't fix the problem.

Przemek Klosowski

unread,
Sep 12, 2017, 3:01:12 PM9/12/17
to beagl...@googlegroups.com
On Tue, Sep 12, 2017 at 2:15 PM, Dennis Lee Bieber <wlf...@ix.netcom.com> wrote:

        I'd be concerned about that print statement... Where is stdout going for a cron job?
 
Cron jobs aren't supposed to have output. If they do, it's mailed to the owner of the job, presumably because they contain error messages for debugging.

Mala Dies

unread,
Sep 12, 2017, 11:11:35 PM9/12/17
to BeagleBoard
Hello,

Run the CRON job with EDITOR=nano crontab -e and make sure you are root. I forget what it must take to become root in our new systems. By default, the Debian Stretch Distro does not place us in the root directory. sudo -i will do it!

Seth

Mala Dies

unread,
Sep 12, 2017, 11:12:53 PM9/12/17
to BeagleBoard
Oh and Medina,

You may need to set up all your code and software in the root folder to allow for direct action in your boot.

Seth

P.S. sudo -i

Mala Dies

unread,
Sep 13, 2017, 12:24:57 AM9/13/17
to BeagleBoard
Hello Medina,

Seth here, again. Oh and dude, you can also throw all that software into the Autorun folder on Cloud 9.

Seth

P.S. Just a reminder...if you use sudo -i, you can exit out by just typing exit. That will bring you to your debian@... or whatever your name is now. You would, before the exit cmd, be root@... and not debian@... or so on. 


On Tuesday, September 12, 2017 at 12:35:33 PM UTC-5, Tomas Medina wrote:

Tomas Medina

unread,
Sep 13, 2017, 12:33:12 PM9/13/17
to BeagleBoard
All my files are already in root. I disabled the security in my Beaglebone so I can log in with root and have administrative privileges by default. I already tried crontab and it didn't run. I prefer not to use Cloud9 due to its limitations. That being said, uploading a file to the autorun folder didn't work either.

Mala Dies

unread,
Sep 13, 2017, 7:41:01 PM9/13/17
to BeagleBoard
Okay...no issue. I hope things work out. If I come across the correct way to start a program/software on boot, I will let you know.

Seth

P.S. I read about it a while back but I came up empty with my current search. They have some Debian docs. on it. I will let you know if I come across it again.

Mala Dies

unread,
Sep 24, 2017, 9:27:52 PM9/24/17
to BeagleBoard
Hello Tomas,

I just listened to Fustini in this post, https://github.com/adafruit/adafruit-beaglebone-io-python/blob/master/doc/run_config-pin_during_startup.md, by starting a service and making two uart pins available to me on boot. 

Seth

P.S. I hope things are going well in your quest. BBB!


On Wednesday, September 13, 2017 at 11:33:12 AM UTC-5, Tomas Medina wrote:
Reply all
Reply to author
Forward
0 new messages