I've tried several hours but could not hit my target.
My project is an interfacing program that can send and receive data from the com port. Now I can send data to the com port. Here is the code (It's very simple. You can go through it in few minutes.)
The design "Form1" contains 6 NumericUpDown components (X,Y,Z,yy,pp,rr) , 2 textboxes (TextBox1 and LogBook) and a button called "send".
My sending format is "X,Y,Z,yy,pp,rr" + "\n". Such a string is sent when the button is pressed. Also, it's presented in the textbox called "LogBook".
The program can send data of such format without any problem but when I add some codes (in bold letters shown below), I cannot manage to receive data from the serial port.
I've just modify the first program, adding several lines (the ones followed with "//add") to form the one shown above. My purpose is to put the data read from sp.ReadLine() into the "LogBook" textbox. (In this way, the "LogBook" textbox will contain both sent and received data.)
However, this program fails to work. I know the problem is that: in the static "Read method", LogBook.Text cannot be accessed. But I haven't come up with an idea to change this program so that it can receive data and present them in the "LogBook" textbox.
How should I attain my goal base on the first program? I mean how should I add codes to it.
Is there anyone that can help me? Take your time. I'm really worry about it. The deadline of the project is approaching.
Question
bobbygd
:cry:
I've tried several hours but could not hit my target.
My project is an interfacing program that can send and receive data from the com port. Now I can send data to the com port. Here is the code (It's very simple. You can go through it in few minutes.)
The design "Form1" contains 6 NumericUpDown components (X,Y,Z,yy,pp,rr) , 2 textboxes (TextBox1 and LogBook) and a button called "send".
My sending format is "X,Y,Z,yy,pp,rr" + "\n". Such a string is sent when the button is pressed. Also, it's presented in the textbox called "LogBook".
The program can send data of such format without any problem but when I add some codes (in bold letters shown below), I cannot manage to receive data from the serial port.
I've just modify the first program, adding several lines (the ones followed with "//add") to form the one shown above. My purpose is to put the data read from sp.ReadLine() into the "LogBook" textbox. (In this way, the "LogBook" textbox will contain both sent and received data.)
However, this program fails to work. I know the problem is that: in the static "Read method", LogBook.Text cannot be accessed. But I haven't come up with an idea to change this program so that it can receive data and present them in the "LogBook" textbox.
How should I attain my goal base on the first program? I mean how should I add codes to it.
Is there anyone that can help me? Take your time. I'm really worry about it. The deadline of the project is approaching.
Thank you very much!!
Link to comment
https://www.neowin.net/forum/topic/485716-chow-can-i-receive-data-through-serial-port/Share on other sites
5 answers to this question
Recommended Posts