Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
hello all,,
I'am a student (i'am sorry if my english very bad)
 
I have a little problem with the GUI and microcontroller project that I created,
I will send two sample data from the microcontroller to the computer using serialports, I sent from the microcontroller using the C language printf ("@% 02d% 04d \ r", temp, count);
i sent using serialports setting on CodeVisionAVR compiler software:
/ / USART initialization
/ / Communication Parameters: 8 Data, 1 Stop, No Parity
/ / USART Receiver: On
/ / USART Transmitter: On
/ / USART Mode: Asynchronous
/ / USART Baud Rate: 9600
 
when the GUI is run the data received and displayed on a RichTextBox looks so perfect, the data are shown like with the transfer by the microcontroller.
but when data is received and i split it with two variables temp and count, I found the problem there.
I want to get the data to ( double or integer variabel) clean and precise. Can you help me??,, i'am very happy for that
thank you.
 
tihis script on my GUI visual C#
private string RxString;
private void serialPort1_DataReceived
(object sender, System.IO.Ports.SerialDataReceivedEventArgs e)
{
RxString = serialPort1.ReadExisting();
this.Invoke(new EventHandler(DisplayText));
}
 
private string data_all,head,data1,data2;
private double data1a,data2a;
private void DisplayText(object sender, EventArgs e)
{
richTextBox1.AppendText(RxString);
if(RxString.Length >= 8)
{
head =RxString. Substring(0, 1);
if(head == '@')
{
data2 = RxString.Substring(1, 2);
data1 = RxString.Substring(3, 4);
data1a = Convert.ToDouble (data1);
data2a = Convert.ToDouble(data2);
this.segmentGauge1.Value = data2a;
this.segmentGauge2.Value = data1a;
}
}
}
Posted 2-Jun-12 18:45pm
Comments
SAKryukov at 3-Jun-12 1:37am
   
Script? Let's start with the obvious: C# is not a scripting language. Now, what's your question?
--SA
tetuko99 at 3-Jun-12 4:10am
   
point of my problem is,,
i want to get numeric data (int or double) from texbox data viewed.
but that my be real ??

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



Advertise | Privacy | Mobile
Web01 | 2.8.1411022.1 | Last Updated 2 Jun 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100