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.
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?
Originally Posted by CVB
If you run the phone with and without debug-uarts set are there any differences to the process running?
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.
Originally Posted by CVB
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.
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
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.
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??
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.
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.
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.