views:

398

answers:

3

Hi folks,

I am looking for an open source cross-platform library for working with the serial port in C, something along the lines of the awesome pyserial library (Unfortunately I have to use C for this application)

I have only found this one: http://www.teuniz.net/RS-232/ and that doesn't seem to have mention OSX compatibility.

Any recommendations/comments would be greatly appreciated.

Thanks.

+2  A: 

I realize that you said C and not C++, but perhaps you could use Boost Asio's serial ports and compile that into a library to be linked with your C application. It claims to be POSIX compatible, and OSX is POSIX.

Mark Rushakoff
Thanks for the suggestion.
Hamza
+2  A: 

Get some additional OSX-specific ObjC code along the lines of AMSerialPort, goSerial, serialconnect, PolKit, ... and implement a conditional compilation of your C source file.

http://osx.hyperjeff.net/Apps/apps?f=serial

trivvo
Thanks for the suggestion, but I'd like to keep it C only.
Hamza
A: 

OS X supports the standard POSIX serial API, from <termios.h> and <unistd.h>. Look up the functions tcsetattr(), cfsetspeed() and so on.

caf