[Pythonmac-SIG] Serial port IO on Python 2.7.3 on OS X
Pascal Oberndörfer
p.oberndoerfer at urheberrecht.org
Fri Jun 8 09:34:57 CEST 2012
Am 08.06.12 02:16, schrieb Mike Wirth:
> Hi, folks,
>
> Newbie (to Python) here. I'm porting a Python app from Windows that
> talks to a Bluetooth 2.1 device using the serial profile (on WinXP it
> shows up as two numbered COM ports, one inbound and the other outbound)
> On the Mac, the device shows up in /dev as:
>
> crw-rw-rw- 1 root wheel 18, 7 May 30 23:12 cu.BlueRadios-COM0
>
> On Windows, the app requires me to install pyserial (and pygame for the
> visual output).
>
> On the Mac, where I've installed and am using python 2.7.3 (rather than
> the pre-installed 2.6.7), my app starts up and acts like it doesn't need
> to have pyserial installed, but of course, it can't connect to the
> expected numbered COM port.
>
> 1. Do I need the Mac equivalent of pyserial?
> 2. Or can I just stuff something like '/dev/cu.BlueRadios-COM0' in the
> app's source code where it expects to open the serial port.
> 3. Anything special about the Bluetooth serial profile (e.g., setting
> port properties)?
>
> Mike
>
> PS: Pointers to the appropriate docs appreciated and I promise to RTFM :-)
Hi Mike,
More than nine years ago there was a mini-wrapper to detect the serial
ports from within Python:
http://mail.python.org/pipermail/pythonmac-sig/2003-February/007189.html
Unfortunately the link is now obsolet.
But there are other prokects still using (extended derivations of) it:
http://trac.warp.es/wader/browser/trunk/contrib/osxserialports/osxserialportsmodule.c?rev=371
https://forge.betavine.net/svn/bcm/branches/sms-confirmation/src/core/contrib/osxserialports/
http://intrepid.danplanet.com/pipermail/chirp_devel/2011-May/000027.html
If this doesn't work for you, drop me a note offline and I will see if I
can find it at home.
The rest is actually using pyserial, which has at least worked for me in
order to connect to serial2USB devices as well as to a GPS via Bluetooth.
Pascal
More information about the Pythonmac-SIG
mailing list