Volume Linking USB device into Docker with MATLAB

조회 수: 3 (최근 30일)
Amoghcharan
Amoghcharan 2023년 11월 6일
답변: Akshat 2023년 12월 14일
I am currently using MATLAB in a Docker container and trying to read data coming from a USB port on the host machine. I have tried adding these arguments into a shell script that runs my Docker container:
--device=/dev/ttyUSB0
-v /dev:/dev
I can see that the dev folder is volume linked in correctly in Docker, however I do not see it in MATLAB when I run 'serialportlist' command. This only returns '/dev/ttyS4' which I have also tried to direct my volume linked /dev/ folder to with no success.
My goal is to use vrjoystick() in a MATLAB script running in a Docker container but have had no success getting MATLAB to find the USB that is connected to the joystick on the host machine.
I would appreciate any insight! Thank you!

답변 (1개)

Akshat
Akshat 2023년 12월 14일
Hi Amoghcharan,
As per my understanding of the question, you want to connect a joystick to a port and use it with MATLAB, but MATLAB can’t discover this in the script.
The lines executed by you is exactly what I would have done, but you can check for the following steps in addition to what you’ve done:
  1. Make sure the output after running “dmesg | grep tty” on the host after connecting the USB device is your device name.
  2. Check for docker permissions to access serial ports.
  3. By this I mean that check the group to which the serial ports are added, has all the permissions. These usually belong to the “dialout” group. For more information on how to do this, refer this link : https://askubuntu.com/questions/133235/how-do-i-allow-non-root-access-to-ttyusb0
Alternatively, you can try to elevate the permissions while running the docker itself. The following command might help:
docker run --privileged --device=/dev/ttyUSB0 -v /dev:/dev my_matlab_image
Hope this helps!
Regards
Akshat

카테고리

Help CenterFile Exchange에서 Parallel Computing Fundamentals에 대해 자세히 알아보기

제품


릴리스

R2021b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by