I made two modifivations in the program (see below) with only the
following effct: I only get "empty characters" (Spaces) instead of the
strings.
Am Donnerstag, den 27.11.2008, 18:15 +0100 schrieb Richard:
> > Based on you question and the information you have gathered thus far,
> > anything else you need to know, maybe I can help?
> Thank you for this offer!
> I don't know if this mailing list accepts attachments so I have copied
> the program "serialtest.pas" at the end of this mail.
>
> I have connected my sending unit with my PC on /dev/ttyS1. This unit
> sends data, I have checked this with a terminal program. The parameters
> are 9600, 8N1. The data consist of a string (ASCII) with 21 characters,
> followed by two LF (dec.10). It is sent every 2 s, sometimes 1 s.
>
> Now I've looked to the rs232_connect-procedure. The loop "
> repeat
> write(ser.recvbyte(1000), ' ');
> until keypressed;
> " should result in showing the received bytes on the screen. But all I
> get is "0 0 0 0...", even, if the unit is switched off.
> I am sorry, but the study of the definitions of RecvByte in the
> SynaSer-unit didn't help me (function TBlockSerial.RecvByte...).
> Is it a timeout, which is to small?
>
> I hope, I made it clear to you.
> Any help appreciated!
> Richard
>
>
>
> ----------------------------------------------------------------------------------
>
>
>
>
> program serialtest; {found anywhere in the www}
>
> {$mode objfpc}{$H+}
>
> uses
> {$IFDEF UNIX}{$IFDEF UseCThreads}
> cthreads,
> {$ENDIF}{$ENDIF}
> Classes,SysUtils,Synaser,Crt
> { you can add units after this };
>
> var l:boolean;
>
> { function check_affirmation():boolean;
> var k:string;
> begin
> Writeln('To quit the application please do NOT use CTRL-C!
> Instead, please press any key to quit the application! '+
> 'Please confirm this notification before the application
> continues! '+
> '[0]=Quit, [1]=Confirm, please continue! ');
> Writeln('Your decision: ');
> Read(k);
> if StrtoInt(k) = 1 then
> begin
> check_affirmation:=true;
> Writeln('OK, application continues ...');
> end
> else
> begin
> check_affirmation:=false;
> Writeln('Abort');
> end
> end; }
>
> procedure RS232_connect;
> var
> ser: TBlockSerial;
ser.ConvertLineEnd := true; {because I have LF/LF instead of CR/LF}
> begin
> ser:=TBlockSerial.Create;
> try
> ser.Connect('/dev/ttyS1'); //ComPort
> {Sleep(1000);}
>
> ser.config(9600, 8, 'N', 1, False, False);
> Write('Device: ' + ser.Device + ' Status: ' +
> ser.LastErrorDesc +' '+
> Inttostr(ser.LastError) + ' ');
> {Sleep(1000);}
> repeat
Write(ser.Recvstring(1000), ' '); {instead of:
>
> Write(ser.RecvByte(1000), ' ');}
> until keypressed; //Important!!!
> finally
> Writeln; writeln('Serial Port will be freed...');
> ser.free;
> Writeln('Serial Port was freed successfully!');
> end;
> end;
>
> begin
> {l:=check_affirmation();
> if l=true then}
> RS232_connect()
> { else
> Writeln('Program quit! ');}
> end.
>
>
--
Richard Müller - Am Spring 9 - D-58802 Balve-Eisborn
Ökologische Station in der JH Sorpesee
www.oeko-sorpe.de - www.wasserreise.info
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
synalist-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/synalist-public