I used this code for sending the data private void SendData() { if (CurrentDataMode == DataMode.Text) { // Send the user's text straight out the port comport.Write(txtSendData.Text); // Show in the terminal window the user's text Log(LogMsgType.Outgoing, txtSendData.Text + "\n"); } else { try { // Convert the user's string of hex digits (ex: B4 CA E2) to a byte array byte[] data = HexStringToByteArray(txtSendData.Text); // Send the binary data out the port comport.Write(data, 0, data.Length); // Show the hex digits on in the terminal window Log(LogMsgType.Outgoing, ByteArrayToHexString(data) + "\n"); } catch (FormatException) { // Inform the user if the hex string was not properly formatted Log(LogMsgType.Error, "Not properly formatted hex string: " + txtSendData.Text + "\n"); } } txtSendData.SelectAll(); } For the Recieving purpose I used private void port_DataReceived(object sender, SerialDataReceivedEventArgs e) { // This method will be called when there is data waiting in the port's buffer // Determain which mode (string or binary) the user is in if (CurrentDataMode == DataMode.Text) { // Read all the data waiting in the buffer string data = comport.ReadExisting(); // Display the text to the user in the terminal Log(LogMsgType.Incoming, data); } else { // Obtain the number of bytes waiting in the port's buffer int bytes = comport.BytesToRead; // Create a byte array buffer to hold the incoming data byte[] buffer = new byte[bytes]; // Read the data from the port and store it in our buffer comport.Read(buffer, 0, bytes); // Show the user the incoming data in hex format Log(LogMsgType.Incoming, ByteArrayToHexString(buffer)); } } now give me appropriate answer for my question. thanks a lot fro replying me.
Arpita Patel