Volume Linking USB device into Docker with MATLAB

3 次查看(过去 30 天)
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