Re: Using TComPort



mIKE wrote:

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.
<snip>
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
.



Relevant Pages

  • RE: How can I create a outlook appointment item from data in a e-m
    ... If you know the starting point of where the text you want occurs, use InStr ... Eric Legault (Outlook MVP, MCDBA, MCTS: ... if I have a string that looks like this: ... Once you get the text you need, it's easy to create a new appointment item: ...
    (microsoft.public.outlook.program_vba)
  • Parsing a string
    ... The function also has two optional input parameters, ... default delimiter value in the function definition line ... then using the instr() functions. ... Dim ArrayBreakPosAs Integer, strPrefix As String ...
    (microsoft.public.access.queries)
  • Re: Search using a list of words
    ... into a String in VB and use the Instr function to search that string for ... list of search words also in upper case. ... Even such a simple solution using Instr would be quite fast, ... you'll need to go to all that trouble and I think you'll find Instr fast ...
    (microsoft.public.vb.general.discussion)
  • Re: Match text - case sensitive
    ... InStr uses a binary comparison by default. ... String expression being searched. ...
    (microsoft.public.scripting.vbscript)
  • Tcomport - for abeginner
    ... Am Using TComport and Delphi 6 ... is if I recieve a string the comport reads the first char then writes it to ... then take the other 223 characters in the string and writes them. ... the First character is an STX and ChR 224 is EOT ...
    (borland.public.delphi.thirdpartytools.general)