Visual C++ to read Strings from Serial Port

Hi.

I'm doing a project using Visual C++ to read data from Serial Port. My
program needs to do *something* when it receives specific data. For eg,
if the program receives "Alarm 1 Zone 4", it will do something.

The data received will be variable in length. My questions:

1) Any recommendations for the serial Comm Class for Visual C++?
2) How can i compare the data i receive from serial to the specific
messages i'm looking for, eg data types, size of data types,
limitations & etc.?

Thanks. Any comments are highly appreciated.

Leng

0
1/16/2007 5:23:55 PM
vc.mfc 33608 articles. 0 followers. Follow

4 Replies
1645 Views

Similar Articles

[PageSpeed] 21

As far as the serial part goes, it is pretty simple take a look at the 
CreateFile function.

Here are some examples:

http://www.codeproject.com/system/chaiyasit_t.asp
http://www.naughter.com/serialport.html
http://www.codeguru.com/Cpp/I-N/network/serialcommunications/article.php/c5425

As far as reading data from the port.  Once you have opened the com port, 
you will need a worker thread the pulls the port for data. When you receive 
data you will be responsible to parse the data and interpret it's meaning. 
Without knowing how the data is being sent to you it's hard to make 
recommendations.

AliR.

"albertleng" <albertleng@gmail.com> wrote in message 
news:1168968235.421739.228000@a75g2000cwd.googlegroups.com...
> Hi.
>
> I'm doing a project using Visual C++ to read data from Serial Port. My
> program needs to do *something* when it receives specific data. For eg,
> if the program receives "Alarm 1 Zone 4", it will do something.
>
> The data received will be variable in length. My questions:
>
> 1) Any recommendations for the serial Comm Class for Visual C++?
> 2) How can i compare the data i receive from serial to the specific
> messages i'm looking for, eg data types, size of data types,
> limitations & etc.?
>
> Thanks. Any comments are highly appreciated.
>
> Leng
> 


0
AliR3470 (3235)
1/16/2007 6:04:31 PM
Here is another one.

http://www.codeguru.com/Cpp/I-N/network/serialcommunications/article.php/c5395


AliR.

"AliR (VC++ MVP)" <AliR@online.nospam> wrote in message 
news:Ps8rh.23694$sR.9271@newssvr29.news.prodigy.net...
> As far as the serial part goes, it is pretty simple take a look at the 
> CreateFile function.
>
> Here are some examples:
>
> http://www.codeproject.com/system/chaiyasit_t.asp
> http://www.naughter.com/serialport.html
> http://www.codeguru.com/Cpp/I-N/network/serialcommunications/article.php/c5425
>
> As far as reading data from the port.  Once you have opened the com port, 
> you will need a worker thread the pulls the port for data. When you 
> receive data you will be responsible to parse the data and interpret it's 
> meaning. Without knowing how the data is being sent to you it's hard to 
> make recommendations.
>
> AliR.
>
> "albertleng" <albertleng@gmail.com> wrote in message 
> news:1168968235.421739.228000@a75g2000cwd.googlegroups.com...
>> Hi.
>>
>> I'm doing a project using Visual C++ to read data from Serial Port. My
>> program needs to do *something* when it receives specific data. For eg,
>> if the program receives "Alarm 1 Zone 4", it will do something.
>>
>> The data received will be variable in length. My questions:
>>
>> 1) Any recommendations for the serial Comm Class for Visual C++?
>> 2) How can i compare the data i receive from serial to the specific
>> messages i'm looking for, eg data types, size of data types,
>> limitations & etc.?
>>
>> Thanks. Any comments are highly appreciated.
>>
>> Leng
>>
>
> 


0
AliR3470 (3235)
1/16/2007 6:06:05 PM
For serial port communication w/MFC, check this out:

http://www.naughter.com/serialport.html

-- 
Ajay Kalra [MVP - VC++]
ajaykalra@yahoo.com


"albertleng" <albertleng@gmail.com> wrote in message
news:1168968235.421739.228000@a75g2000cwd.googlegroups.com...
> Hi.
>
> I'm doing a project using Visual C++ to read data from Serial Port. My
> program needs to do *something* when it receives specific data. For eg,
> if the program receives "Alarm 1 Zone 4", it will do something.
>
> The data received will be variable in length. My questions:
>
> 1) Any recommendations for the serial Comm Class for Visual C++?
> 2) How can i compare the data i receive from serial to the specific
> messages i'm looking for, eg data types, size of data types,
> limitations & etc.?
>
> Thanks. Any comments are highly appreciated.
>
> Leng
>


0
ajaykalra (6842)
1/16/2007 6:07:24 PM
http://www.codeproject.com/system/cserialcom.asp will be helpful ........

secondly when u go to this lower level, u get only raw data ......

or are u expecting serialized data on port ....
if yes then u may think of compatible deserialization .....

"albertleng" <albertleng@gmail.com> wrote in message 
news:1168968235.421739.228000@a75g2000cwd.googlegroups.com...
> Hi.
>
> I'm doing a project using Visual C++ to read data from Serial Port. My
> program needs to do *something* when it receives specific data. For eg,
> if the program receives "Alarm 1 Zone 4", it will do something.
>
> The data received will be variable in length. My questions:
>
> 1) Any recommendations for the serial Comm Class for Visual C++?
> 2) How can i compare the data i receive from serial to the specific
> messages i'm looking for, eg data types, size of data types,
> limitations & etc.?
>
> Thanks. Any comments are highly appreciated.
>
> Leng
> 


0
mm9402 (8)
1/16/2007 6:07:43 PM
Reply:

Similar Artilces:

Outlook 2007 Reading Pane
I am desperate for help with respect to the Reading Pane in my Outlook 2007. It simply isnt working also i seem to have no keyboard shortcuts operable when i try to use them. Are there any bug reports with the Reading Pane and are there any fixes proposed.. have to say Outlook 2007 seems incredible buggy to me. Appreciate help Thank you "Andy" <andy.parry@btinternet.com> wrote in message news:%23T42lVnwJHA.248@TK2MSFTNGP06.phx.gbl... >I am desperate for help with respect to the Reading Pane in my Outlook 2007. >It simply isnt working also i seem to have no key...

Search CSV for string.
Hi, I'm using Excel 2003 and have a macro that allows a user to select files in a sub directory, does a search for specific data in each file, extracts data in another column if there is a match, etc. I also require that the user can select a single file. I tried to modify the code I have, but it will not work. Any help would be appreciated..... this is what I have tried: Sub GetSingleFile() Dim FileName As Variant FileName = Application.GetOpenFilename If FileName = False Then Debug.Print "user cancelled" Else Debug.Print "file selected: " ...

Using Visual C++ 6.0 MFC Application
01/19/2004 Using a single document or a dialog application, I am able to use my own variables that are declared in the same source file, however, if I try to declare a global variable in a header file or a source file included before the code I am using, I get the error "Undeclared Identifier". Example in Old C: "First.h" int i; "Main.cpp" #include "First.h" main() { i=5; printf("%d",i); } When I declare a variable in a header file, in Class View - Globals, my variable does show up, b...

xml utf-8 String to XPathDocument
Hi; I have a string that is an xml file. It starts with <?xml encoding='utf-8'... and it has the utf-8 2-byte sequences as 2 chars. How do I get that into an XPathDocument where the 2-char sequences are not treated as 2 characters? -- thanks - dave Hi dave, You don't need to care about the encoding, just create an XPathDocment object with the filename as the constructor's parameter. Or you can load the file into a stream and open the XPathDocument from the stream. Kevin Yu ======= "This posting is provided "AS IS" with no warranties, and confers no ...

How to read data from valentina db?
Hi Experts, I've got a data source that comprises of 3 files as; somedb.dat, somedb.ind and somedb.vdb which I guess belongs to a valentina database. I'd like to know if there's anyone who has dealt with such data and was able to import/parse the data form these files. And of course how. Any help, code, pointers would be highly appreciated. Thanks in advance. Alp I've never heard of "a valentina database." The file/database/spreadsheet formats that Access supports are options in the File | Get External Data dialogs. If the valentina database can not expor...

Standard Visual Basic vs Visual Basic for Applications
I've recently purchased Front Page and understand that I can code with Visual Basic as part of this software package. 1. What does Front Page contain: Standard Visual Basic or VBA? 2. Do either or both work with Visual Studio? 3. Is Visio different from Visual Studio? -- Deb Front Page and Visio are both Microsoft Office applications that contain VBA (Visual Basic for Applications). These programs are productivity applications first and programming platforms second. Visual Studio is a pure programming application. (All it does is let you write other programs.) Older versions of ...

very basic MS access 2007 (button click no read issue)
I added 2 text fields and a button to a form in MS access 2007. and i went to the code builder and tried to add values to the text fields . ex: textBox1.text = "name" i coded this to the button click event.. but some times after i get an error.. the button click property never works... so i have to create a new form and redo it. can some one tell me why this is hapenning , and tell me a way to prevent this.. In Access, you can only use the text property if the control has the focus. Instead, try: textbox1 = "Name" or textbox1.Value = "...

intermittent access to public folders PLEASE READ!!
I have about ten users that cannot access one public folder tree off and on. They can access all other folders without error. The folder is a third level folder, and all permissions are set at the root. Both Default and Anonyms have contributor permission all the way down the tree. If I add the users directly to the fold they gain access for a few hours, then they cannot access again. There is a 1000 users in the enterprise, and everyone else is not having any problems. ANY IDEAS would be great. How many servers you have? If there are several it might be replication problem. Or ...

Excel Viewer Won't Read xls file!
Was emailed an xls file so downloaded Excel Viewer, but even though the Excel Graphic has appeared on the file, when I try to open it Excel Viewer 2003 says it can't open files of this type. Running XP SP2 on a Dimension 8250.. Ideas would be appreciated One can name and rename a file just anything, the .xls extension is no guarantee that the file has anything to do with excel. Does the viewer open files that you know for sure are excel files ? HTH. Best wishes Harald "Graham Jones" <GrahamJones@discussions.microsoft.com> skrev i melding news:655D550D-2961-41AC-96A...

HP Image Editor files default to C:\ directory
Re: HP 3970 Scanner Hello Everyone: Maybe someone here has or has used this scanner and knows the answer. I will make my question as straightforward as possible. Once I have scanned an image and 'saved it,' it defaults to the C:\ directory unless I choose another location. If it is saved in another directory, it will not show up on the image editor so I unable to print or edit the image. Is there a way to change the settings so that an image is automatically saved to a default location other than C:\ or do I have to move an image to the C:\ location each time I ...

I Visual Basic Error "File Not Found" when Excel opens
Good afternoon. I am using XP Pro at work and My computer just started doing this. when I open Excel, I get a message pop up that says in title "Visual Basic Error" and in body of error window is "File Not Found". If I click on help, says something about error 53 but when I try to look that up on Microsoft's website, can't find what seems to apply to my issue. And now when I go into my personal.xls to view my macros, I can get in, but if I try to save anything, I get a window pop up saying Excel must be shut down, and then a window pops up asking me if I want...

C-DLL-VBA-EXCEL strings
Hello, I'm trying to connect excel to a C dll library (call C dll from excel through the VBA). It works well for returning integer and double values (see simple example below), but I can't seem to get it to return strings. I am using MinGW gcc (so basically only C) to construct my dll, so I don't have access to BSTR and other cpp like objects/functions... Is there a way to make the C dll return strings to excel? Thanks DLL.c #ifdef BUILD_DLL #define EXPORT __declspec(dllexport) #else #define EXPORT __declspec(dllimport) #endif EXPORT int __stdcall add2(int num){ return num + 2; ...

Those of you with a 0x8004210A error message on Outlook 2003's Internet Mail, read this. I've made it work here
Hi everyone I'd been fighting this one for some time and finally got things working today. I noticed there were lots of questions about it on these newsgroups and not many answers (no offense, just what I found). Anyway, I got tipped off by an article on the Microsoft site, but one I found by accident. Here's what I did: I searched the entire system drive for the Inetcomm.dll file, and found two. One was iirc in Windows' SYSTEM32 folder, the other in some ServicePackSomething folder. The files were different versions (the SYSTEM32 one being newer, as expected). What I did was...

reading from chart
I'm not sure how to check a given value against a chart in the spreadsheet to find a corresponding value in the chart. If there is a value 25 let's say in a cell, I need to be able to look for 25 in a chart and find the value that corresponds to it. I don't even know where to begin. -- Thanks, Jim You could use programming to find a number in a table, and return its row and/or column number. Is that what you're trying to do? Jim wrote: > I'm not sure how to check a given value against a chart in the spreadsheet to > find a corresponding value in the chart. ...

Don't mark as read?!?
I have a shared email account through exchange 2000 that is accessed through Outlook 2000. When I get new mail it is bold (meaning it's unread), however when I click on the message onece it unbolds and goes as read. I only want it to mark it as read if I double click and open the email. Is there anyway to change this feature to actually opening the email only instead of just (single click) selecting it, in order to mark as unread? Tools->Options->Other->Advanced=>Preview Pane. --� Milly Staples [MVP - Outlook] Post all replies to the group to keep the discussion in...

C++ equivalent?
Hi, In c# where I would access a named property of a chart series like: series["DrawingStyle"]= columnStyle; But I can't figure out how to do the equivalent in c++. Where a 'normal' property would be set like this in c++: series->MarkerSize= markerSize; c# series.MarkerSize= markerSize; Thanks, Dan. On 23-04-2010 17:41, DanB wrote: > In c# where I would access a named property of a chart series like: > series["DrawingStyle"]= columnStyle; > But I can't figure out how to do the equivalent in c++. > > > Wher...

Looking for Visual C++ programmer with MS SQL Server 2005 to work off-site on small project
Looking for Visual C++ programmer with MS SQL Server 2005 to work off-site on small project. Please send me an email to: larryTAKEOUT@seldin.net Lawrence M. Seldin, CMC, CPC Contributing writer for FUTURES Magazine Author of RECRUITSOURCE PEOPLESOFT EXAM and RECRUITSOURCE SAP/R3 EXAM Author of POWER TIPS FOR THE APPLE NEWTON and INTRODUCTION TO CSP NOTE: To send me an email, remove TAKEOUT from my email address: larryTAKEOUT@seldin.net NOTE: My web home page: www.seldin.net ...

Error: Memory could not be read
I am running a Multithreaded VC application and some times I am getting the error in my application when it runs on the production server. "The instruction ********** referenced memory at "***********". The memory could not be read. Click OK to terminate the program. Click on CANCEL to debug the program. But when I test the same on other machines I am unable replicate . As it is production server I am unable to Debug in that system. Both systems have same configurations (windows XP professional, 2002 version, service pack1) Can someone let me know what are all the general ...

Visual C++ AND .Net
What would be the best package for me to purchase if I want to move from VC++ 6.0 and VB 6.0 to .Net? I think it is Visual Studio .Net (around $800.00). Is this correct? I just need a little direction since I have just been given the go ahead to purchase these items. Any information on these products - from someone who has used them - would be helpful. Thank you Ken >-----Original Message----- >What would be the best package for me to purchase if I want to move from >VC++ 6.0 and VB 6.0 to .Net? I think it is Visual Studio .Net (around >$800.00). Is this correct? I just nee...

Convert text string in format of cell reference to a cell reference
Is there any way of converting a text string in the format of a valid cell reference i.e. " 'Sheet1'!F23 " to an actaul cell reference that could be used in a formula? Frank You could use the INDIRECT() function. This will use the value in the cell as a cell reference. So if Merges!A1 was in B2, INDIRECT(B2) would return the value in Merges!A1 Andy. "Frank" <anonymous@discussions.microsoft.com> wrote in message news:3EAAD6E9-C337-4BF6-B721-A7C75D5D99EA@microsoft.com... > Is there any way of converting a text string in the format of a valid cell referenc...

How does C# avoid needing C++ style header files?
I am new to C# and want to understand its architecture a little better. How does C# avoid needing C++ style header files? Hello, By design when you compile some code, metadata are stored as part of the generated file allowing to use those classes in a self contained way. It has all the needed info built into it. See : http://msdn.microsoft.com/en-us/library/xcd8txaw(VS.71).aspx (Metadata Overview) -- Patrice "Peter Olcott" <NoSpam@SeeScreen.com> a �crit dans le message de groupe de discussion : t8CdnWMCZcduNcTWnZ2dnUVZ_hudnZ2d@giganews.com... &...

Read a .pub file when don't have Publisher
I was sent a .pub file, but don't have Publisher. Is there free software to download so I can just read the file? ala .pdf files? Thx. After managing to set up OE-QuoteFix on his new PC, Ed reads a message from Susan <anonymous@discussions.microsoft.com>... > I was sent a .pub file, but don't have Publisher. Is there free > software to download so I can just read the file? ala .pdf files? No. Refer the source to http://www.mvps.org/publisher/sharing.html Converting the file to PDF is the best option. The whole point of PDF is to share documents created in other applic...

IE8 toolbars etc are black and I can't read the text
I ahve IE8. The toolbar(s) have gome black and I can't read anything. What can I do to correct this, please? Outlook express is fine. MikeH MikeH <truronews@btconnect.com> wrote: > I ahve IE8. The toolbar(s) have gome black and I can't read anything. What > can I do to correct this, please? Outlook express is fine. Try to first read one or more of the many "toolbars are black" questions on this newsgroup. "Rob" <nomail@example.com> wrote in message news:slrnhv5c3a.ghg.nomail@xs8.xs4all.nl... > MikeH <truronews@btcon...

connection string and ADO
Hi, I would like to know how do you do to store the connection string of an ADO component. Basically to access to a DB (to insert, update, select,..) we usually use the DB administrator password and account. So if we store it somewhere, we create a security hole. How can i do to not make application users type several time the DB administrator data (for creating DB, for example), or the users data (password, account) in case of select, insert,... commands ? thanks a lot, Maileen "Maileen" <noemail@nospam.com> wrote in message news:uzwJ3aVEGHA.140@TK2MSFTNGP12.phx.gbl....

add a delivery report/read receipt to an excel cell
is it possible to add a delivery report/read receipt to a 2003 excel spreadsheet cell from an Outlook email With some custom VBA programming, you should be able to do this. -- Robert Sparnaaij [MVP-Outlook] Coauthor, Configuring Microsoft Outlook 2003 http://www.howto-outlook.com/ Outlook FAQ, HowTo, Downloads, Add-Ins and more http://www.msoutlook.info/ Real World Questions, Real World Answers ----- "bishop bass" <bishop bass@discussions.microsoft.com> wrote in message news:98338893-D851-4767-A7A7-7460EB94B508@microsoft.com... > is it possible to ad...