Machine connection

Ubuntu 24.04.1 LTS and LaserWeb last version (docker)
I run docker:

docker run -device=/dev/ttyUSB0 -p 8000:8000 joesantos/laserweb:latest

And I don’t see the serial port (ttyUSB0)!

simonovich@simonovich-Aspire-E5-772G:/opt/hg/docker/LaserWeb4$ groups $USER
simonovich : simonovich adm tty uucp dialout cdrom sudo dip plugdev users lpadmin docker
simonovich@comp:/opt/hg/docker/LaserWeb4$ id -Gn $USER
simonovich adm tty uucp dialout cdrom sudo dip plugdev users lpadmin docker
simonovich@comp:/opt/hg/docker/LaserWeb4$ ls /dev/ttyUSB0 
/dev/ttyUSB0
simonovich@comp:/opt/hg/docker/LaserWeb4$ ls -la /dev/ttyUSB0 
crw-rw---- 1 simonovich dialout 188, 0 jan 30 23:50 /dev/ttyUSB0
simonovich@comp:/opt/hg/docker/LaserWeb4$

What happened? Why?

1 Like

Logs:

1 Like

@simonovich ; I cannot see anything wrong with the permissions as you list them.

What happens if you try to talk directly to the firmware via a serial console app like Universal Gcode Sender, Pronterface, pyserial-miniterm (etc)? Do you see the machine? do you get a response to sending ctrl-X (should reset and show firmware line)?

  • Initially I cant think of a reason why the docker image wouldnt see the USB port… but I must confess it ia a very long time since I tried this.

Everything works well through Lightburn and through Lasergrbl (wine).

Ok; having slept a bit and re-read some stuff I was forgetting. Docker (which I am very familiar with) is a PITA with /dev/ devices in general and tty* devices in particular.

One point is that devices are enumerated when the container starts, so if your device is (re-)connected after the container starts it will not be visible. resetting the controller board usually resets the USB connection too. Catch-22.

The modern solution seems to be cgroups: docker container run | Docker Docs

I think you need something like:

docker run --device-cgroup-rule='c 188:0 rmw'  -p 8000:8000 joesantos/laserweb:latest

I’m out-and-about with my laptop and cant test this. Note that I prefer to run laserweb directly from nodejs/npm without docker. On modern distros this works well and avoids issues like the above.

See also this stackoverflow discussion & post

Here the user for some reason creates a block device manually. I repeated his steps. This solution does not help me.
My USB devices are visible in the container anyway. But they are not loaded on the web page.

By sample:

$ docker run -it --rm --privileged --tty --volume=/dev:/dev -p 8000:8000 joesantos/laserweb:latest sh

and inside the container environment:

/app # ls -la /dev/tty*

crw-rw-rw-    1 root     tty         5,   0 Feb  4 11:04 /dev/tty
crw--w----    1 root     tty         4,   0 Jan 24 07:10 /dev/tty0
crw--w----    1 root     tty         4,   1 Jan 24 07:10 /dev/tty1
...
...
crw-rw----    1 root     dialout     4,  73 Jan 24 07:10 /dev/ttyS9
crw-rw----    1 node     dialout   188,   0 Feb  4 10:08 /dev/ttyUSB0
/app # stat /dev/ttyUSB0 
  File: /dev/ttyUSB0
  Size: 0         	Blocks: 0          IO Block: 4096   character special file
Device: 5h/5d	Inode: 1476        Links: 1     Device type: bc,0
Access: (0666/crw-rw-rw-)  Uid: ( 1000/    node)   Gid: (   20/ dialout)
Access: 2025-02-04 10:08:15.000000000
Modify: 2025-02-04 10:08:15.000000000
Change: 2025-02-04 11:24:10.000000000

But there are still no USB ports on the page ‘Machine Connection’.

In the browser console I see a strange request:


GET /sockjs-node/info?t=1738663920990 undefined
Host: 172.17.0.3:8080
User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:134.0) Gecko/20100101 Firefox/134.0
Accept: */*
Accept-Language: ru-RU,ru;q=0.8,en-US;q=0.5,en;q=0.3
Accept-Encoding: gzip, deflate
Origin: http://172.17.0.3:8000
DNT: 1
Connection: keep-alive
Referer: http://172.17.0.3:8000/

It returns error ‘NS_ERROR_CONNECTION_REFUSED’.
Maybe this is related to my problem.

I read the ReadMe again and worked with docker. Found an error:

  • Writing -device - is incorrect, you need to specify --device, otherwise the port will not be mounted
    I built the dev version of the container and launched it: ports appeared and everything works fine!
    After that, I returned to the old launch cases and checked them again.

Results:

  1. docker run -device=/dev/ttyUSB0 -p 8000:8000 joesantos/laserweb:latest
  1. docker build -f Dockerfile.release -t laserweb:release .
    docker run --device=/dev/ttyUSB0 --rm -p 8000:8000 laserweb:release
  • For the release build from docker - the same thing! :disappointed:
  1. docker build --target dev -t laserweb:dev .
    docker run --device=/dev/ttyUSB0 --rm -p 8000:8000 laserweb:dev
  • dev-build works fine, the machine connects :+1: