Orin Eman wrote: > On 10/21/06, Genome wrote: >> I'm thingking of setting DTR on from the PC side when connecting and >> then the device on the other end should reply by setting DSR on.. and >> keep them on while connected. just like a modem.. to detect a >> connection and sudden disconnection.. im thinking of always querying >> this pins before sending and receiving couple it with some error >> handling routine to tell if the cable is good or not. > > Pretty much using the pins for their intended purpose. Sounds good to > me! Except that it wastes two pins, as Jan-Erik says, without any benefit -- at least not one that I could spot. You probably need some kind of packet/error detection structure anyway. So sending out a start marker (or a whole packet; depending on the length of the packets) and waiting a short time for the correct response seems good enough. If the response doesn't come, you just assume that there's no device connected and repeat the check. When there's a correct response, you assume a device connected. On the device side, you don't respond unless you receive a complete and correct start marker (or packet, see above). I can't imagine what the pins would detect that this doesn't. You can hook up an interrupt to the pins and detect the (relative) exact moment when the device gets removed from the serial port, but is this important? Or is it good enough that you know whether a start marker or packet gets responded to correctly (indicating the presence or not of the device)? BTW, the modem analogy is not quite correct. The status pins in the communication with a modem serve their purpose because the PC (or whatever DTE) is not actually communicating /with/ the modem (normally): it is communicating with another device /through/ the modem. So the protocol (whatever it is) on the TxD/RxD lines is not the modem protocol, it is the protocol of the device on the other end of the line. The status pins help maintaining the communication with the modem while the devices and the ends of the line communicate with each other. Designing something like this from scratch today, you'd probably just pack a modem control protocol on top of something like TCP/Ethernet or USB and be done with it -- no status lines. Gerhard -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist