Thanks guys,
I have got a bit further. The following seems to work, but
if you have any advice please fell free to let me know.
Code---------------------------
program serialcollex;
{$APPTYPE CONSOLE}
uses
synaser,
sysutils;
var
ser:TBlockSerial;
LCMD:String;
begin
ser:=TBlockserial.Create;
try
ser.RaiseExcept:=true;
ser.Connect('COM1');
ser.Config(9600,8,'N',0,false,false);
while not (ser.LastError <> 0) do begin
if ser.lastError<>0 then break;
if ser.canread(1000) then begin
LCMD := ser.Recvstring(1000);
writeLn(LCMD);
end;
end;
finally
ser.Free;
end;
end.
End of code---------------------------------------------
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Andreas
Berger
Sent: 27 September 2007 12:49
To: Ararat Synapse
Subject: Re: [Synalist] synaser example
[EMAIL PROTECTED] wrote:
> OK,
> No response yet, But i have simplified my code as 'terminated' cause a
> problem. So while the new code will run I get an error after the
>
Instead of a "Repeat ... Until false" loop try a "While not(Terminated)
do" loop
> Recvstring timeout.
> 'ESynaSerError with message 'Communication error 9997' Timeout during
> operation'.
>
Probably because of the "ser.RaiseExcept := True" statement. Try it
without this.
> What does this mean?
> How can I improve my simple code?
>
> code as follows
>
> code---------------
>
> program dataser;
>
> {$APPTYPE CONSOLE}
>
> uses
> synaser,
> sysutils;
>
> var
> ser:TBlockSerial;
> LCMD:String;
> begin
> ser:=TBlockserial.Create;
> try
> ser.RaiseExcept:=True;
> ser.Connect('COM1');
> ser.Config(9600,8,'N',0,false,false);
> if ser.lastError<>0 then exit;
> LCMD := ser.Recvstring(10000);
> writeLn('LCMD');
> finally
> ser.Free;
> end;
> end.
>
> end od code-------------------------------------
>
>
> Lloydie T
>
>
>> Hi,
>> I wish to use synaser to capture text sent to a serial port. I do not
>> have a test facilty at the moment, so I need a little help to make sure
>> I am going in the right direction.
>>
>> The basic code I have is as follows.
>> code----------------------------------
>>
>> {$MODE DELPHI}
>>
>> Program testser;
>>
>> uses
>> synaser, sysutils;
>>
>> var
>> ser:TBlockSerial;
>> LCMD:String;
>> begin
>> ser:=TBlockserial.Create;
>> try
>> ser.RaiseExcept:=True;
>> ser.Connect('COM1');
>> ser.Config(9600,8,'N',0,false,false);
>> with ser do
>> begin
>> repeat
>> if terminated then break;
>> LCMD := RecvString(1000);
>> if lastError<>0 then break;
>> writeLn('LCMD');
>> if lastError<>0 then break;
>> until false;
>> end;
>> finally
>> ser.Free;
>> end;
>> end.
>>
>> End of code----------------------------------
>>
>> Does this look OK?
>> If not, how should I do this?
>>
>> Lloydie T
>>
>>
>>
>> -------------------------------------------------------------------------
>> This SF.net email is sponsored by: Microsoft
>> Defy all challenges. Microsoft(R) Visual Studio 2005.
>> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
>> _______________________________________________
>> synalist-public mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/synalist-public
>>
>>
>
>
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Microsoft
> Defy all challenges. Microsoft(R) Visual Studio 2005.
> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
> _______________________________________________
> synalist-public mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/synalist-public
>
>
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
synalist-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/synalist-public
--
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.488 / Virus Database: 269.13.32/1033 - Release Date: 27/09/2007
11:06
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
synalist-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/synalist-public