Want to highlight a helpful answer? Upvote!

Did someone help you, or did an answer or User Tip resolve your issue? Upvote by selecting the upvote arrow. Your feedback helps others! Learn more about when to upvote >

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

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
Question marked as Best reply

Posted on May 13, 2011 8:56 PM

Look inside the folder from the Xcode install - /Developer/Applications/Utilities/USB Prober


Search the Dev Center for related code, samples, etc.

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.

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 ID.