Pages: 1 [2] 3   Go Down
Author Topic: cannot read the data from arduino to the c#  (Read 4648 times)
0 Members and 1 Guest are viewing this topic.
Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 597
Posts: 33314
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

that's means it will not read the data into gui?
No it will read data if you send it data and if you write the code correctly.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 39
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

PaulS, my problem now, the serialport is open..however the data cannnot be uploaded in the WPF?
if every function im doing the threading part..is it works to received the data in synchronous manner?
im handle the serial port class in one threads and the data in another threads..
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48543
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Did you try running my application? Did you look at how it handles the serial data in one thread and communicates with the GUI thread?
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 39
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

yes.n i have take a look on the threading..when i click on the button..it says "The port is already open". However there is no data appeared on the WPF.it appeared in the console application and arduino serial monitor but not in the WPF C# application.
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48543
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
when i click on the button..it says "The port is already open". However there is no data appeared on the WPF.
Are you trying to run my application and the serial monitor at the same time?

If my application can't open the serial port, is it any wonder why no serial data appear on the form?
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 39
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

there's an error " Couldn't find input file"Properties\Resources.resx.what thats mean?
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48543
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
there's an error " Couldn't find input file"Properties\Resources.resx.what thats mean?
p
The file is in the zip file I attached.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 39
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

yes.i have extracted the file..
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 39
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

the result of the code is appeared in the serial monitor of the arduino and on the console application...however the data is not appeared on the windows form? is there any wrong with my code?

* Program.zip (318.31 KB - downloaded 14 times.)
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48543
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

When I click on the zip file, I get:
Quote
Error 503 Service Unavailable

Service Unavailable
Guru Meditation:

XID: 1078454701

Varnish cache server
So, if you could please varnish the cache server again, that would be good.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 39
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

hi PaulS, attached is my code that will received the arduino data.

* FloodDetection.csproj (3.76 KB - downloaded 13 times.)
* Program.cs (0.5 KB - downloaded 17 times.)
* Form1.cs (16.99 KB - downloaded 39 times.)
* Form1.Designer.cs (13.3 KB - downloaded 17 times.)
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48543
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Can't read them, either. I posted in Website and Forum about the problem. When the new coat of varnish dries, I'll try again.
Logged

Indiana
Offline Offline
Jr. Member
**
Karma: 1
Posts: 61
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Let me make sure I understand correctly.

1. Your Arduino is running code outputting data to serial port.
2. You want the data Arduino is sending to serial port to be read into your C# program and displayed on a Windows Form.

I think you have your read and write backwards.  You aren't trying to WRITE the output from serial to your C# GUI, you want to READ the output from Arduino, into your C# program and then display it in the GUI.

set a string variable in C# = sp1.readline()

Then set the GUI element ".TEXT" field = to the string variable you created to display it.
Logged

0
Offline Offline
Tesla Member
***
Karma: 141
Posts: 9470
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Simple serial monitor test code that sends back what is sent to the arduino. If this works, then the issue is with your pc code. If your pc code opens/closes the pc com port on each write, that will cause the arduino to reset each write.

Code:
// zoomkat 7-30-11 serial I/O string test
// type a string in serial monitor. then send or enter
// for IDE 0019 and later

String readString;

void setup() {
  Serial.begin(9600);
  Serial.println("serial test 0021"); // so I can keep track of what is loaded
}

void loop() {

  while (Serial.available()) {
    delay(2);  //delay to allow byte to arrive in input buffer
    char c = Serial.read();
    readString += c;
  }

  if (readString.length() >0) {
    Serial.println(readString);

    readString="";
  }
}


Logged

Consider the daffodil. And while you're doing that, I'll be over here, looking through your stuff.   smiley-cool

Offline Offline
Newbie
*
Karma: 0
Posts: 39
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

you are right ,jjspierx

im just receiving the latitude sent by the transmitter and display on GUI.does the code for dispalying the latlong making any sense?
Logged

Pages: 1 [2] 3   Go Up
Jump to: