open serial ports using matlab web

28 views (last 30 days)
I have some problems using serialport sentence in the online matlab enviroment. The serial port in windows it's called as 'COMx' but in linux is something like "/dev/ttySx" just like online matlab. So, when I try to open the port usin the sentence s = serialport("/dev/ttyS0", 115200) an error occurs saying Unable to connect to the serialport device at port '/dev/ttyS0', also happen using "COMx" instead. I gess that may be is some problems related with the access to the port of the computer from online matlab enviroment, but I don't know how fix it.

Answers (1)

Walter Roberson
Walter Roberson on 16 Feb 2023
Edited: Walter Roberson on 16 Feb 2023
MATLAB Online runs on a cloud somewhere. Your interface to it is through a web browser. The only part that runs on your own hardware is the web browser.
The only way for a web browser to access hardware that lives on your computer is by using an HTML5 interface. Security models in browsers have changed over the years so that JavaScript cannot access hardware except through specific interfaces. The only common browser that implements the interface is Chrome, and it is currently limited to playing sound and transferring some kinds of sensor data if I recall correctly.
In summary: there is no way for MATLAB Online to be able to access serial ports on your computer. That includes not being able to access arduino or raspberry pi.
(I have seen some hints that arduino connections might be available in the future.)

Tags

Community Treasure Hunt

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

Start Hunting!