Matlab does not recognize serial port

Right now I'm trying to use Matlab to read in serial data through an FTDI interface with an RS422 on a laptop running Centos 6. The data is passed through every 25 seconds or so. I already have code that runs with another computer, and I know the laptop itself can receive the data (have confirmed this using cutecom). The current issue is that I cannot access the serial port in Matlab.
So far I have tried to create a symbolic link from /dev/ttyUSB0 (what the laptop recognizes as the port going to the RS422) to /dev/ttyS101 as described here. I also tried adding a java.opts file to specify which serial ports Matlab should be looking as described in the answer here.
I've verified permissions: used ls -l /dev/ttyUSB0 and got the following result:
crw-rw---- 1 root dialout 188
And I made sure I was in the dialout group.
Any suggestions on what to try next?

2 comentarios

Ameer Hamza
Ameer Hamza el 22 de Mayo de 2018
How are you trying to access the serial port and what is the error given by MATLAB?
Through a USB-to-RS422 cable. Running the following code:
s = serial('/dev/ttyUSB0')
fopen(s)
I get:
Error using serial/fopen (line 72)
Open failed: Port: /dev/ttyUSB0 is not available. No ports available.
Use INSTRFIND to determine if other instrument objects are connected to the requested device.

Iniciar sesión para comentar.

Respuestas (2)

Ameer Hamza
Ameer Hamza el 22 de Mayo de 2018
Make sure that no other program is accessing the serial port. Close all other programs which might be accessing the serial port and then try again. Also in MATLAB check the output of
instrfind
If it is non-empty then run the following lines before trying again
fclose(instrfind)
delete(instrfind)

5 comentarios

Daniel Ramos
Daniel Ramos el 22 de Mayo de 2018
I only have Matlab running while trying to run the code. Even restarted the laptop just to be sure.
Prior to running what I showed you above, the output of instrfind is []
As you mentioned in the question, you tried the symbolic link method. But in the code you gave in the comment, you are not using the symbolic link, rather the actual serial port. Have you tried
s = serial('/dev/ttyS101')
fopen(s)
after creating the symbolic link?
Daniel Ramos
Daniel Ramos el 22 de Mayo de 2018
Yes I did, it gives the same errror. It does show up under seriallist but that's the only difference
Ameer Hamza
Ameer Hamza el 22 de Mayo de 2018
I cannot think of any other reason. It seems to be some bug on Linux systems.
Daniel Ramos
Daniel Ramos el 22 de Mayo de 2018
That was the answer I was worried about. Thank you for your help!

Iniciar sesión para comentar.

vibhorag
vibhorag el 28 de Jun. de 2019
Editada: vibhorag el 28 de Jun. de 2019

0 votos

I recieve the same error when trying to read the port; but, Matlab produces the same error. Has anybody worked out the solution for this?

Categorías

Más información sobre MATLAB en Centro de ayuda y File Exchange.

Productos

Versión

R2018a

Preguntada:

el 22 de Mayo de 2018

Editada:

el 28 de Jun. de 2019

Community Treasure Hunt

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

Start Hunting!

Translated by