473,772 Members | 2,412 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

getting data through serial port

Hi,

I know that the System.IO.Ports .Serial port event for receiving data
(DataReceived) happens on a secondary thread, and that if there will be any
interaction of that data with the UI, it should be done through invoke.

Right now my application receives serial data and a class hierarchy is
responsible for handling it.
If I run the application, everything seems to work fine, but if I put a
breakpoint on it and try to follow, the weirdest things happen. For example,
sometimes it gives error messages, sometimes the application just stops
(vanishes is the correct word) and some other times VS IDE halts and
completely goes away. That usually happens if I put the mouse over any
variable and try to inspect its value.

For me it smells like threading problems (and if it smell like a duck and
walk like a duck...).

What is the best practice on handling the received data once it arrives (and
triggers the event) on the serial port? Do I have to synchronize it with the
main app thread?

Cheers

Padu
May 25 '06 #1
2 3468
If you have data that both are accessing yes you have to synchronize them.

Cheers,

Greg Young
"Padu" <pa**@merlotti. com> wrote in message
news:ze******** ************@is west.net...
Hi,

I know that the System.IO.Ports .Serial port event for receiving data
(DataReceived) happens on a secondary thread, and that if there will be
any interaction of that data with the UI, it should be done through
invoke.

Right now my application receives serial data and a class hierarchy is
responsible for handling it.
If I run the application, everything seems to work fine, but if I put a
breakpoint on it and try to follow, the weirdest things happen. For
example, sometimes it gives error messages, sometimes the application just
stops (vanishes is the correct word) and some other times VS IDE halts and
completely goes away. That usually happens if I put the mouse over any
variable and try to inspect its value.

For me it smells like threading problems (and if it smell like a duck and
walk like a duck...).

What is the best practice on handling the received data once it arrives
(and triggers the event) on the serial port? Do I have to synchronize it
with the main app thread?

Cheers

Padu

May 26 '06 #2
"Greg Young"
If you have data that both are accessing yes you have to synchronize them.

Cheers,

Greg Young

The think is that right now, no, there's no thread concurrency. The problem
only happens in the debugger, and it happens very uglyly. So I was wondering
if I'm doing things the correct way.

Cheers

Padu
May 26 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
11164
by: Tom Van Ginneken | last post by:
Hi, I need to write binary data to a serial port. I am using this function: #include <unistd.h> ssize_t write(int fd, const void *buf, size_t count); I am able to write a alpha-numeric character to the port using this: write (filedescriptor,"a",1);
1
2551
by: kiran | last post by:
Hi all, I have a problem to communicate with serial port(COM3:). I am able to open the handle but cannot send any data. 1. I connected my motoroala handset to PC through datacable. 2. I installed valid driver to detec the motorla(V400) handset 3. I tested the handset through Hypertermal and succssfully sending any data. 4. I opened the Control Panel -> Phone and Model window and clicked the modem tab and I saw that the Motorola...
4
17821
by: Frank | last post by:
Hello, how to get information about all serial ports in the PC? I use the following code, but i got only the data of the FIRST serial port. All other serial port information are not available with this code sample: ManagementObjectSearcher searcher = new ManagementObjectSearcher("Select * from WIN32_SerialPort");
2
3018
by: wesolutki | last post by:
Hi, how to send data to other application by serial port? I want to have two programs opened on one computer, one send and second recive data, but using serial port. Wesolutki :-)
2
6184
by: Lou | last post by:
I have a class that creates an instance of the seril Port. Every thing works fine except whenever I receive data I cannot display the recieved data. I get no errors but the recived data seems to just go no where. I can see the recived data in my serial receive function but when I either raise an event with it or try to display it in a text box nothing happens. I do use beginInvoke on the text box. If I trace the code through it all...
7
4083
by: Lou | last post by:
I have a class that uses the serial port class Private SerialPort as New SerialPort When I receive the asyncronous serial port response it appears that data is on a different thread than my UI. When I try to raise an event in my class my frmMain doesn't get the callback. i think this is a threading issue. Question is how do I get the serial port response from my vb class to my main form.
1
15099
by: Rich | last post by:
Hello, I am working on a python library for sending and receiving data from a Subaru's ECU (the fuel injection computer) via the OBD-II port and an OBD to USB cable, with the Subaru Select Monitor protocol. There are a few open source programs that do this already (http://romraider.com/ , http://jdash.sourceforge.net/ , http://tari.co.za/downloads/software/source/ ), but they are written in Java or C++. I have never done anything with serial...
0
3788
by: =?Utf-8?B?Q2hhcmxpZQ==?= | last post by:
Hi, This apparently is a common problem and I've yet to read a solution that actually works for my specific situation. I have a Zebra RW220 printer that I connect to via Bluetooth connection mapped to a serial port. The application I'm writing runs on a Windows Mobile 5 device, so there's no built in printer support and I have to use a serial port.
6
8469
by: anu29dolly | last post by:
Hello everyone... I have written a program to write and read data from serial port.... I am able to write 80(in binary)..and is expecting 1B but i am uable to read it... My code goes as follows,,.... int main()
0
10261
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10103
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8934
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7460
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6713
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5482
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4007
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3609
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2850
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.