How can I read a serial port using XCode?

Hello,


I'm using an iMac 2009 with Mac OS X 10.6.7. I have a USB to Serial cable and I want to connect a hardware I made using a microprocessor Microchip PIC to my mac. I'd like to read values from the serial port and also write values to it. I'm already able to do this using the Terminal with the following command:


screen /dev/tty.usbserial 9600


I'd like to build my own application now. Does anyone could send me any sample code?


I'm using XCode 3.2.5 and I'm a beginner on XCode.

iMac, Mac OS X (10.6.4)

Posted on May 13, 2011 8:06 PM

Reply
5 replies

May 14, 2011 6:44 AM in response to K T

I looked at Dev Center for sample code, and I found this link:


http://developer.apple.com/library/mac/#samplecode/SerialPortSample/Introduction /Intro.html%23//apple_ref/doc/uid/DTS10000454-Intro-DontLinkElementID_2


I downloaded the sample Xcode project and, when I click on "Build and Run" button, it generates an error with the following message:


"GCC 4.2 is not compatible with the Mac OS X 10.4 SDK (file SerialPortSample.c)"


Maybe, it occurs because the code is too old (2005). I didn't find any newer sample.


Could you help me?


Thank you.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

How can I read a serial port using XCode?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.