Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

CunningWard

macrumors member
Original poster
Jan 30, 2008
33
0
Middle of a Cornfield, Iowa
I just started programming with an Arduino a few months ago and now one of the projects I would like to do for a lab I work for is read in sensor data and send that to a terminal program via the USB connected Arduino. This has presented a few problems:

#1) Ncurses is not working properly in Xcode. I've tried macports and reinstalling ncurses to no avail. I keep getting a linking error in Xcode.

#2) Nowhere can I find information on reading in from a serial port in C for Mac...I know this can be done on Windows, but that just takes the fun out of it.

Any help would be greatly appreciated!
 
#1) Ncurses is not working properly in Xcode. I've tried macports and reinstalling ncurses to no avail. I keep getting a linking error in Xcode.
Post the error message. We can't see your Xcode window from here.


#2) Nowhere can I find information on reading in from a serial port in C for Mac...I know this can be done on Windows, but that just takes the fun out of it.
Google AMSerialPort

AMSerialPort is an Objective-C library for using serial ports. It's open source under the BSD License.

I know you asked for C, but AMSerialPort uses the C IOKit functions in its implementation. If it's too much work to rewrite it, you can write C functions that wrap AMSerialPort and then call those from your C code.
 
AMSerialPort is an Objective-C library for using serial ports. It's open source under the BSD License.

I know you asked for C, but AMSerialPort uses the C IOKit functions in its implementation. If it's too much work to rewrite it, you can write C functions that wrap AMSerialPort and then call those from your C code.

Couldn't one simply open a /dev/ttyxxx file from a C program to use the RS-232 port?
 
I know that this is kinda offtopic but, why won't you use a Cocoa Application to display the data?

Knowing that there is a Library to read from serial port, you'll rid of complications about ncurses :)

I'm starting with Arduino, it's a great device!
 
you can just use standard posix functions in c to read/write from a serial port.
Your device should show up as /dev/tty.something
I haven't figured out how to use nonstandard baud rates yet though. Because of that, I can't gather data from my hardware using the fastest settings (my hardware goes up to 921660 baud).

I used this page to learn how to work with serial ports:
http://www.easysw.com/~mike/serial/serial.html

It should serve you well.
 
Hello, I need to develop an XCode app able to use the serial port ON THE iPHONE. I already arranged the physical connection, jailbroke the iphone, installed minicom and so on, and I can see on the little mobile terminal app (cydia) the characters sent from arduino.
But I need to read these characters from my XCode app.
Is everything you wrote here still true? Can I use AMSerialPort or is it only for Cocoa desktop?
Thank you!
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.