This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Indication when serial port is closed

Halo to everyone,

I'm trying to make some serial communication between c# windows application and my MCB2300 with LPC2378.

I don't know how to indicate end of message. Is there some function to signal when serial port is closed? Or does anyone know some another way to solve this problem?you


Thank you a lot,

Bojana

  • Hmm, I'm not sure I understand the question correctly.

    -If I do, then...

    No, there's no way to indicate that a serial port is closed.

    You can connect anything to a serial port, then make this "anything" send a character to that port, and that character will be received if there's a serial port driver available.

    Eg. a serial port is not a file or pipe. It's simply put just 3 wires, and you can send data on it anytime you wish.

    It's not like TCP/IP, where you need to open a connection, and send data, then close the connection.

    The serial port is always "open".

    So what you will have to do, is to write a protocol. In the old days, we had a simple transfer protocol called X-modem. This is probably too simple for what you want to do. But it demonstrates how handshaking works; eg. a file is sent from one device to another device, and a minimum of checking is done, so that the receiving device can be more or less sure that the data arrived in good condition.

    X-modem CRC is a better choice. Z-modem is complicated but much safer.

    Remember: In the middle of the transfer, someone could just unplug the serial cable - just for the fun of it - without telling you.

    Thus you must ensure that all your data have been received in good condition, before you start using them.