Serial port

Hey,

I've got an application (VC6), which must communicate with the serial port 
(com port).
I use ReadFile, WriteFile with Non-overlapped mode.
There's a thread, which is only for the reading.
The problem: Missing data.

Does anybody knows, how the input/output buffer of the comport is 
realizied?
When there come more data over the ComPort then the Software reads out,
what happens?

Does anybody had some advices?

Thanks
       Peter
0
anti (26)
8/6/2004 8:40:07 PM
vc.mfc 33608 articles. 0 followers. Follow

2 Replies
1106 Views

Similar Articles

[PageSpeed] 21

There are a variety of ways to set up reading a commport, but in general you=
 have to use overlapped IO.
The comm port driver in effect puts data in your buffer when it feels like=
 it (if it's got any) so you have to handle logical message unpacking=
 yourself.

Look up the help and there are a some examples.

You can set it up to wait for a particular character. You will have to setup=
 timeouts etc.

Check out the COMMTIMEOUTS and OVERLAPPED structures.

On Sat, 7 Aug 2004 06:40:07 +1000, peter meier wrote:
>=A0Hey,
>
>=A0I've got an application (VC6), which must communicate with the serial=
 port
>=A0(com port).
>=A0I use ReadFile, WriteFile with Non-overlapped mode.
>=A0There's a thread, which is only for the reading.
>=A0The problem: Missing data.
>
>=A0Does anybody knows, how the input/output buffer of the comport is
>=A0realizied?
>=A0When there come more data over the ComPort then the Software reads out,
>=A0what happens?
>
>=A0Does anybody had some advices?
>
>=A0Thanks
>=A0 =A0 =A0 =A0 Peter


0
isemmel (236)
8/6/2004 9:52:16 PM
peter meier wrote:

> Hey,
> 
> I've got an application (VC6), which must communicate with the serial 
> port (com port).
> I use ReadFile, WriteFile with Non-overlapped mode.
> There's a thread, which is only for the reading.
> The problem: Missing data.
> 
> Does anybody knows, how the input/output buffer of the comport is 
> realizied?
> When there come more data over the ComPort then the Software reads out,
> what happens?
> 
> Does anybody had some advices?
> 
> Thanks
>       Peter

There should be no missing data - you probably have a bug.  Make sure 
you use the dwNumberOfBytesRead to process the return.  The driver has a 
buffer that will save data until you ask for it.  If it fills up you 
should get an error.  Are you checking for comm errors (ClearCommError)?

Read "Serial Communications in Win32" in MSDN, and study the MTTTY 
sample code.

-- 
Scott McPhillips [VC++ MVP]

0
Scott
8/6/2004 10:51:05 PM
Reply:

Similar Artilces:

Serial Number Problem
Hi Everyone, we run Dynamics on our server anyway we had HUGE problems and lost a lot of work.....anyway after fixing lots up i still have one MAJOR problem. Serial numbers for items in the system do exist if you look up inventory ~ Serials. There is a list of serial numbers in stock ready to use. But when we go to do an invoice there are no serial numbers, it asks you if you want to overide the quantities... Our problem was we lost our inventory file therefore we had to put an old file back on...although these serial numbers are there we can not use them which also means i cant put t...

Duplicate Element Names in Serialized XML
Hi All, Hoping someone can solve a problem for me. I am modifying the schema for a rather complex web service written in VB.NET. The services uses a large number of serialized classes to output the overall XML. The problem I am having is that I require 2 XML elements of the same name to be serialized from the 1 class. Due to the way the web service is written only 1 of these would be ever be called at a time. However, it seems that I get an exception if the same element name is used twice in one class.. any ideas? For example: 'start class here <XMLElement ("elementName&q...

Serial Motor
How do you control a motor via serial port? What language should I use? Justin Case wrote: > How do you control a motor via serial port? What language should I > use? I don't know, but it certainly isn't possible with SQL Server ... http://lmgtfy.com/?q=How+do+you+control+a+motor+via+serial+port -- HTH, Bob Barrows Bob Barrows (reb01501@NOyahoo.SPAMcom) writes: > I don't know, but it certainly isn't possible with SQL Server ... What? You can't control a motor with an engine? -- Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se...

serial port communuication
Hi all, I m communicating to a printer device through serial port.It is failing to open the port,but when I disable and enable the com port in device manager,it works fine(i.e)it communicates with the printer and reads the configuration settings of the printer). Regards Hari are u leaving the port opened when ur program terminates ........ what is the frequency of u disabling/enabling port ....... after every run ...... some times works some times not ..... ????? "hari" <haricibi83@gmail.com> wrote in message news:1171455246.402743.203120@k78g2000cwa.googlegrou...

Serialization of jagged Arrays Issue
Hi there, I m trying to return an object (of my own written class) from a web service that contains jagged Arrays as public variables. Asp.Net is showing me the its serialized version on the browser when i invoke the service during test. Code: public class returnType { [System.Xml.Serialization.XmlElementAttribute("chassisdata")] public _chassisdata[] chassisdata; [XmlArray(),XmlArrayItem("wheel", typeof(_wheel[]),IsNullable=false)] public _wheel[][] upsteps; [XmlArray(),XmlArrayItem("wheelsize", typeof(_wheelsize[]),IsNullable=false)] publi...

open files serially
Hi, I seek your help for the following; I have few files in one of the folder. The file names are ending with numeric number. The uniqueness of the file names are they are serially numbered e.g. ABC123.xls, XYZ124.xls, MNO_AB125.xls, LKM126.xls. I would like to open these files serially (...123 then ...124 so on so forth till last files in the folder). Once the file is open i would like to do some processing and save it in another folder. The files once opened and saved in another folder it should get deleted from earlier folder (From where the file was opened). Than...

COleDateTimeSpan
I noticed problem in Visual Studio.NET 7.0.9466, don't know if something wrong with my VC source code. the bug could cause data corruption if you use serialization of COleDatTimeSpan object, the problem is in file olevar.cpp, one line of code is missing (at least on my mashine ============= CArchive& AFXAPI operator<<(CArchive& ar, COleDateTimeSpan dateSpanSrc return ar << dateSpanSrc.m_span CArchive& AFXAPI operator>>(CArchive& ar, COleDateTimeSpan& dateSpanSrc ar >> (long&)dateSpanSrc.m_status return ar >> dateSpanSrc.m_span ...

Parallel Port / USB Port Converter
RMS-SO was connected using Parallel Port with Epson TMU then Printer opened Cash Drawer using telphone cable. We had to move RMS-SO towards new PC with full USB Ports, so that, we are using a Parallel /USB converter, but it doesn't work anymore. Do you have any idea what could be good alternatives for this trouble. -- Thxs 4 ur tym EG This is a multi-part message in MIME format. ------=_NextPart_000_0021_01C948F4.F1EF4620 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable It may be a port setting issue, especially if you are still set t...

Serialize
Hi All, I use Serialize() to open files in my application. However, if the file is ReadOnly I get the error "Failed to open document" from CDocManager::OpenDocumentFile(LPCTSTR lpszFileName). Anyone have any ideas how to get around this? Cheers, Rob ...

Serializing Array with array "name" in the XML
I need help serializing an array without including the array "name". I am writing in C# and using the XmlSerializer to serial classes. I am trying to serialize a class with an array in it like the one below. public class myclass { public imagecontext; public myimage[] images; } public myimage { public string name; public string path; } It will serialize something like this... <myclass> <imagecontext>my context</imagecontext> <images> <myimage> <name>Image1</name> ...

What is most efficient way to serialize a "group" of objects?
What would be the most efficient way to serialize a group of the same objects? For example, if I have 10 Organization objects I want to return from a WebMethod in a "container", what type of container would be most efficient (ArrayList, Collection, etc.)? It is a requirement that the container be dynamic in size and be able to add each object dynamically. Also, if an ArrayList or something similar is used, is there a way to have the root element be something other than "ArrayOfAnyType", e.g., "Organizations"? Thanks, Chris ...

serialize CObArray
I've just converted an app from vc6 to vc7 (vis studio .net 2003 version). I have a serialized file type which has worked perfectly for years, now i'm getting errors when reading newly archived CObArray (which not suprisingly contains objects derived from cobject). Anyone else had this problem?? Just a pointer. When you post, try and give as much information as you can, particularly the errors you are getting? Is this any use? http://support.microsoft.com/default.aspx?scid=kb;en-us;322621 Andy Mortimer [MS] Please do not send email directly to this alias. This alias is for news...

Serializing an object whose class implements ICollection
Hi All, I've been searching around for a solution to over-riding the default serialization of an object whose class is derived from System.Collections.CollectionBase (implementing ICollection). From searches, a solution seems to have been offered by a Dino Chiesa. In his proposed solution, Dino suggests that you specify an XmlRootAttribute in the serializer along with a code example that is no longer available at the url posted. Attempting this solution (without benefit of the example) yields only an error InnerException {"XmlRoot and XmlType attributes may not be specifi...

Serialization - DeSerialization
Hello All, I'm trying to use XML Serialization to a class that inherits from another class and also has ArrayLists exposed as properties. When I serialize the class after populating the methods I get the following XML: <?xml version="1.0" encoding="utf-16"?> <Bulletin xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <MetaData>MetaData</MetaData> <Notes> <Note> <MetaData>MetaData</MetaData> <CreatedDate>2003-08-01T11:41:16.942...

Serial communication Threading (Thread is blocking)
Hi All, in my application, I am Creating one thread i.e worker thread. suppose my main thread is A and child thread(worker thread) is B. i am using this thread for serial communication. this is a blocking thread. now in my main application A when i create this thread B i start a timer. and i am expecting that in the interval specified in the timer the operation should get complete. otherwise i want to kill the thread B. but is it possible to kill the serial thread (B) in the context of thread (A). means in the timer handler. and how can we no is there any data is present on the port or n...

How to serialize multiple DataSets to a single file
I have 10 unique DataSets, and I would like to serialize them to a single file. I assign each of them a sequential name (e.g., DataSet 1, DataSet 2, etc.). The DataSets are comprised entirely of "double" types. I would like to serialize them to the same file, and later retrieve them, perhaps randomly (for example, extract only DataSet 4 from the file). All the information I have read on binary serialization and deserialization assumes that I will serialize each object to its own file. How can I serialize multiple DataSets to single a file, and later deserialize t...

XML Serialization problem
Hi folks! I have some XML Serialization problem. I searched Internet and found some good info but still can't resolve the problem. I have next situation: I have solution contains 2 projects: Proj1 and Proj2. Each project compiled to dll. In Proj1 contains Class1 And Proj2 contains Class2. Now, Class2 has reference to Class1. I want to XML serialize Class2. In order to do that I added attr: [XmlInclude(typeof(Class1))] before Class2 definition. It's compiled but when it's running it throws exception something like that: "File or assembly name Proj1, or one of its dependenc...

Cedit serialization
Is there a way to serialize CEdit control data? When I use the operator << or >> it fails since it has no overridden operator for serialization. Can someone advise please? Thanks Galia "Galia" <galia@mandi.com> ha scritto nel messaggio news:OcFOW8uHIHA.2480@TK2MSFTNGP05.phx.gbl... > Is there a way to serialize CEdit control data? > When I use the operator << or >> it fails since it has no overridden > operator for serialization. > Can someone advise please? You may want to serialize the string stored into the CEdit instance. So: * y...

Serialize processes
Hi I have an application and on the same PC two instances of this application. This means there are two processes of the same application. It is neceesary that the processes doesn't run simultaneous. Is it possible to serialize the two processes? I mean the processes, not the threads. I use Visual Studio 2003 and C++./MFC. Thanks Hans You can check on the OnInitInstance if the app is already running. If so, abort on the second instance, or you can wait until the first instance is done. Check out: http://www.codeproject.com/cpp/csingleinst.asp "Hans Stoessel" <hst...

Serializing array of objects of different types
Hello, I need to serialize/deserialize array of non-typed objects to/from such xml: <contents> <resource name="res1" /> <category name="cat1" /> <resource name="res2" /> <category name="cat2" /> </contents> So that Contents object is array that consists of Resource or Category objects. The problem is that while using XmlSerializer with ICollection, the method item[] have to return object of some type (but not just object). Otherwize it throws an error. Before I'v been using 2 typed arrays (that consists ...

Serial Number Not Showing in Serial/Lot Trace Inquiry
I setup a Sales Inventory item and I set it to trace serial numbers. I created a purchase order and receipt. For the receipt, I manually entered 2 serial numbers. If I look at the serial number report or serial inquiry, I can see the 2 serial numbers for this item. Both are on-hand, not committed or allocated. However, in the Serial/Lot Trace Inquiry, I cannot see these serial numbers/this item regardless of the option I select such as Find serial numbers received from a vendor. I have clicked the Redisplay button. Am I missing a step ...

Open previously opened serialized file != new open serialize file
Doing some testing of my reworked serialize code this morning (thanks for the help Sigurd and Headache - it fixed the pointer problems) and ran into something I don't understand. If I open a previously unopened (in the session) serialized file everything works fine. But if I close the file and reopen it, some of the pointers are undefined and the session crashes. Looking in the debugger, it does go through the ::Serialize code the second time, but clearly isn't actually reading it from disk since the pointer values have changed (from reasonable to cdcdcdcd). I assume the sessio...

Serialization problem 05-27-10
Hi, I was under the impression that with serialization I could transfer a block of data from one application to another. So I wrote a website where after the user had put in some data, it is put in a structure and that structure is serialized into a file. Then this file is emailed and the backend user reads it in an application for processing. If I try to read the file into the same kind of structure, I get an exception error. Apparently it needs the webpage that generated the file to open it??? This is putting me in a lot of trouble as the website is already in use. I...

To Serialize or Not?
Another question for you guys to help with if you can...I have an item "Jagermeister" and this bottle contains a barcode...then at the same time it's sold to me in a gift set with glasses, and that contains another barcode...is there anyway that I can combine the inventory and say I have a total of 12 bottles weather they are part of a gift set or not? Sometimes I break the gift set...when I run low on the shelf. I am hopeing that there is an easy way for me to track this, instead of manually each time I break up the gift set. -- Thank You,; Vince If you don't care...

Serializing a collection class
Hi, is it possible to serialize a top-level class with a collection of items? For example, is this possible: <ParkingLot ...> <ParkedCar><Make>Ford</Make></ParkedCar> <ParkedMotorcycle><Make>Honda</Make></ParkedMotorcycle> <ParkedCar><Make>Hyondai</Make></ParkedCar> <ParkedCar><Make>Volvo</Make></ParkedCar> .... lots of other cars and motorcycles ... </ParkingLot> I know it is possible to serialize a known number of vehicles, with a class like this: public class ParkingLot { ...