Article View: borland.public.cppbuilder.nativeapi
Article #3471Re: Com port error
From: Remy Lebeau (TeamB)
Date: Fri, 16 Jun 2006 16:55
Date: Fri, 16 Jun 2006 16:55
41 lines
2148 bytes
2148 bytes
"JD" <nospam@nospam.com> wrote in message
news:4492cbf9$1@newsgroups.borland.com...
> After some searching, it's been decided that the thread
> should not use WaitCommEvent
Why not? That is the correct way to wait for events on a COM port. Have
you read the MSDN articles on working with communication ports yet? I
strongly suggest that you do so.
Communications Resources
http://msdn.microsoft.com/library/en-us/devio/base/communications_resources.asp
Serial Communications in Win32
http://msdn.microsoft.com/library/en-us/dnfiles/html/msdn_serial.asp
The second article has a lot of sample source code in it.
> What I'm trying to do now is open the port twice
You can't do that. A COM port can only be opened once.
> once for reading and another for writing
You would have to open it once for both reading and writing at the same
time:
WCom = ::CreateFile( TEXT("COM1"), GENERIC_READ | GENERIC_WRITE, 0,
...);
Notice above that the sharing rights must also be set to 0 for exclusive
access. You cannot share a COM port.
> but on the second call to CreateFile, I get an Access denied error:
As you should be.
Gambit
Technical Details
Message-ID:
<4492e2ca$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news2.google.com!news2.google.com!news4.google.com!news2.volia.net!npeer.de.kpn-eurorings.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<4491a4c2$1@newsgroups.borland.com> <4491a6b2$1@newsgroups.borland.com> <4492cbf9$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,f1782b94b4ced041 X-Google-Attributes: gid10cc67,public X-Google-Language: ENGLISH,ASCII-7-bit From: "Remy Lebeau \(TeamB\)" <no.spam@no.spam.com> Newsgroups: borland.public.cppbuilder.nativeapi References: <4491a4c2$1@newsgroups.borland.com> <4491a6b2$1@newsgroups.borland.com> <4492cbf9$1@newsgroups.borland.com> Subject: Re: Com port error Date: Fri, 16 Jun 2006 09:55:19 -0700 Lines: 43 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1409 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409 NNTP-Posting-Host: 68.69.17.41 Message-ID: <4492e2ca$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1150477002 68.69.17.41 (16 Jun 2006 09:56:42 -0700) Path: arc1-ca.pugleaf.net!g2news2.google.com!news2.google.com!news4.google.com!news2.volia.net!npeer.de.kpn-eurorings.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail