OS X serial port problems (comm.m)

I have tried comm.mexmac and I cannot seem to get it working. I have a
keyspan serial
adapter with the OS X drivers. The adapter software recognizes when
the adapter is
plugged in and removed, but "comm" commands go totally unnoticed.

I used the OS9 version of comm.mex with no problems. The notes for the
version I am
using now say it has been tested with OS 10.3 and Matlab v6. So maybe
v7 of Matlab
broke something. Or maybe I am doing something wrong. But, in any
case, its not
encouraging.

I don't suppose anyone is working on a new version of PsychSerial?

-Jordy

-----------------------
Dr. Jordy Kaufman
Lecturer in Psychology
UCL
26 Bedford Way
London WC1H 0AP

tel: 020 7679 5352
fax: 020 7436 4276
Jordy,

I am sure I will have a need for an OSX PsychSerial is the near-enough
future. But presently, just a non-traditional use of serial adapter
in OS9 in one of the labs lead me to try "comm" for the OSX version of
the same based on Denis' post not too long ago.

First, here is my hardware (and MATLAB version) relevant to this reply:
1. Mac PowerBook G4 OSX (10.3.9) 667 MHz PowerPC 512 MB SDRAM.
2. Keyspan HighSpeed USB serial adapter with one DB9 male port,
comm('open') identifies it as /dev/cu.USA19H181P1.1. (Same as yours?
Or are you using the Keyspan Twin with two female Din8 ports?)
3. Belkin USB serial adapter for Mac, F5U-103-MAC, with one DB9 male
port and one female Din8 port, comm('open') identifies it as
/dev/cu.F5U103BL1081
4. MATLAB 7.0.4 (R14 SP2), Psychtoolbox 1.0.5

My experimenting using "comm" with both adapters was limited. With an
oscilloscope, I only tested for activity on pin 3 (Transmitted Data,
TxData) with ground connected to pin 5 (Signal Ground, Gnd). But
maybe you will find this helpful.

Using the Keyspan adapter with driver from the disk that came with it,
comm('open'), comm('close'), comm('status'), comm('break') all worked
consistently and as expected. Well, I don't know what comm('break')
is supposed to do, but it set TxData and other pins high for about 300
ms each time it was called. Calling comm('write') with various DATA
values produced no voltage changes on any pins. (i.e., comm('write')
did nothing)

For comparison, I tried "comm" with a Belkin adapter borrowed from a
different lab. This is an older adapter which Belkin now seems refuse
to acknowledge they ever manufactured, much less post an OSX driver,
but I found one. I'll just post some links regarding downloading
ubsa-kext.tgz and installation instructions. When you look at the
"Digital Leafblower" page, know that I did not bother to HEX edit the
binary as described. I just installed it as is per those instruction.
http://www.digitalleafblower.com/
http://sourceforge.net/project/showfiles.php?group_id=87812
http://forums.macosxhints.com/showthread.php?t=25990&highlight=belkin+f5u103

In the case of the Belkin adapter, comm('open'), comm('close'),
comm('status'), comm('write') all worked consistently and as expected.
I should qualify that I am pretty sure comm('write') worked because
the highs and lows of the oscilloscope trace matched the binary of the
numbers I was transmitting, but I was not communicating with any
external hardware or computer. And in this case, comm('break') did
nothing on the Belkin.

In conclusion, if you and I used the same Keyspan adapter, sounds like
we noted similar problems comm problems. But if you can get your
hands on a Belkin F5U-103 Mac adapter, there might be hope for using
comm with OSX MATLAB. I noticed the download of comm comes with the
XCode files, but it is over my head to figure out why comm('write')
would work with one driver/adapter pair but not the other.

Daniel Shima
Vanderbilt Vision Research Center


On 4/20/05, Jordy Kaufman <j.kaufman@...> wrote:
>
>
> I have tried comm.mexmac and I cannot seem to get it working. I have a
> keyspan serial
> adapter with the OS X drivers. The adapter software recognizes when
> the adapter is
> plugged in and removed, but "comm" commands go totally unnoticed.
>
> I used the OS9 version of comm.mex with no problems. The notes for the
> version I am
> using now say it has been tested with OS 10.3 and Matlab v6. So maybe
> v7 of Matlab
> broke something. Or maybe I am doing something wrong. But, in any
> case, its not
> encouraging.
>
> I don't suppose anyone is working on a new version of PsychSerial?
>
> -Jordy
>
> -----------------------
> Dr. Jordy Kaufman
> Lecturer in Psychology
> UCL
> 26 Bedford Way
> London WC1H 0AP
>
> tel: 020 7679 5352
> fax: 020 7436 4276
dear jordy & dan

i spiffed up the psychhardware page (Contents.m) for the 1.05 release
of the OSX Psychtoolbox, but my update was inadvertently omitted from
the release. it includes all the information that everyone has
contributed about serial options on all Psychtoolbox platforms. it'll
be in the 1.06 release, but in the meantime i'm pasting it below.

any additions would we welcome.

best

denis

% Psychtoolbox:PsychHardware
% Sense and control the world outside the computer. For keyboard and
mouse
% see PsychBasic. For other USB devices, see
% web http://psychtoolbox.org/usb.html -browser;
%
% help Psychtoolbox % For an overview, triple-click me & hit enter.
%
% ActiveWire - Win, OS9: ActiveWire minimal USB interface, $59.
% web http://www.activewireinc.com/ -browser
;
% CMCheckInit - OS9: Turn on color meter.
% CMClose - OS9: Turn off color meter.
% MeasSpd - OS9: Use color meter to measure a spectral power
% distribution.
% MeasXYZ - OS9: Use color meter to measure XYZ coordinates.
% CRSColorToolbox - OS9: Talk to CRS Colorimeter.
% PR650Toolbox - OS9: Talk to PR650 Colorimeter. (This will
% eventually supercede PsychObsolete:CMETER.)
% Daq folder - OSX: Control the PMD-1208FS data acquisition
% device.
% Joystick - OS9: Read USB game controllers. OSX: renamed
"Gamepad".
% Gamepad - OSX: Read USB game controllers. Formerly
"Joystick".
% GetGamepadIndices - OSX: Get indices of gampads in PsychHID device
list.
% GetKeyboardIndices - OSX: Get indices of keyboards in PsychHID
device list.
% GetMouseIndices - OSX: Get indices of mice in the PsychHID device
list.
% PsychHID - OSX: Read/write any HID-compliant USB device.
See web page:
% web http://psychtoolbox.org/usb.html
% PsychSerial - Win, OS9: Send and receive through serial ports.
% SERIAL - Win: Send and receive through serial ports.
% Standard Matlab function. Requires Java,
so it's
% not available if you run Matlab with the
% -NOJVM switch. In Win we use the -NOJVM
switch
% to fix the problem with GetChar.
% COMM - OSX Send and receive through serial ports.
% web
http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?
objectId=4952&objectType=file -browser;
% Snd - Win, OS9, OSX: Play a sound.
% TestIOPort - OSX: Use the Code Mercenaries' IO Warrior
minimal
% USB interface, 49 euros. "IOPort.mexmac"
should be
% renamed "IOWarrior.mexmac".
% web http://www.codemercs.com/E_index.html
-browser;
%
% Minolta Toolbox
% Set of m-files and sample code that can be used for reading luminance
data
% from the Minolta LS-110 luminance meter. Contains simple program for
% creating a LUT.
% web
http://cornelis.med.rug.nl/pub/psychtoolboxstuff/minoltatoolbox.sit
-browser;
%
% OSX: For serial port access under Mac OS X you may want to download
COMM
% from the Mathworks web site. Written by Tom Davis. "This MEX-file
% provides Matlab access to Mac serial ports. This includes built-in
ports
% (modem and irDa) and add-on ports, such as USB-to-serial adapters. It
has
% been tested with Mac OS X 10.3 and Matlab 6.5.1. The Xcode project
used to
% develop the MEX-file is included."
% web
http://www.mathworks.com/Matlabcentral/fileexchange/loadFile.do?
objectId=4952&objectType=file -browser;
%
% TCP/UDP/IP Toolbox 2.0.5
% This toolbox can be used to set up TCP/IP connections or send/receive
% UDP/IP packets in Matlab. It can transmit data over the
Intranet/Internet
% between Matlab processes or other applications. It is possible to act
as
% server and/or client and transmit strings, arrays of any data type,
% files, or Matlab variables. There's no mexmac file in this release,
% but this toolbox works perfectly on Mac OS X as is. Tested with
% Matlab 7.0.1 and Mac OS X 10.3.7. Just use the MEX command with the
main
% pnet.c file and it will generate a pnet.mexmac.
% web
http://www.mathworks.com/Matlabcentral/fileexchange/loadFile.do?
objectId=345&objectType=file -browser;
Jordy,

As a possible issue for OSX "comm" users with Keyspan adapters, I
forgot to mention that Keyspan makes a big deal in its driver
documentation about this:

"The Keyspan USB Serial Adapter Software for Mac OS X will make your
serial devices work under Mac OS X ONLY if your serial device has Mac
OS X native software."

That seems strange to me, that the adapter would only work if you had
it connected to particular hardware. The quote comes from the User
Manual PDF-file at the link below. Per my oscilloscope testing, seems
like you should be able to at least 'write' to the port even if it is
not connected to anything. Maybe someone can explain the issue
better:
http://www.keyspan.com/support/macosx/usa/

Also, as an update, regarding my use of "comm" with the Belkin
F5U-103-MAC adapter and the homemade OSX driver for it found on the
web, I was able to communicate with a Minolta CRT Color Analyzer
CA-100 through its RS232 port using its cable which terminates as a
Din8 plug connected to my adapter. That includes 'open' with
'9600,e,7,2' passed as the config parameter, 'write', 'read',
'status', and 'close'.

Again, as the particular Belkin adapter is not easy to find, I
encourage others to post about other USB-serial adapters that work for
them in OSX MATLAB using "comm".

Daniel Shima
Vanderbilt Vision Research Center
Hi Daniel,

With respect to troubleshooting, the keyspan utility does not even
register 'open' and 'close' commands, so even though you are measuring
activity there, I am not sure that this activity indicates expected
behaviour.

Unfortunately, my experiments depend on two serial connections, so I
really need a twin adapter. As you noted, Belkin pretty much insists
that these products don't exist and that even if they do exist there
are no drivers for OS X. All Keyspan products (including the internal
PCI card) come with the "OSX native" disclaimer.

So, for now, it looks like I am in a bind that requires me to go back
to OS9.

-Jordy

On 21 Apr 2005, at 01:02, Daniel Shima wrote:

>
>
>
> Jordy,
>
> I am sure I will have a need for an OSX PsychSerial is the near-enough
> future. But presently, just a non-traditional use of serial adapter
> in OS9 in one of the labs lead me to try "comm" for the OSX version of
> the same based on Denis' post not too long ago.
>
> First, here is my hardware (and MATLAB version) relevant to this reply:
> 1. Mac PowerBook G4 OSX (10.3.9) 667 MHz PowerPC 512 MB SDRAM.
> 2. Keyspan HighSpeed USB serial adapter with one DB9 male port,
> comm('open') identifies it as /dev/cu.USA19H181P1.1. (Same as yours?
> Or are you using the Keyspan Twin with two female Din8 ports?)
> 3. Belkin USB serial adapter for Mac, F5U-103-MAC, with one DB9 male
> port and one female Din8 port, comm('open') identifies it as
> /dev/cu.F5U103BL1081
> 4. MATLAB 7.0.4 (R14 SP2), Psychtoolbox 1.0.5
>
> My experimenting using "comm" with both adapters was limited. With an
> oscilloscope, I only tested for activity on pin 3 (Transmitted Data,
> TxData) with ground connected to pin 5 (Signal Ground, Gnd). But
> maybe you will find this helpful.
>
> Using the Keyspan adapter with driver from the disk that came with it,
> comm('open'), comm('close'), comm('status'), comm('break') all worked
> consistently and as expected. Well, I don't know what comm('break')
> is supposed to do, but it set TxData and other pins high for about 300
> ms each time it was called. Calling comm('write') with various DATA
> values produced no voltage changes on any pins. (i.e., comm('write')
> did nothing)
>
> For comparison, I tried "comm" with a Belkin adapter borrowed from a
> different lab. This is an older adapter which Belkin now seems refuse
> to acknowledge they ever manufactured, much less post an OSX driver,
> but I found one. I'll just post some links regarding downloading
> ubsa-kext.tgz and installation instructions. When you look at the
> "Digital Leafblower" page, know that I did not bother to HEX edit the
> binary as described. I just installed it as is per those instruction.
> http://www.digitalleafblower.com/
> http://sourceforge.net/project/showfiles.php?group_id=87812
> http://forums.macosxhints.com/showthread.php?
> t=25990&highlight=belkin+f5u103
>
> In the case of the Belkin adapter, comm('open'), comm('close'),
> comm('status'), comm('write') all worked consistently and as expected.
> I should qualify that I am pretty sure comm('write') worked because
> the highs and lows of the oscilloscope trace matched the binary of the
> numbers I was transmitting, but I was not communicating with any
> external hardware or computer. And in this case, comm('break') did
> nothing on the Belkin.
>
> In conclusion, if you and I used the same Keyspan adapter, sounds like
> we noted similar problems comm problems. But if you can get your
> hands on a Belkin F5U-103 Mac adapter, there might be hope for using
> comm with OSX MATLAB. I noticed the download of comm comes with the
> XCode files, but it is over my head to figure out why comm('write')
> would work with one driver/adapter pair but not the other.
>
> Daniel Shima
> Vanderbilt Vision Research Center
>
>
> On 4/20/05, Jordy Kaufman <j.kaufman@...> wrote:
>>
>>
>> I have tried comm.mexmac and I cannot seem to get it working. I have
>> a
>> keyspan serial
>> adapter with the OS X drivers. The adapter software recognizes when
>> the adapter is
>> plugged in and removed, but "comm" commands go totally unnoticed.
>>
>> I used the OS9 version of comm.mex with no problems. The notes for
>> the
>> version I am
>> using now say it has been tested with OS 10.3 and Matlab v6. So maybe
>> v7 of Matlab
>> broke something. Or maybe I am doing something wrong. But, in any
>> case, its not
>> encouraging.
>>
>> I don't suppose anyone is working on a new version of PsychSerial?
>>
>> -Jordy
>>
>> -----------------------
>> Dr. Jordy Kaufman
>> Lecturer in Psychology
>> UCL
>> 26 Bedford Way
>> London WC1H 0AP
>>
>> tel: 020 7679 5352
>> fax: 020 7436 4276
>
>
>
>
>
> Post your message to: psychtoolbox@yahoogroups.com
> Please indicate OS9, OSX, or WIN version, and include your full name.
> Denis Pelli, David Brainard, and Allen Ingling.
> http://psychtoolbox.org
>
> Yahoo! Groups Links
>
>
>
>
>
>
>
>
-----------------------
Dr. Jordy Kaufman
Lecturer in Psychology
UCL
26 Bedford Way
London WC1H 0AP

tel: 020 7679 5352
fax: 020 7436 4276