How to detect Serial or TTL signal for a PIC?
Simple steps as follows...

The first step is to disable the driver attached to the PIC (No point damaging the equipment with excessive voltage)

Then monitor the in coming signal from the device and detect if they are Negative Wiki RS232 Voltage wave form

Then decide which mode the PIC should use. TTL is only positive. RS232 has a good -V and +V swing around 0V. It may be a good idea to detect more than -1V just in case of noise etc.