Re: Using TComPort
- From: Charles Hacker <reply.to@xxxxxxxxxxxxxxxxxx>
- Date: Mon, 17 Jul 2006 11:13:39 +1000
mIKE wrote:
<snip>
I've just started using Dejan Crnila's TComPort version 2.64 with a tiny
Delphi 5 app. So far this was worked well, but I need to make some
improvements and I'm not sure how to proceed.
What I'd like to do is reduce this primitive process to one button click.
To do that, I need to send a command, say CR/LF, then wait (in some sense of
the word) for the completed response to see if the reply is the necessary
sign-on prompt. If the reply is as expected, then I can continue.
Seems like a simple enough task to me, what is your problem?
All you need to do is 'parse' the input string, and wait for valid
return characters, before procedding to sending the next set of strings.
For example, some pesudo code below describes this:
instr:string;
step:integer;
On button press,
instr = '';
step = 1;
memo.lines.clear;
Send CR/LF;
On Rx Char
instr = instr+RxChar;
if (step=1)and(instr = sign-on prompt) then
begin
instr = '';
step = 2;
Send password;
end
if (step=2)and(instr = successful logon) then
begin
instr = '';
step = 3;
Send text command;
end
if (step=3) then
begin
Memo1.Text := Memo1.Text + cStr
if ("end of return text"?) then
begin
step = 0;
memo1.savetofile(....)
send exit;
end;
end;
(Of course appropriate error messages, and error traps are still needed
to account for recieved string NOT being correct.
Also better string handelling is poosible, (such as NOT using a memo,
use a StingList)).
I have done similar tasks before (using TComPort by the way), for
getting data (data logging) from an electronic venier calliper.
And for that matter, also for communication to a microproccessor
development board.
(The web address for the microprocessor system is below if you are
interested).
http://www.gu.edu.au/school/eng/mmt/HBoard.html
--
Charles Hacker
Lecturer in Electronics and Computing
School of Engineering
Griffith University - Gold Coast
Australia
.
- Follow-Ups:
- Re: Using TComPort
- From: mIKE
- Re: Using TComPort
- References:
- Using TComPort
- From: mIKE
- Using TComPort
- Prev by Date: Re: Display output from DOS prompt
- Next by Date: Re: Display output from DOS prompt
- Previous by thread: Using TComPort
- Next by thread: Re: Using TComPort
- Index(es):
Relevant Pages
|