The EAAccessory framework allows an iOS program to read from and write to external accessories connected via the dock connector or bluetooth. Any iOS program can access pretty much any external accessory.
Among the many dock connector pins, there are a handful devoted to a UART that theoretically allows access to external serial devices. On the other hand, accessories need to be blessed by Apple via the Made for iPhone program to work with non-jailbroken devices.
A company called Southern Stars sells a product called the SkyWire which effectively converts the dock connector on a non-jailbroken device to an RS-232 cable.