🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #10510

Serial Communications issue

#10510
From: tomdas
Date: Tue, 13 Apr 2004 16:13
42 lines
2202 bytes
Hi to all,
I am trying to use com Port in Windows XP and I have some problems with
it.What I exactly want
 to do is to open the Com1 at 9600,n,8,1,set the RTS pin as an IO pin and
SET it(-12V) and after
this to write to and read from this serial port while the RTS is set.

I work in C++ and I am opening the port using Createfile(not overlapping
way) like this:

MyComHandle=CreateFile(Comm,(GENERIC_READ |
GENERIC_WRITE),0,0,OPEN_EXISTING,0,0);

Then I am setting the DCB to the com1 having 9600,n,8,1,no flow control for
CTS,RTS,DTR,DSR
(FALSE,RTS_CONTROL_DISABLE,DTR_CONTROL_DISABLE,FALSE) using the :

SetCommState(MyComHandle,&MyComDCB);

and I am also setting the COMMTIMEOUTS as 20,200,10,0,0

After a while I am setting the RTS pin using the:

EscapeCommFunction(SerialComHandle, SETRTS);

After this whenever I am trying to read  from the serial port using the
function:

ReadFile(hFile,Buffer,Bytes2Read,BytesRead),NULL)

I am getting the error 995(ERROR_OPERATION_ABORTED) (using the GetLastError)
which means:
"The I/O operation has been aborted because of either a thread exit or an
application request."

If I don't use the EscapeCommFunction first the read doesn't give an error.

What am I doing wrong or which is another way to set RTS and then read and
write to the serial port?

Thanks in advance,
Thomas
Technical Details
Message-ID: <407c11a7@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!news.glorb.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,a3ab790bb03822fa,start
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2004-04-13 09:40:18 PST
From: "tomdas" <tomdais@otenet.gr>
Newsgroups: borland.public.cppbuilder.nativeapi
Subject: Serial Communications issue
Date: Tue, 13 Apr 2004 19:13:25 +0300
Lines: 45
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
NNTP-Posting-Host: 62.103.139.39
Message-ID: <407c11a7@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1081872807 62.103.139.39 (13 Apr 2004 09:13:27 -0800)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!news.glorb.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail