Virtual Serial Port on Mac OS X

Hello,
I have a question concerning the connection to virtual serial ports on Mac OS X! Is it possible to connect on Mac OS X to a serial Device called something like "/dev/ttys001" like it's on Linux, or is it needed to have a "/dev/tty.xxx" virtual device. I installed "socat" on osx for getting a virtual serial port, but this utility only generates port names the linux way.
Greets Jürgen

2 commentaires

Walter Roberson
Walter Roberson le 22 Nov 2012
When you say "virtual serial" for this purpose, are you referring to ptty or are you referring to serial-over-USB ?
Jürgen
Jürgen le 22 Nov 2012
I meant ptty. No external adapter or anything. The utility I use is "socat". The port is listed under ls /dev/tty* but when I try to open the Port, Matlab says it cannot find ttys001 and only shows me devices available nmed with tty.xxx or cu.xxx

Connectez-vous pour commenter.

Réponses (2)

Walter Roberson
Walter Roberson le 22 Nov 2012

0 votes

I would expect /dev/pty* something. In particular, OS-X appears to use /dev/pty[p-w][0-9a-f]
Looking at http://cocoontech.com/forums/topic/19633-serial-to-ethernet-for-macs/ and the example linked to, it appears you would name one of those ports on the socat command line and have applications open it.

5 commentaires

Jürgen
Jürgen le 22 Nov 2012
Yes it's right that Mac OS x also uses ptyw.. but nevertheless Matlab seems to only recognize device Names starting with tty.something.
Error using serial/fopen (line 72) Open failed: Port: /dev/ttys001 is not available. Available ports: /dev/tty.Bluetooth-PDA-Sync, /dev/cu.Bluetooth-PDA-Sync, /dev/tty.Bluetooth-Modem, /dev/cu.Bluetooth-Modem. Use INSTRFIND to determine if other instrument objects are connected to the requested device.
The Matlab documentation says also something like tty.key... for the parameter. http://www.mathworks.de/de/help/matlab/ref/serial.html
So is it in Matlab for Mac Os X not possible to use serial ports not named tty.xx or cu.xx. Are there other utilities than socat, or how is it possible in socat to open a virtual com port called tty.s001. Actually I use this command for creating a virtual serial port pair which is connected to each other "socat -d -d pty,link=/dev/tty.Bluetooth-PDA-Sync,raw,echo=0 pty,link=/dev/tty.Bluetooth-Modem,raw,echo=0".
Walter Roberson
Walter Roberson le 22 Nov 2012
Hmmmm... looks like serial() calls upon the java methods of com.mathworks.toolbox.instrument.SerialComm which is supposed to return a java object representing the port, empty if it cannot find the port. fopen() on the serial object retrieves the returned object (if it is there at all) and operates on it.
I do not know how the constructor com.mathworks.toolbox.instrument.SerialComm.SerialComm works. There is com.mathworks.toolbox.instrument.SerialComm.findAllPorts which returns the ports that show up in that list, but I don't know if the method is just doing string checks against that list or is checking the device file for reasonability. It could be that it is looking for devices with major device number 18 and populating the list with those and only checking against those. I don't know.
Jürgen
Jürgen le 22 Nov 2012
I now tried to open a virtual serial port with socat (ttys001) and renamed it afterwards to tty.s001, but it also didn't show up in Matlab. Only recognizes my Bluetooth Module
Walter Roberson
Walter Roberson le 22 Nov 2012
I remembered a hack that would work if you had a pair of real (physical) serial ports in your system, but it looks like you do not have that.
Jürgen
Jürgen le 22 Nov 2012
Modifié(e) : Jürgen le 22 Nov 2012
No I don't have something like that and it's only for educational purpose, but teh methd of serial port works perfectly unter Windows with Virtual Serial Port Driver from Eltima and I think it will also work with socat under Linux but just have to try it.
It would only be interesting if there is any way of tweaking Matlab the way to get also to work with virtual serial ports on Mac.

Connectez-vous pour commenter.

Jürgen
Jürgen le 24 Nov 2012

0 votes

What I have found out so far is, that Matlab and other Applications will recognize virtual ports is, to create/emulate a hardware port with something like this http://com0com.sourceforge.net/ and then link the virtual ports from socat with the emulated hardware ...

Catégories

En savoir plus sur Graphics Performance dans Centre d'aide et File Exchange

Question posée :

le 21 Nov 2012

Community Treasure Hunt

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

Start Hunting!

Translated by