Article View: borland.public.cppbuilder.nativeapi
Article #10374Re: Serial comms and cotrolling the RTS line
From: Steve Aletto
Date: Wed, 21 Apr 2004 07:47
Date: Wed, 21 Apr 2004 07:47
37 lines
2530 bytes
2530 bytes
> I have created my own com port class and have had no problems transmitting > and recieving data via my serial ports, but now I want to control the RTS > line as a direction control pin for RS485 data. Unfortunately there isn't an easy solution to that problem. I've been looking for years... > Unfortunately, the WaitCommEventFunction returns immediately That's because the serial _software_buffer_ is empty, but you don't know the state of the hardware buffer and shift register (where the bits are really output). > I cant use the fRtsControl from the DCB structure as it drops the line upto > 10 ms after the data has been sent and is not fast enough. Not fast enough? Mmm... you could think to introduce a delay in your 485 device (provided that you are developing it of course). There are two "best solutions": using an automatic 232/485 converter (you don't need to move any signal any more) or creating your own serial driver. The latter is surely difficult, but you could access the COM port at low level (such as we did under DOS, where you can check the state of the shift register and you didn't have any problem handling 485). Another solution (simpler, but not perfect) is to send one character per time or add a final dummy character at the end of the string (if this doesn't introduce protocol problems). Also, try setting different values for the COM port transmission buffer (see in the control panel). If you find any better solution let me know. HTH, Steve.
Technical Details
Message-ID:
<40862737$1@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-mailReferences:
<40853bbf@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10cc67,29200a53fdd311dc X-Google-Attributes: gid10cc67,public X-Google-ArrivalTime: 2004-04-21 01:09:23 PST Reply-To: "Steve Aletto" <steve_alettoANTI@SPAMhotmail.com> From: "Steve Aletto" <steve_alettoANTI@SPAMhotmail.com> Newsgroups: borland.public.cppbuilder.nativeapi References: <40853bbf@newsgroups.borland.com> Subject: Re: Serial comms and cotrolling the RTS line Date: Wed, 21 Apr 2004 09:47:02 +0200 Lines: 39 Organization: Steve Aletto 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: 81.208.124.114 Message-ID: <40862737$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1082533687 81.208.124.114 (21 Apr 2004 00:48:07 -0700) 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