[fpc-pascal] Using built-in serial instead of synaser and the like for Linux console app?
Bo Berglund
bo.berglund at gmail.com
Tue Sep 1 19:17:08 CEST 2020
On Tue, 1 Sep 2020 14:21:44 +0200 (CEST), Michael Van Canneyt via
fpc-pascal
<fpc-pascal at lists.freepascal.org> wrote:
>You must still set the default value in the constructor.
>
>>
>> Note that the thread itself has no idea what is the baudrate in use so
>> it cannot calculate the proper value at the start of Execute...
>> And there is no Create method either that I can use.
>
>The constructor can always be overridden.
>
I did this:
TComPortReadThread=class(TThread)
private
FBuffer: TBytes;
FReadPacketSize: integer;
FReadTimeout: integer;
public
MustDie: boolean;
Owner: TFpSerialPort;
constructor Create; override; //<= THIS ADDED, GIVES ERROR
property ReadPacketSize: integer read FReadPacketSize write
FReadPacketSize; //How many bytes to read in each operation
property ReadTimeout: integer read FReadTimeout write
FReadTimeout; //Max time to wait for data in thread
protected
procedure CallEvent;
procedure Execute; override;
published
property Terminated;
end;
and the code will not compile:
fpserialport.pas(41,17) Error: There is no method in an ancestor class
to be overridden: "constructor Create;"
So, does TThread not have a constructor????
I thought all objects had.
--
Bo Berglund
Developer in Sweden
More information about the fpc-pascal
mailing list