🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Comm Port

#8794
From: Bob Gonder
Date: Wed, 15 Sep 2004 20:03
51 lines
3092 bytes
McKool wrote:

>How can i make the port work sinchronous? which api function exist f�r send 
>a byte and get a return when the byte was received?

Don't open the port with FILE_FLAG_OVERLAPPED.
Use WriteFile() with lpOverlapped = NULL.

>> I could see with an osciloscope that the Low-Hight state which i want, i 
>> can make ik sending a 0x0 using as baudrate of 360. That is something ;-) 
>> . When i send the 0x0 i get a Low signal for exact 25 ml.  The problem is 
>> to calculate the time after that happens.

Is this what you need to happen?
 25 ms low,
 25ms high,
 then commands at 10400 baud?

>> The duration of send a 0x0 is (if i understud well)      (1/360)*1000 = 
>> 2,7777 ml . so, in order to send something in the next 25 ml shall the 
>> program wait theoretic

Huh?
There is no 360 setting. Docs say 300 or 600.
The duration of a character at 360 baud would be 1/36 second. The
duration of the 8 zero bits would be 1/45 second.
But, you are looking for a zero duration of 1/40 second (25 ms)
OTOH, if you set Parity to Even instead of None, then you would get a
Zero-Time of 1/40 second.
But, that makes it hard to get 25 ms of high.

>> This hardware is a standard device to communicate to a Car.  The name is 
>> K-Line and in order to start a comunication must be sent a 25 ml low, 25 
>> ml hight and some start bytes after that.  But it must be just 25ml, if it 
>> is not exact (+/- 1 ml) don't work.  I find a sample program mad in Delphi 
>> (only the Exe file) and i see in the osciloscope that it make just that 
>> what i want, so must to be a simple way.

Try this sequence:

CreateFile();
SetBaud(10400);
SetThreadPriority(Higher)
starttime=GetTime();
SetCommBreak();
while( (GetTime()-starttime) < 25ms );
ClearCommBreak();
SetThreadPriority(Normal)
/*Now for 25ms high.*/
WriteFile( 26 times 0xff )	/* (10400/10)/40 == 26 */
WriteFile(Commands)
Technical Details
Message-ID: <iq3hk010j18jjg2bl6lhvhtedq351sb9g1@4ax.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!proxad.net!gatel-ffm!gatel-ffm!194.25.134.126.MISMATCH!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <4145a779$1@newsgroups.borland.com> <88fbk0d602p65ajvc5lk89tc2bc5qv93dg@4ax.com> <41469b86$1@newsgroups.borland.com> <4146b149$1@newsgroups.borland.com> <jf9ek095ohfqfgl304ncsf62mhc340nu88@4ax.com> <41483adc@newsgroups.borland.com> <414844ac$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,c3fce443b4c5c053
X-Google-Attributes: gid10cc67,public
X-Google-Language: ENGLISH,ASCII
From: Bob Gonder <notbg@notmindspring.invalid>
Newsgroups: borland.public.cppbuilder.nativeapi
Subject: Re: Comm Port
Date: Wed, 15 Sep 2004 13:03:21 -0700
Organization: MindSpring Enterprises, Inc.
Reply-To: notbg@notmindspring.invalid
Message-ID: <iq3hk010j18jjg2bl6lhvhtedq351sb9g1@4ax.com>
References: <4145a779$1@newsgroups.borland.com> <88fbk0d602p65ajvc5lk89tc2bc5qv93dg@4ax.com> <41469b86$1@newsgroups.borland.com> <4146b149$1@newsgroups.borland.com> <jf9ek095ohfqfgl304ncsf62mhc340nu88@4ax.com> <41483adc@newsgroups.borland.com> <414844ac$1@newsgroups.borland.com>
X-Newsreader: Forte Agent 1.93/32.576 English (American)
MIME-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
NNTP-Posting-Host: 67.76.65.139
X-Trace: newsgroups.borland.com 1095278598 67.76.65.139 (15 Sep 2004 13:03:18 -0700)
Lines: 54
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!proxad.net!gatel-ffm!gatel-ffm!194.25.134.126.MISMATCH!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail