Author Topic: Some things gone wrong.....I think.  (Read 11831 times)

GlennP

  • Frequent Contributor
  • ****
  • Posts: 141
Some things gone wrong.....I think.
« on: January 11, 2012, 10:53:34 am »
Hi All,

I'm guessing this is the right place for this but in an app to interface to a board I have found an oddity,
the boards returns :

UD:0010=H2000950463700045160077129#0D#0D

this is picked up by my code as

UD:0010=H2000950463700045160077129 >23

it appears that the following happens the data comes back (why there is two line feeds I can find out my end) but #0D changing into ' >23' is a little strange, I would be expecting a 23 as thats the hex for #
but  space > or 20h 62h leaves me a little worried at the event handler

 private void port_DataReceived_1(object sender,SerialDataReceivedEventArgs e)   
        {
           // MessageBox.Show("Here!!");
          InputData = myComPort.ReadExisting();
          if (InputData != String.Empty)
          {
            this.BeginInvoke(new SetTextCallback(SetText), new object[]{ InputData});
          }
             
        }
  the set text function is

       private void SetText(string text)
        {
            this.rtbIncoming.Text += text;
            if (text.Contains("OK"))
            {
                return;
            }
            if (text.Contains("ERR - No Data"))
            {
                MessageBox.Show("ERR - No Data");
            }
            if (text.Contains("UD:"))
            {
                rtbIncoming.Text += '\r' + '\n';
                ProcessReturnedData();
            }

         
        }
         
     void ProcessReturnedData()
    {
       rtbReturnedData.Text += rtbIncoming.Text+'\r'+'\n';
    }



Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: Some things gone wrong.....I think.
« Reply #1 on: January 11, 2012, 11:16:44 am »
Check your Encoding. See this discussion:

http://www.lvr.com/forum/index.php?topic=683.0

Jan

GlennP

  • Frequent Contributor
  • ****
  • Posts: 141
Re: Some things gone wrong.....I think.
« Reply #2 on: January 11, 2012, 11:39:59 am »
Thanks I will look that over when I get chance!

Glenn