Why is my serial port not recognized with MATLAB on Linux or Solaris?
10 ビュー (過去 30 日間)
古いコメントを表示
MathWorks Support Team
2013 年 2 月 14 日
編集済み: MathWorks Support Team
2016 年 1 月 26 日
I would like to open serial ports with names like '/dev/ttyPS0' on my Linux machine with MATLAB. If I attempt to connect to this serial port
s=serial('ttyPS0')
fopen(s)
I receive the following error: ERROR: ??? Error using ==> serial.fopen at 71 Port: ttyPS0 is not available. No ports are available. Use INSTRFIND to determine if other instrument objects are connected to the requested device.
採用された回答
MathWorks Support Team
2016 年 1 月 26 日
MATLAB only automatically recognizes serial port names of the form /dev/ttyS[0-255]. If the serial port is named something else, identifying this serial port with MATLAB would be needed to be done through the java.opts file or by creating a symbolic link to the port which has a standard name.
For example, create a symbolic link named ttyS101 as follows (assuming /dev/ttyS101 does not exist):
ln -s /dev/ttyPS0 /dev/ttyS101
/dev/ttyS101will then be available in addition to the usual ports found.
The other way to have MATLAB recognize the port name is by creating a file named java.opts. In this file, include the following line:
-Dgnu.io.rxtx.SerialPorts=/dev/ttyPS0
where "/dev/ttyPS0" is the name of your serial port. (To enter multiple ports/file descriptors separate them by colons :). Put the java.opts file in the userpath directory in MATLAB, and navigate to that directory before starting MATLAB.
This will work for dozens of serial port types in Linux and Solaris. There are many serial port types supported that show up as unique device files. As a rough number, there are 50x256 possible serial ports in a Linux system. MATLAB only automatically checks 2% of those (/dev/ttyS[0-255]).
0 件のコメント
その他の回答 (0 件)
参考
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!