Pages: [1]   Go Down
Author Topic: c# question reading comport  (Read 685 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Full Member
***
Karma: 2
Posts: 212
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I am writing a program in c#, actually i am just learning c# now.

My current program is able to read dummy data series and display it on a graph, (not bad for 2 days c# )
It looks quite well it will show the last 100 measurements in various ways.
If each measurement is based on multiple reading then those are just other lines in the graph.

but now the bad part.. i'm unable to read serial data events i cannt use static event functions to work (cause i dont know how they would call a normal privat function). or i get other kind of errors, its troublesome in short i got multiple kinds of errors trying realize it. if i remove the staic parts it wont work also.. in short I am able to get the data representation part working. but not the serial read part.
(and yes the serial port connector is dropped on Form1), i find it hard to point where it goes wrong sometimes the code runs but just doesnt give an error, and no serial data is read.

Someone care to help? 
posting here a sample in C# for reading a line   {arduino code uses serial.println(string)}  from a serial event, and display it in a textbox
Such a sample i be able to rewrite into my program.
Logged

the land of sun+snow
Offline Offline
Faraday Member
**
Karma: 149
Posts: 2790
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

It's not quite as simple as you may think. You have to use C# multitasking
functions, and run the serial routines in the background and your Forms
in the foreground, and bind them together using Delegates so you don't
crash the computer. Take a look at the code in the Smileys Workshop ZIP
file on this page for starters. It has both VB and C# code.

http://smileymicros.com/blog/2011/06/10/serial-communications-part-2-a-simple-terminal-2/
Logged

Offline Offline
Full Member
***
Karma: 2
Posts: 212
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

actually this is a real good answer, with this i dive deeper into c#
just as i wanted to understand the language gimmicks
Logged

Pages: [1]   Go Up
Jump to: