none
SERIALPORT DATA CONVERSION RRS feed

  • Question

  • Hi,

     

    am developing serial port application in .net compact framework device, i can get the serial port data normally, like { 0 1} or {1\r\n} . while am clicking 1 button.

     

     private void serialPort1_DataReceived(object sender, System.IO.Ports.SerialDataReceivedEventArgs e)
        {
          
    
    
          dr = serialPort1.ReadExisting();
    
          
          //textBox2.Text += dr;//.Trim();
    
          this.Invoke(new EventHandler(DisplayText));
     
    
    
        }
    
    
        private void DisplayText(object sender, EventArgs e)
        {
          //MessageBox.Show("reading");
          remcount++;
    
    
    
          textBox1.Text = "";
    
          textBox1.Text += dr.Trim();
    }

     

     

    but i need to convert the data into text format. like if i press 1  then i should get 1.. is possible to convert the data in .net compact framework.

     

     

    Please Suggest me to get the text format ?

    Saturday, December 18, 2010 1:07 PM

All replies

  • Hi Maanikmca,

    I don't understand your question, serialPort1.ReadExisting() will return data in string format, so what is the problem?

    Regards

    Fabrice

    Monday, December 20, 2010 7:04 AM
  • actually its returning value like 0 12 while pressing 12 volume increase button. when i compare with my string value its returning error.

     

    0 12 between o and 12 contains some values thats the value i could not find ?

     

     

    Monday, December 20, 2010 12:56 PM
  • You haven't told us anything about the data being sent.  So how can we possibly tell you what to do with the data?  You are telling us about "buttons", but what do buttons have to do with serial communication?


    Bruce Eitman (eMVP)
    Senior Engineer
    Bruce.Eitman AT Eurotech DOT com
    My BLOG http://geekswithblogs.net/bruceeitman

    Eurotech Inc.
    www.Eurotech.com
    Monday, December 20, 2010 3:48 PM
    Moderator
  • Hi,

     

    I need correct data while pressing remote button..now am getting value while pressing number 1 button [0 1]. this is how am getting while pressing a 1 button..

     

    i should get the data like 1 if i press button 1 in remote ..

     

    is that possible ?

     

     

    Tuesday, December 21, 2010 4:38 AM
  • Again, what data is sent?  You are focused on the receiver, but the issue may be with the sender.  If you want to receive valid values, you must send valid values.  So if you want to receive a 1 then the sender must send a 1.

    Again, what does a button have to do with serial communications?  I do see that you added "remote" but that still doesn't tell us anything about the serial communications on either the sender or the receiver.

    It is possible that your sender is sending key codes, but that is hard to say since we know nothing about your sender other than it appears to be a shirt with buttons.


    Bruce Eitman (eMVP)
    Senior Engineer
    Bruce.Eitman AT Eurotech DOT com
    My BLOG http://geekswithblogs.net/bruceeitman

    Eurotech Inc.
    www.Eurotech.com
    Tuesday, December 21, 2010 2:09 PM
    Moderator
  • Exactly!  What corresponds to the "1" button?  The ASCII character "1", or the binary value 0x01, or something completely different?  There's no magic where the serial port code will somehow interpret the data for you and understand what you want; that's what YOU get paid to do.

    Paul T.

    Monday, December 27, 2010 4:16 PM