Thank you for this information. I will have to do some reading and
experimenting with udev and symlinks over the next few days.

Interesting that you mention this in the context of a BBB self-test,
because a PCBA factory functional test fixture is exactly the application
I'm working on right now.

--
Don Pancoe, P.E.
Industrial Designer, Electrical Engineer
DonPancoe.com <http://donpancoe.com/>


On Tue, Apr 21, 2020 at 10:14 AM Jason Kridner <[email protected]>
wrote:

>
>
> On Tue, Apr 21, 2020 at 9:02 AM Don Pancoe <[email protected]> wrote:
>
>> Hello all,
>>
>> I have been successfully using a barcode scanner / keyboard emulator with
>> python on a BBB thanks to the evdev library (
>> https://python-evdev.readthedocs.io/en/latest/) recommended by Drew
>> Fustini.
>>
>> However, when I run the main program with crontab instead of from a
>> console (I want to eliminate the need to have a laptop at the workstation),
>> the barcode scanner no longer works. I suspect it has something to do with
>> with the /dev/input path to the device being different in that
>> environment, but I'm not entirely sure.
>>
>> I've done some searching and reading into this but haven't found the
>> magic answer yet. I've not yet even been able to connect a console to the
>> instance that was spawned by crontab to see what's going on inside of it.
>>
>> Any guidance appreciated, including pointing me to resources to work
>> through myself.
>>
>
> I've been using C, not Python, but I do launch my program from a udev
> rule, which should be comparable to being launched from crontab. I do a bit
> more in the udev rules (
> https://github.com/jadonk/beagle-tester/blob/master/beagle-tester.rules)
> to actually create a symlink for the barcode scanner that I then use in my
> C program:
>
> KERNEL=="event*", ATTRS{idVendor}=="05fe", ATTRS{idProduct}=="1010",\
> SYMLINK+="input/beagle-barcode", TAG+="systemd",\
> ENV{SYSTEMD_WANTS}="beagle-tester.service"
> KERNEL=="event*", ATTRS{idVendor}=="05f9", ATTRS{idProduct}=="2204",\
> SYMLINK+="input/beagle-barcode", TAG+="systemd",\
> ENV{SYSTEMD_WANTS}="beagle-tester.service"
> KERNEL=="event*", ATTRS{idVendor}=="067e", ATTRS{idProduct}=="0801",\
> SYMLINK+="input/beagle-barcode", TAG+="systemd",\
> ENV{SYSTEMD_WANTS}="beagle-tester.service"
> KERNEL=="event*", ATTRS{idVendor}=="0c2e", ATTRS{idProduct}=="0901",\
> SYMLINK+="input/beagle-barcode", TAG+="systemd",\
> ENV{SYSTEMD_WANTS}="beagle-tester.service"
> KERNEL=="event*", ATTRS{idVendor}=="05f9", ATTRS{idProduct}=="2206",\
> SYMLINK+="input/beagle-barcode", TAG+="systemd",\
> ENV{SYSTEMD_WANTS}="beagle-tester.service"
> KERNEL=="event*", ATTRS{idVendor}=="24ea", ATTRS{idProduct}=="0197",\
> SYMLINK+="input/beagle-barcode", TAG+="systemd",\
> ENV{SYSTEMD_WANTS}="beagle-tester.service"
>
>
> You can see I also use the insertion of the barcode scanner to startup the
> beagle-tester.service (
> https://github.com/jadonk/beagle-tester/blob/master/beagle-tester.service
> ):
>
> [Unit]
> Description=Beagle Self-test
> Requires=dev-input-beagle\x2dbarcode.device
> BindsTo=dev-input-beagle\x2dbarcode.device
> [Service]
> ExecStart=/usr/sbin/beagle-tester
>
> In my C program (
> https://github.com/jadonk/beagle-tester/blob/master/beagle-tester.c#L3119),
> I just open up the symlink:
>
> int barcode = open("/dev/input/beagle-barcode", O_RDONLY);
> The path shouldn't change based on if you invoke the program from the
> console or by a crontab, but it could change due to adding/removing input
> devices. I suggest you look at my udev-rule + systemd method of invocation
> and see if that makes it more stable. The VID/PID entries in the udev rules
> are based on which barcode scanners I've used/tested. You can make a more
> generic rule to try to catch more input devices.
>
> Note, these rules come pre-installed on the Debian images, so they might
> actually be getting in your way already! We use these in production tests
> of the boards.
>
>
>
>> --
>> Don Pancoe, P.E.
>> Industrial Designer, Electrical Engineer
>> DonPancoe.com <http://donpancoe.com/>
>>
>> --
>> 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].
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/beagleboard/CAP3tSUPTTQn7bZ_M53vRGzbdKgeSzefu_%2BDvTT4gDLE5rSp14A%40mail.gmail.com
>> <https://groups.google.com/d/msgid/beagleboard/CAP3tSUPTTQn7bZ_M53vRGzbdKgeSzefu_%2BDvTT4gDLE5rSp14A%40mail.gmail.com?utm_medium=email&utm_source=footer>
>> .
>>
>
>
> --
> https://beagleboard.org/about - a 501c3 non-profit educating around open
> hardware computing
>
> --
> 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].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/beagleboard/CA%2BT6QPkSbPjvEXY_HXHUC90%3Dek0EX2YO6JYG_2MszpfcP%3DY5fA%40mail.gmail.com
> <https://groups.google.com/d/msgid/beagleboard/CA%2BT6QPkSbPjvEXY_HXHUC90%3Dek0EX2YO6JYG_2MszpfcP%3DY5fA%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>

-- 
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].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/beagleboard/CAP3tSUMCo6OKUwVe4RfBK7LRcUtUvWGZwkBVWfrqp3iKAAWFZQ%40mail.gmail.com.

Reply via email to