View Full Version : trying to use the serial port
iphonejoe
08-09-2007, 04:34 AM
i am trying to use the iPhone's serial port via IOKit. i wrote a litte app that lists all "serial" devices of the iPhone. here is what i get:
iap /dev/tty.iap /dev/cu.iap
baseband /dev/tty.baseband /dev/cu.baseband
bluetooth /dev/tty.bluetooth /dev/cu.bluetooth
debug /dev/tty.debug /dev/cu.debug
i am curious what "iap" might be? anyone here has a good guess where the serial port is hiding?
the above list was generated with code like such:
CFDictionarySetValue(classesToMatch,
CFSTR(kIOSerialBSDTypeKey),
CFSTR(kIOSerialBSDAllTypes));
IOServiceGetMatchingServices(masterPort, classesToMatch, serialIterator);
anyone?
thanks,
ipj
dragon-tmd
08-09-2007, 02:00 PM
Afaik IAP means "Interface for Application Portability (IAP)". Often used in UNIX developing.
iphonejoe
08-10-2007, 09:38 AM
thanks, that's interesting. i also noticed that there is:
System/Library/Frameworks/IAP.framework/IAP
System/Library/Frameworks/IAP.framework/Support/iapd
not sure if that's related to the /dev/iap though....
risner
08-14-2007, 04:12 PM
What serial port are you talking about here?
The USB serial?
Are you trying to cu out to talk to RS232 devices like a Cisco?
iphonejoe
08-15-2007, 07:02 AM
i am trying to use the RS232 serial port via IOKit. so i used a simple IOKit serial example to list all the ports that fit the most general RS232 device type, see code above. however, what i get back, doesn't look like any real RS232 port is available on the iphone.
i would love to get some input for folks who know more about IOKit.
thanks,
-ipj
risner
08-15-2007, 03:41 PM
what i get back, doesn't look like any real RS232 port is available on the iphone.
Where do you think the RS232 port is located?
mattlach
08-15-2007, 09:23 PM
I would be really surprised if they hid access to an RS232 interface in the dock cable.
Not even mac desktops or laptops come with real RS232 ports these days do they? Thats why they sell USB to RS232 dongles for those unlucky few who HAVE to have RS232.
hachu
08-17-2007, 04:49 AM
My guess would have been iPod Accessory Port....
stuartjmoore
08-18-2007, 12:05 AM
If they left the RS232 port from the iPod connector, then it won't be RS232. It's just TTL, but with a max232 chip it can be easily converted to RS232 levels...
iphonejoe
09-11-2007, 09:01 AM
http://ipodlinux.org/Dock_Connector
also, all arround the net, i can read this:
"
we got a serial console working, here is how
the serial has the same pinouts as iPod serial
use a 6.8kish resistor from pin 21 to gnd
tie pin 11-sergnd to the real ground
use iphoneinterface to send the following commands in recovery mode:
setenv debug-uarts 1
saveenv
reboot
"
so since the iphone has a dock connector, i assume(d) that there is serial (TTL or RS232). the trick is how to use it via IOKit?
I've been playing with the serial port for a week now and I have to say its tricky. I've tried all the ports and it seems like the only ones that work are the tty.iap and cu.iap. Both of these ports are mentioned under the IOSerialBSDClient section in the IOKIt registry. I was able to run minicom and send serial data out to my computer but the problem I found is that the iphone locks up when you try to send data back to the iphone over that same connection. I am by no means an apple OS X expert so any pointers people can give me would really help out.
Does anyone know the nuisances between cu.iap and tty.iap? I assume that one is a callout device and one is a dial in device... maybe thats why its locking up everytime I send data to the phone.
tparker.ca
10-05-2007, 08:16 PM
I've been playing with the serial port for a week now and I have to say its tricky.
Are you sure nothing else is listening to the serial port? I heard there was a shell? Perhaps you need to kill off a getty process or the modern equivalent? The xserve runs a serial daemon of some sort perhaps the iphone daemon is related?
If you run the phone with and without debug-uarts set are there any differences to the process running?
hachu
10-06-2007, 09:38 AM
Use only tty.
From what I understand, on Unix machines, the cu devices differ by the way they respond to open(), in that they do some primitive locking.
Oh yeah, is lsof available on the iPhone? If so, use that and tell us if it will tell you who's got tty.iap open.
I've been playing with the serial port for a week now and I have to say its tricky. I've tried all the ports and it seems like the only ones that work are the tty.iap and cu.iap. Both of these ports are mentioned under the IOSerialBSDClient section in the IOKIt registry. I was able to run minicom and send serial data out to my computer but the problem I found is that the iphone locks up when you try to send data back to the iphone over that same connection. I am by no means an apple OS X expert so any pointers people can give me would really help out.
Does anyone know the nuisances between cu.iap and tty.iap? I assume that one is a callout device and one is a dial in device... maybe thats why its locking up everytime I send data to the phone.
hachu
10-15-2007, 09:24 AM
Hey, can somebody ssh into a iphone and run "ps aux" and "lsof" and post the output somewhere? It might be useful to know the name of the app that currently handles stuff on the dock connector's serial port.
Sebbi
10-22-2007, 05:13 AM
Could not find "lsof", but here is the output from "ps aux":
# ps aux
USER PID %CPU %MEM VSZ RSS TT STAT STARTED TIME COMMAND
root 217 0.0 0.0 272872 332 p0 R+ 4:13AM 0:00.01 ps aux
root 1 0.0 0.0 272956 332 ?? Ss Fri11PM 0:04.74 /sbin/launchd
root 12 0.0 0.0 297684 1012 ?? Ss Fri11PM 1:27.73 /usr/local/bin/SMST/SMST
root 13 0.0 0.0 285564 872 ?? Ss Fri11PM 0:02.21 /usr/sbin/BTServer
root 14 0.0 0.0 279092 1172 ?? Ss Fri11PM 0:36.67 /System/Library/Frameworks/CoreTelephony.framework/Support/CommCenter
root 17 0.0 0.0 275084 936 ?? Ss Fri11PM 1:58.96 /usr/sbin/configd
root 18 0.0 0.0 273396 360 ?? Ss Fri11PM 0:00.10 /usr/libexec/crashreporterd
root 19 0.0 0.0 272968 304 ?? Ss Fri11PM 0:00.42 /usr/sbin/cron
root 20 0.0 0.0 286788 1196 ?? Ss Fri11PM 0:09.16 /System/Library/Frameworks/IAP.framework/Support/iapd
root 21 0.0 0.0 273712 648 ?? Ss Fri11PM 0:10.84 /usr/sbin/mDNSResponder -launchd
root 22 0.0 0.0 275144 660 ?? Ss Fri11PM 0:22.52 /usr/libexec/lockdownd
root 23 0.0 0.0 274000 276 ?? Ss Fri11PM 2:54.90 /usr/sbin/syslogd
root 24 0.0 0.0 274168 200 ?? Ss Fri11PM 0:00.11 /bin/sh /etc/hackinit.sh
root 25 0.0 0.0 282248 528 ?? Ss Fri11PM 0:01.71 /usr/libexec/ptpd -t usb
root 28 0.0 0.0 273456 256 ?? Ss Fri11PM 0:25.71 /usr/sbin/notifyd
root 31 0.0 0.0 272904 188 ?? S Fri11PM 0:02.09 /usr/sbin/PXLdaemon
root 32 0.0 0.0 264644 120 ?? S Fri11PM 0:16.90 /usr/sbin/update
root 125 0.0 0.0 289836 9684 ?? Ss 3:04AM 0:38.79 /usr/sbin/mediaserverd
root 141 0.0 0.0 273276 620 ?? S 3:39AM 0:03.39 /usr/sbin/sshd -i
root 145 0.0 0.0 274168 980 p0 Ss 3:40AM 0:00.75 -sh
root 212 0.0 0.0 320316 22432 ?? Ss 4:02AM 0:26.35 /System/Library/CoreServices/SpringBoard.app/SpringBoard
root 213 0.0 0.0 299696 2044 ?? S 4:02AM 0:00.42 /Applications/MobilePhone.app/MobilePhone --firstLaunch --suspended
hachu
10-23-2007, 06:49 AM
Ah, so there's a iapd.
I wonder if CVB can try again after killing the iapd process.
That one's probably got the serial port open and was listening for stuff.
TheRain
11-18-2007, 11:21 AM
I'm having the same problem as CVB. Has anyone gotten past that? I'm using uart.iap, instead of the others listed here. Works fine for serial output, but reading input either freezes the iphone, or does nothing depending on what flags I'm using etc.
Killing iapd seems to stop the serial device from working properly in output and does not fix input. I tried changing permissions to uart.iap, but that had not affect.
The other thing I could try is to use pin 21 and try some different resistances to see if any of them activate it. Maybe 500Kohm as mentioned here http://pinouts.ru/Devices/ipod_pinout.shtml .
Anyone else had any more luck with this??
TheRain
11-19-2007, 04:10 AM
Well I tried a 6k ohm today from pin 21 to gnd and no luck. Didn't have a 500k ohm, but I'll be trying that next and let you all know if it works.
hachu
11-21-2007, 06:58 AM
Changing permissions won't do anything.
The problem you're having is that the code that handles actual iPod accessories such as car kits and speaker docks is seeing the signals you're trying to input and failing to interpret them properly. (my guess is that with a car kit, it freezes the interface like it would do for a normal ipod?)
The idea of killing iapd and then trying your serial port tests was to make it so that your app is the only one using the serial port. Guess it isn't that easy.
I need to get myself a serial breakout dock or cable to play with.
TheRain
11-21-2007, 08:46 AM
Yes, I understand that. Well today I tried 500K ohm and that did not work. I don't think the freezing is because of the normal behaviors that are supposed to happen with an accessory because it freezes ALL functionality. For instance, my SSH terminal connection no longer responds to anything. I believe this is a safegard put in place to only allow authorized peripherals.
HOWEVER ;) I have found a way to get get serial input working now... it may not be the best solution, but it does work. I was starting to think I was going to go crazy because every so ofter (like once every 20 tries) serial input would NOT freeze the iphone and the data would reach my program. With the method I have found, the Iphone will still give a warning that the peripheral you have attached is not an official iphone peripheral. But after this it will work.
I'll release more details once I have a good demo of this, so that people don't steal the credit for finding it.
TheRain
11-21-2007, 08:50 AM
Actually, now I have found a method that does not give a warning about an unauthorized accessory being attached :)
enderffx
11-21-2007, 12:50 PM
TheRain,
apart from the serial stuff that you do ( i'd love to attach a serial gamepad for NES :-) ) i would LOVE to have that nasty Message killed !
Please whatever you do, let us know how to suppress that warning, will you ?
Greetings & THANX MAN !
Ender
TheRain
11-21-2007, 08:16 PM
Ender,
I'd be interested to know how you are coming across this message? I haven't found a way to supress it, per se, i've just found a way to get through to serial without having it come up, which is just a slight variation on the first way I found to get through to it.
cheaptec
11-22-2007, 10:25 AM
Excuse me, I'm wiki, you said have wrote a littel app. What compiler do you use? Can someone say me how or specify some link where find some docs about dev system for darvin on iPhone (iPod)? Many thanks.
enderffx
11-22-2007, 12:36 PM
TheRain,
i am just sticking the iPhone in my AUDI CarKit, so nothing interesting here :-)
All people using pre - iPhone accessories would love to have that stupid message disabled...
i hope to get the Toolchain up'n running sometime soon but already the pre-x-mas panic got its grip on me so the weekends are already quite filled up :-)
Ender
enderffx
11-22-2007, 12:42 PM
cheaptec,
look in the official wiki, the explain how to get the toolchain up and running on win / mac.
Its complicated, just read it :-)
http://iphone.fiveforty.net/wiki/index.php/Toolchain_Project
Ender
ThibThib
11-22-2007, 12:43 PM
TheRain, I am very interested by your method to send/receive data from Rx/Tx pins (you didn't mentionned them? Do you use these pins?).
I will be able to try it in few days (when my Ipod dock connector from Ridax (http://home.swipnet.se/ridax/connector.htm) will be arrived)
Some questions :
- is your warning message the one stored in your_rootfilesystem/System/Library/Framework/IAP.framework/English.lproj/Framework.strings ???
- is there a way to make our "device" reconized by the iPhone (or iPod Touch in my case) by editing the your_rootfilesystem/System/Library/Framework/IAP.framework/iapconfiguration.plist file ??
Do you have infos on it (maybe in PM if you prefere)
- what are the resistance you use ? 500Kohm
Thank you
Excuse me, I'm wiki, you said have wrote a littel app. What compiler do you use? Can someone say me how or specify some link where find some docs about dev system for darvin on iPhone (iPod)? Many thanks.
Hello Cheaptec. You will find infos you're looking for here (http://code.google.com/p/iphone-dev/wiki/Building) and here (http://www.cocoadev.com/index.pl?IPhoneRuntime)
TheRain
11-22-2007, 09:24 PM
Some questions :
- is your warning message the one stored in your_rootfilesystem/System/Library/Framework/IAP.framework/English.lproj/Framework.strings ???
- is there a way to make our "device" reconized by the iPhone (or iPod Touch in my case) by editing the your_rootfilesystem/System/Library/Framework/IAP.framework/iapconfiguration.plist file ??
Do you have infos on it (maybe in PM if you prefere)
- what are the resistance you use ? 500Kohm
- Yes that is the message. Seems like a strange message, doesn't it? Airlplane mode?
- On making our device recognized by the iphone, I'm not sure. I'm circumventing it even being recognized as an accessory at this point.
-I am using NO resistors. Part of the reason it took so long to experiment with this was because of all of the info out there on resistances, and the apple protocol. As it turns out, I can make the TX,RX act as a standard UART without using either. My I/O code on the Iphone is standard UNIX termios I/O code. The trick comes in at the accessory port itself.
TheRain
11-22-2007, 09:47 PM
TheRain,
i am just sticking the iPhone in my AUDI CarKit, so nothing interesting here :-)
All people using pre - iPhone accessories would love to have that stupid message disabled...
i hope to get the Toolchain up'n running sometime soon but already the pre-x-mas panic got its grip on me so the weekends are already quite filled up :-)
Ender
I know how you mean about the holidays. So do the old accessories work even though that message pops up?
cheaptec
11-23-2007, 10:29 AM
thank you enderffx.
enderffx
11-23-2007, 11:04 AM
TheRain:
so far they all worked, i have:
-A Car Kit made by Dension
-A Kensington FM-RDS Transmitter
-A Logitech Boom-Boom Box
The iPhone always complains but works :-)
If the Acc. tries to display something on the ipod screen ( like the FM Transmiter normally shows the chosen Frequency ) the iPhone simply ignores.
So i set up the FM Transmitter and the Car Kit with my wifes ipod and now use it on the iPhone...
cheaptec:
You're welcome :-)
Greetings,
Ender
TheRain
12-08-2007, 03:06 AM
Hi folks, my serial controller is not quite together yet. So tomorrow or Sunday I will make a more basic PC to Iphone serial demo and explain how it works so as to not keep people waiting. I'd love to see what cool things people do with serial port access anyway, so I want to release the details soon :)
doudoo
12-09-2007, 06:33 PM
WAOUW cant wait to have a gamepad to play gba and incoming psx emu :)
ThibThib
12-11-2007, 11:35 AM
Hi folks, my serial controller is not quite together yet. So tomorrow or Sunday I will make a more basic PC to Iphone serial demo and explain how it works so as to not keep people waiting. I'd love to see what cool things people do with serial port access anyway, so I want to release the details soon :)
Hello TheRain
Waiting for your demo.
If you want, I can test it for iPod Touch (i should be the same as with the iPhone).
Don't hesitate to post details.
Thank you
starkruzr
12-11-2007, 12:21 PM
WAOUW cant wait to have a gamepad to play gba and incoming psx emu :)
++ this is super exciting. Is there a project page for this somewhere so we can keep track and donate?
MuscleNerd
12-11-2007, 06:08 PM
ThibThib and starkruzr, TheRain started a different thread with a site you should visit (http://hackint0sh.org/forum/showthread.php?t=18904) :)
TheRain
12-11-2007, 08:21 PM
Oh yah, sorry for the confusion- I made a separate thread here http://www.hackint0sh.org/forum/showthread.php?t=18904
vBulletin® v3.7.3, Copyright ©2000-2008, Jelsoft Enterprises Ltd.