Hi ,

my program connect to old machine , the program received data
but with many symbols and unnecessary characters

any suggestion

thanks

this pic is the differnce between old program (VB) that receive with
arranged characters :

[IMG]http://i42.tinypic.com/2z9ch1d.jpg[/IMG]

Recommended Answers

All 4 Replies

thanks adatapost for the help , i saw this link before but i didn't found resolve to my probelm i think the problem related to ReadExisting because its read all buffer data this the reason why i see unnecessary characters
please help me thanks

=========

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();
          comport.ReadByte();


        // 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));
      }
    }

Hi ,

my program connect to old machine , the program received data
but with many symbols and unnecessary characters

any suggestion

thanks

this pic is the differnce between old program (VB) that receive with
arranged characters :

[IMG]http://i42.tinypic.com/2z9ch1d.jpg[/IMG]

You can either filter unwanted chars in the sender machine or filter out in your program if you can find a trend to setup your filter algorithm.

Fred

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.