Click here to Skip to main content
12,942,930 members (70,007 online)
Rate this:
Please Sign up or sign in to vote.
See more:
i want to read the data from USB Port continuously as soon as i press a button and Open a dialog box in MFC? Pls someone help me out?
Thanks in Advance.
Posted 15-Jun-12 22:47pm
Updated 15-Jun-12 22:49pm
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

No, you don't.

What you actually want to do is handle the SerialPort DataRecieved messages, and process each byte as it arrives, or transfer them to a buffer for processing in the background.

If you try to read continuously, you will lock up your UI and annoy your users...
Anurag Kela 16-Jun-12 5:19am
i didn't get you? i want to read the response generated by my hardware on Printer keystrokes as soon as dialog opens.
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

There are several applications like that here on CP - search and look through them. Here is one to get you started: CSerialIO - A Useful and Simple Serial Communication Class[^]

You tagged C++, so that is the example I added here. There are other nice projects in C# if you are interested.

Soren Madsen
Anurag Kela 16-Jun-12 5:17am
i have gone through your project before and it really helps to understand the serial communication concept for the freshers like me.
i will tell u what m trying to do.
i m sending a command to my hardware on a button click event and after that m opening a new dialog and i want to read the data from USB as soon as the dialog initializes or simultaneously
Anurag Kela 16-Jun-12 5:34am
My Project deadline are too close n i have to do something on it by monday so pls help me out?

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

    Print Answers RSS
Top Experts
Last 24hrsThis month
OriginalGriff 4,633
CHill60 2,880
Maciej Los 2,268
Jochen Arndt 1,900
ppolymorphe 1,755

Advertise | Privacy | Mobile
Web02 | 2.8.170518.1 | Last Updated 16 Jun 2012
Copyright © CodeProject, 1999-2017
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