🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Synchronization Problems....

#14310
From: Phuoc Can HUA
Date: Fri, 15 Aug 2003 06:05
80 lines
3899 bytes
I'm not a port expert. But recursive call in this place is very bad. In 
general, recursive should only be used if back tracking is needed. It's 
very slow and risky. If the stop criteria is not good enough it can crash 
the program (or even the system).

As far as I understand, you don't need to back track the previous baudrate. 
Why don't you simply use a loop to go through your 5 different baudrates? 
and use a timer event to execute the loop. I assume the incoming messages 
are buffered so that you won't miss them due to the size of the timer 
interval.

HTH
Phuoc Can HUA


On Thu, 14 Aug 2003 08:40:06 +0200, Keneth Wagner <keneth.wagner@peak- 
system.com> wrote:

> Thanks Phuoc Can HUA for the answer.  I already use a thread to read from
> the serial port, and the timer solution ok, i took not that in count 
> because
> my problem is Wait inside a Function meanwhile an event is happening 
> severla
> times and a timer running at the same time.  Maybe i forgoting something 
> and
> i can not  see my problem (Maybe my logic is wrong) -
>
> I have to do this:
> - check how many serial port are availables in the computer (Done)
> - Connect, Desconnect, Send to the serial Port (Done)
> - Receive Bytes from the Port (Done - with a thread)
> - Comunicate to the main window when i receive a message (Done, WM_USER
> message)
> - Check for an special dispositive in each port found (MY PORBLEM)
> For make this i need to send a message trhoug the port.  If a
> dispositive is there, it can understand the message i sent and response
> retruning the Firmware.  I have to construct the complete string before 
> make
> the return of the function, so i need wait inside a function for 
> construct
> the string with several port reads and, when the firmware is correct, 
> return
> true or fale in order to know when in a  port is a dispositive connected. 
> I
> have to wait for the "acknowledged message" but this gonna happen only 
> with
> an specific baudrate, so i have to test in each port sending the message
> with 5 different baudrates.  When a "defined wait Answer time" is gone i
> have to test the next baudrate an so on. I can not see the way to wait :-) 
>
>
> .
> I know is there (in some place).  I can use a recursive function to check
> the Baudrates, but i still need the way to make Connect-Send-Receive-Wait
> inside the function who ask if any dispositive with that baudarate is in
> that port.
>
> bool isThere(Baudrate){
> if(GetResponse())  // This is my problem
> return true;
> else
> if(BaudRate <= TotalBaudrates)
> return isThere(NextBaudRate)
>
> return false;
> }
>
> Thanks again, if you have any comment, please let me know,.
>
> Keneth.
>
>
>



-- 
_/\__/\__/\__/\__/\__/\_
www.huaonline.com
My Homepage is my Castle
Technical Details
Message-ID: <oprtxm62q4bq7az6@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-09!supernews.com!pln-w!extra.newsguy.com!lotsanews.com!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <3f3a0df1@newsgroups.borland.com> <oprtvd370vbq7az6@newsgroups.borland.com> <3f3b2efc$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,a4a10dc5e85235c0
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2003-08-14 23:39:54 PST
Newsgroups: borland.public.cppbuilder.nativeapi
Subject: Re: Synchronization Problems....
References: <3f3a0df1@newsgroups.borland.com> <oprtvd370vbq7az6@newsgroups.borland.com> <3f3b2efc$1@newsgroups.borland.com>
Message-ID: <oprtxm62q4bq7az6@newsgroups.borland.com>
Content-Type: text/plain; charset=iso-8859-15; format=flowed
From: Phuoc Can HUA <home}a+t{huaonline.com>
MIME-Version: 1.0
Date: Fri, 15 Aug 2003 16:05:16 +1000
User-Agent: Opera7.10/Win32 M2 build 2840
NNTP-Posting-Host: 203.194.21.162
X-Trace: newsgroups.borland.com 1060927794 203.194.21.162 (14 Aug 2003 23:09:54 -0700)
Lines: 80
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-09!supernews.com!pln-w!extra.newsguy.com!lotsanews.com!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail