Why is my serial port not recognized with MATLAB on Linux or Solaris?
조회 수: 15 (최근 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개)
참고 항목
카테고리
Help Center 및 File Exchange에서 MATLAB Support Package for Arduino Hardware에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!