[fpc-pascal] Using built-in serial instead of synaser and the like for Linux console app?

Christo Crause christo.crause at gmail.com
Fri Aug 21 20:06:04 CEST 2020


On Fri, Aug 21, 2020 at 12:05 PM Bo Berglund via fpc-pascal <
fpc-pascal at lists.freepascal.org> wrote:

> So hence my question:
> Is there something bad about serial (built-in to fpc) that makes it
> unsuitable for use?
>

In my limited experience the FPC serial unit is a bit more low level than
the components such as synaser etc.  There is a bit more of a learning
curve and one needs to decide whether to go blocking or not and how to
handle async reads etc.  I needed to use custom baud rates with auto baud
for an application (debugwire-gdb-bridge) so I took the time to figure out
some of the details.  Since then I've re-used it in other serial based
applications - once you get past the learning curve of how things fit
together it is relatively easy (I guess like most things).  I prefer it now
because it reduces external dependencies in a project.


> Seems like there are virtually no posts describing solutions using
> serial...
>

Here is a unit showing how to open, read and write (blocking) using the
serial unit:
https://github.com/ccrause/debugwire-gdb-bridge/blob/master/serialutils.pas
Unfortunately there is other code for sending a break command and setting
custom baud rates which makes it appear more complicated than it should be.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20200821/23b38aa4/attachment.htm>


More information about the fpc-pascal mailing list