On Sun, 27 Dec 2020 21:15:03 +0100, Jean SUZINEAU via fpc-pascal <fpc-pascal@lists.freepascal.org> wrote:
>I think TBlockSerial can work in your console program context. May be >TLazSerial can be more tricky to use in your context, you'll need to use >events/callbacks and FCL. I have struggled with LazSerial in a console program and it just is not intended for that usage. Won't work. Throws exceptions if run in a device without a GUI like a Linux server. But instead I used the built-in serial unit and packaged the whole reading stuff into a thread that will read the serial line constantly using the blocking read and supply the data to the main application as it arrives. Not a big deal to do and get working. You need a read timeout in the execute loop so that the thread can detect if it has been commanded to terminate, that is all I think. Also, for the OP: What do you mean by receiving hex data? Are you saying that you receive byte data as 2-character ASCII hex code? I.e. every byte you want to receive is represented by *two* characters in the incoming stream? In that case if you are not using any delimiters you will probably soon be out of sync and mixing most and least significant hex characters in the transmission so that for example 1a 2b 3c could become ..1 a2 b3 c.. Very dangerous situation. You really must use some kind of delimiter in the data flow... -- Bo Berglund Developer in Sweden _______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal