of course - if you are just about testing - attach your periperial as described in attaching peripherals to the serial port (just 3 pins, GND, Tx, Rx - no more need for the former specific “toggle GND” procedure with the most recent (Jan 2009) iPhone / iPod touch firmware) and use the minicom terminal program (can be installed via Cydia). As for the HW connections - this is a 3.3 V port - without any level shifters, so DON’t connect to your PC serial port directly.
the code referenced below is very basic - but should give you the idea how it works - accessing the serial port on OSX in C
This was once used for talking to another serially attached peripheral. Adapt the path to the serial port and the generation of sent / parsing of received data to your needs.