On Tue, 01 Sep 2020 10:22:08 +0200, Bo Berglund via fpc-pascal <fpc-pascal@lists.freepascal.org> wrote:
>Maybe I could tie the timeout to the actual baud used? Slower speeds >use longer timeout etc? Timeout could be set to the time it takes to >transfer the number of bytes to read? > >And both arguments could be made properties of the class such that the >user can tweak performance a bit? I tried to do this: TComPortReadThread=class(TThread) private FBuffer: TBytes; FPacketSize: integer; default 10; FReadTimeout: integer; default 10; public MustDie: boolean; Owner: TFpSerialPort; property ReadPacketSize: integer read FPacketSize write FPacketSize; //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; But I cannot set the default value of the two new fields FPacketSize and FReadTimeout, I get an error in the above code (and variations of the same). Is there no way to declare a property to have a default non-zero value? 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. Any ideas? -- Bo Berglund Developer in Sweden _______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal