Hilscher Community Forum
[SOLVED] USB Serial device mapping into Container - Printable Version

+- Hilscher Community Forum (https://forum.hilscher.com)
+-- Forum: netPI 3 - Docker featuring Industrial Raspberry Pi 3 platform (https://forum.hilscher.com/forum-1.html)
+--- Forum: Software (https://forum.hilscher.com/forum-5.html)
+--- Thread: [SOLVED] USB Serial device mapping into Container (/thread-312.html)

Pages: 1 2


[SOLVED] USB Serial device mapping into Container - hannes - August-24th-2018

Hello,

i have two USB serial devices and i want to use them in two containers. One device is a normal arduino uno and the other device is a zebra barcode scanner.
Now i tried to connect them and i dont see the /dev/ devices in my container. 

I used the following image: hilschernetpi/netpi-debian-stretch with privileged mode enabled. 

In "dmesg" i see the devices plugged in and discovered right, but no dev device.
How can i make it work?

I already looked into this thread: https://forum.hilscher.com/thread-158-page-3.html?

Do i have to map the devices manually into the container? And how can i discover the names of that devices to map them into the container.

Thanks in advance!
BR
Hannes


RE: USB Serial device mapping into Container - Armin@netPI - August-24th-2018

Hello Hannes,

one thing I have to mention here about using priviledge mode on netPI. On a standard Raspberry Pi utillizing Docker in mode "priviledged" ALL /dev devices are automatically mapped. Not so with netPI. netPI includes a special version Docker mapping not ALL available host devices into the container automatically. This is because of security reasons ... else you could easily get access to the netPI SD card drive and hack netPI's security software and root system. This is what we definitively not want.

So back to your problem. Yes indeed because of my explanation above you have to map the devices manually from the beginning and start of the container. Linux maps those units to host devices called /dev/ttyUSBx if they are serial port device and x for any next device starting with 0 then 1 etc.

So you have to insert the serial devices while netPI was booting. Then you have to map /dev/ttyUSB0 and /dev/ttyUSB1 and also the bus device /dev/bus.

This should work
Armin


RE: USB Serial device mapping into Container - hannes - August-24th-2018

(August-24th-2018, 09:34 AM)Armin@netPI Wrote: Hello Hannes,

one thing I have to mention here about using priviledge mode on netPI. On a standard Raspberry Pi utillizing Docker in mode "priviledged" ALL /dev devices are automatically mapped. Not so with netPI. netPI includes a special version Docker mapping not ALL available host devices into the container automatically. This is because of security reasons ... else you could easily get access to the netPI SD card drive and hack netPI's security software and root system. This is what we definitively not want.

So back to your problem. Yes indeed because of my explanation above you have to map the devices manually from the beginning and start of the container. Linux maps those units to host devices called /dev/ttyUSBx if they are serial port device and x for any next device starting with 0 then 1 etc.

So you have to insert the serial devices while netPI was booting. Then you have to map /dev/ttyUSB0 and /dev/ttyUSB1 and also the bus device /dev/bus.

This should work
Armin

Hi Armin,

i see. It make totally sense to not automap everything. 
I tried to map it the following way:

   

But when i try to map the devices in portainer i got the following error message:

   


I do it as you said. Plugged in the USB devices, restarted the netPI and then start a container with mapped USB devices.
What can we do next? 

BR
Hannes


RE: USB Serial device mapping into Container - Armin@netPI - August-24th-2018

Thank you for your fast reaply.

I followed to what you configured and everything is fine.

I googled a little bit about Zebra Scanner for example. What I found out was that USB it not always USB under Linux ... and how devices are supported by a kernel driver when the are connected to a USB even if they are based on a simple serial communication is not always the same under Linux.

Especially with a focus on Zebra I found out that this device is not mapped as ttyUSB device but as hidraw device (Human Interface Device) as stated here https://www.kernel.org/doc/Documentation/hid/hidraw.txt

Here comes now the point where I have doubts. You should start with the Zebra device only for a test because I don't know if netPI Linux kernel has included the hidraw kernel module driver included or not. But it is worth it to test. So start netPI with Zebra only, map /dev/bus and /dev/hidraw0 and see what happens then.

Thx
Armin


RE: USB Serial device mapping into Container - Armin@netPI - August-24th-2018

I googled for Arduino as well and found this interesting article here: https://rfc1149.net/blog/2013/03/05/what-is-the-difference-between-devttyusbx-and-devttyacmx/

It seems that Arduino apparently is mapped as /dev/ttyACM device and not as /dev/ttyUSB device.

So give it a try with /dev/ttyACM0.


RE: USB Serial device mapping into Container - hannes - August-24th-2018

Hi Armin,

thank you too for the fast reply.
I tried the following:

1.:
-Connected arduino
- Restarted netPI
- Try to map /dev/ttyACM0

=> not working with same error "no such file or directory /dev/ttyACM0

2.
- Connected Zebra scanner
- Restarted netPI
- Try to map /dev/hidraw0

=> also not working with the same error "no such device"

When i used both devices on other linux computers (debian) they appeared both as "ttyACMX". I dont know why it is not working here.
The driver of the scanner is one thing, but i think the arduino should work?!

BR
Hannes


RE: USB Serial device mapping into Container - Armin@netPI - August-24th-2018

Well maybe I can organize at least an Arduino here and give you feedback monday about what I found out.

Which version are you using?


RE: USB Serial device mapping into Container - Armin@netPI - August-24th-2018

And indeed the debian on netPI is not different of others ... all the same kernel... so if those devices really are mapping to ttyACMx I am afraid of that the kernel mode driver is not available in the current netPI firmware.

I will keep you informed.


RE: USB Serial device mapping into Container - hannes - August-24th-2018

Hey Armin,

that would be great.
This is my Firmware version:

   

BR
Hannes


RE: USB Serial device mapping into Container - Armin@netPI - August-24th-2018

Hello Hannes,

I have progress by the way.

Instead of an Arduino I used any other ACM compatible device from my stock and connected it to my netPI.

I switched on the privileged mode and mapped /dev/ttyACM0 device while using the raspbian Docker image and it is working fine. See the picture.

But I am using the latest netPI Software V1.1.3.0RC3 from netPI's homepage. Maybe this is the solution.

Please update your netPI and try it again. Then it should work.

Armin