psychopy.org | Reference | Downloads | Github

Iohub pstbox serial port number on Mac OS X

I’ve been using the iohub pstbox class to relay digital signals via a PST button box from PCs running PsychoPy v1.84.2, and this works well. Now I’m trying to do the same thing from a Mac (OS X, v10.16) running the standalone Mac version of PsychoPy v1.84.2, but have encountered a problem. The problem is that I don’t know how to reference the comm port. I’m using a Prolific USB-to-Serial Comm Port adapter, which plugs into a USB port, and on a PC I can instruct iohub with SERIAL_PORT = ‘COM4’. But on the Mac, the USB ports are named differently (e.g. ‘0x14100000 / 7’) and PsychoPy tells me that it can’t locate the port if I instruct iohub with SERIAL_PORT = ‘7’ or SERIAL_PORT = ‘0x14100000 / 7’. Please can somebody tell me how to reference this port?
Thanks,
Richard.

On Unix-based systems, ports like this appear like files in the file system, rather than being accessed via a memory address.

So look in /dev/ for files that probably start with tty. You might notice that file appear and disappear when you plug in the USB to serial adapter. You then refer to that port using the full path, e.g. /dev/tty_something_xxx

HI Michael,

Many thanks for your reply. I’ve only just had a chance to follow your advice, because of the Easter holiday period. Unfortunately, I’ve been unable to identify the name of the port.

I opened the terminal window and typed ‘ls /dev/’ and this brought up a lot of /dev/tty entries, but the list of entries did not change when I plugged and unplugged the USB-to-serial adapter, re-typing ‘ls /dev/’ each time. I know that the adapter is being detected and recognised by the Mac, because it shows up in About this Mac > System Report > USB with the correct product details and a location ID that is specific to the USB port used (e.g. 0x141 or 0x142).

I also tried plugging and unplugging a USB flash drive to see whether this would make a difference to the list of /dev/tty entries, and it failed to do so, despite the fact that the Mac was able to view the contents of the flash drive when it was plugged in.

Does this make any sense to you? By the way, the Mac OS is v10.13.3, not v10.16 as I said previously.

Richard.

The flash drive isn’t really relevant to this, as it isn’t a serial device. It appears as a regular disk volume in the file system.

I wonder if you have installed the driver for this USB-serial adapter? It’s quite possible that you didn’t get a Mac version with the device itself, or that it came on one of those tiny half-size CDs that are no use to anybody anymore, so go online and search for the Mac Prolific driver (check the model number if you can find one, but I think it is generally PL2303 something). e.g. something like here:
http://www.prolific.com.tw/US/ShowProduct.aspx?p_id=229&pcid=41

The adapter won’t be usable without the software to drive it. Once it is installed, you never have to interact with it. But when it is working properly, you should see that entry appear in /dev/tty* on insertion.

Hi Michael,

Thanks again for your advice. I hadn’t tried installing a driver on the Mac, as this hadn’t been necessary on a PC, but installing the driver that you recommended worked! The device now comes up when I type ‘ls \dev\tty*’ in the Terminal, and is listed as tty.usbserial. The iohub pstbox demo program for Coder (https://github.com/psychopy/psychopy/blob/master/psychopy/demos/coder/iohub/serial/pstbox.py) now runs on the Mac when I change the line ‘SERIAL_PORT = ‘COM4’ to ‘SERIAL_PORT = ‘\dev\tty.usbserial’.

Unfortunately, the program that I wrote in Builder still does not work, and gives the same error message as before (‘Error starting ioHub server’, raised when the program reaches the line ‘io = launchHubServer(**iohubkwargs)’. The problem appears to be with Builder, and not with my code. I have copied the code from the pstbox demo, up to this point and a little bit beyond (to where some lamps are switched on to test that they work), and pasted it into a clean Coder program and a clean Builder program (in ‘Begin Experiment’): the Coder program works and the Builder program does not.

To be clear: my Builder program runs fine on a PC; and a Builder program that doesn’t used iohub runs on the Mac. The problem seems to be caused by a combination of Mac + Builder + iohub.

The whole error message reads:

Running: /Users/***/Desktop/chess PsychoPy/chess2_lastrun.py

pyo version 0.8.0 (uses single precision)
2018-04-18 13:41:38.608 python[2491:55652] ApplePersistenceIgnoreState: Existing state will not be touched. New state will be written to (null)
2018-04-18 13:41:50.847 python[2532:55862] ApplePersistenceIgnoreState: Existing state will not be touched. New state will be written to (null)
This program needs access to the screen.
Please run with a Framework build of python, and only when you are
logged in on the main display of your Mac.
Closing remaining open files:/Users/***/Desktop/chess PsychoPy/pstbox.hdf5…done
Traceback (most recent call last):
File “/Users/***/Desktop/chess PsychoPy/chess2_lastrun.py”, line 105, in
io = launchHubServer(**iohubkwargs)
File “/private/var/folders/p5/xl0d80j54qnc61x83h5j997c0000gn/T/AppTranslocation/B30443F7-B9CB-4706-AADF-BE9D7EAE8967/d/PsychoPy2.app/Contents/Resources/lib/python2.7/psychopy/iohub/client/init.py”, line 1504, in launchHubServer
return ioHubConnection(ioConfig)
File “/private/var/folders/p5/xl0d80j54qnc61x83h5j997c0000gn/T/AppTranslocation/B30443F7-B9CB-4706-AADF-BE9D7EAE8967/d/PsychoPy2.app/Contents/Resources/lib/python2.7/psychopy/iohub/client/init.py”, line 287, in init
raise RuntimeError(“Error starting ioHub server: %s”%(self.iohub_status))
RuntimeError: Error starting ioHub server: ioHub startup timed out. iohub Server startup Failed. startup_read:

(The two lines starting ‘2018-04-18’ also came up for the Coder program that worked.)

I wonder if I should start a new thread, as this has strayed from the original topic.

Richard.