Download Winsoft ComPort for Linux v1.5 Full Source for Delphi 10.2 - 11 and Lazarus

Winsoft ComPort for Linux v1.5 Full Source for Delphi 10.2 - 11 and Lazarus

Winsoft ComPort for Linux v1.5 Full Source for Delphi 10.2 - 11 and Lazarus
Winsoft ComPort for Linux v1.5 Full Source for Delphi 10.2 - 11 and Lazarus


Delphi component for serial communication for Linux.

Features

Communication with devices connected to serial port
Supports 64-bit Linux
Supports Delphi 10.2 - 11 and Lazarus 2.0.12
Source code included in registered version
Royalty free distribution in applications

Installation

1. unpack lcomport.zip file to some folder
2. copy all files from Delphi11 subfolder
(when using Delphi 11) to DelphiExample subfolder
3. open demo example Demo.proj located
in DelphiExample subfolder and compile it
4. you may need to allow access to Linux serial
device using: sudo chmod a+rw /dev/ttyUSB0

type
  EComError = class(Exception);

  TBaudRate = (brDefault, br0, br50, br75, br110, br134, br150, br200, br300,
    br600, br1200, br1800, br2400, br4800, br9600, br19200, br38400,
    br57600, br115200, br230400, br460800, br500000, br576000,
    br921600, br1000000, br1152000, br1500000, br2000000, br2500000,
    br3000000, br3500000, br4000000, brCustom);
  TParity = (paDefault, paNone, paOdd, paEven);
  TStopBits = (sbDefault, sb1, sb2);
  TDataBits = (dbDefault, db5, db6, db7, db8);

  TModemStatusValue = (msCTS, msDSR, msRing, msRLSD);
  TModemStatus = set of TModemStatusValue;

  TBlockMode = (bmBlocking, bmNonBlocking);

  TOption = (opCanonical, opEcho, opEchoErase, opEchoKill, opEchoNl, opEnableSignals, opHangUpOnClose,
    opHardwareFlowControl, opIgnoreModemLines, opNoFlushAfterInterrupt);
  TOptions = set of TOption;

  TInputOption = (ioDisableReceiver, ioEnableProcessing, ioEnableXonXoff, ioIgnoreBreak, ioIgnoreCr,
    ioIgnoreParityError, ioMarkParityError, ioParityCheck, ioStripOffEighthBit,
    ioTranslateCrToNl, ioTranslateNlToCr);
  TInputOptions = set of TInputOption;

  TOutputOption = (opAnyCharIsXon, ooEnableProcessing, ooEnableXonXoff, ooTranslateCrToNl,
    ooTranslateNlToCrLf, ooUseFillCharacter);
  TOutputOptions = set of TOutputOption;

  TOpenCloseEvent = procedure (ComPort: TLComPort) of object;
  TReadWriteEvent = procedure (Sender: TObject; Buffer: Pointer; Length: Integer) of object;
  TComAction = (caFail, caAbort);
  TComErrorEvent = procedure (ComPort: TLComPort; E: EComError; var Action: TComAction) of object;

  TDevice = record
    Name: string;
    FileName: string;
  end;

  TCharacters = class(TPersistent)
    property Interrupt: Char Index 0 read write default Chr(-1);
    property Quit: Char Index 1 read write default Chr(-1);
    property Erase: Char Index 2 read write default Chr(-1);
    property Kill: Char Index 3 read write default Chr(-1);
    property Eof: Char Index 4 read write default Chr(-1);
    property Start: Char Index 8 read write default Chr(-1);
    property Stop: Char Index 9 read write default Chr(-1);
    property Suspend: Char Index 10 read write default Chr(-1);
    property Eol: Char Index 11 read write default Chr(-1);
    property Reprint: Char Index 12 read write default Chr(-1);
    property Discard: Char Index 13 read write default Chr(-1);
    property WordErase: Char Index 14 read write default Chr(-1);
    property LiteralNext: Char Index 15 read write default Chr(-1);
    property Eol2: Char Index 16 read write default Chr(-1);
  end;

  TLComPort = class(TComponent)
    constructor Create(AOwner: TComponent);
    procedure Open;
    procedure Close;

    procedure Read(Buffer: Pointer; Count: Integer);
    procedure Write(Buffer: Pointer; Count: Integer; WaitForCompletion: Boolean = False);

    function ReadBytes: TBytes;
    procedure WriteBytes(const Value: TBytes);

    function ReadAnsiString: AnsiString;
    procedure WriteAnsiString(const Value: AnsiString);

    function Read(Encoding: TEncoding): UnicodeString;
    procedure Write(const Value: UnicodeString; Encoding: TEncoding);

    function ReadUtf8: UnicodeString;
    procedure WriteUtf8(const Value: UnicodeString);

    function ReadAnsiLine: AnsiString;
    procedure WriteAnsiLine(const Value: AnsiString);

    function ReadLine: TBytes;
    procedure WriteLine(const Value: TBytes);

    function ReadLine(Encoding: TEncoding): UnicodeString;
    procedure WriteLine(const Value: UnicodeString; Encoding: TEncoding);

    function ReadLineUtf8: UnicodeString;
    procedure WriteLineUtf8(const Value: UnicodeString);

    function ReadAnsiUntil(Terminator: AnsiChar): AnsiString;
    function ReadUntil(Terminator: Byte): TBytes;
    function ReadUntil(Terminator: Byte; Encoding: TEncoding): UnicodeString;
    function ReadUntilUtf8(Terminator: Byte): UnicodeString;

    function ReadAnsiChar: AnsiChar;
    procedure WriteAnsiChar(Value: AnsiChar);

    function ReadChar: Char;
    procedure WriteChar(Value: Char);

    function ReadByte: Byte;
    procedure WriteByte(Value: Byte);

    function ReadWord: Word;
    procedure WriteWord(Value: Word);

    function ReadLongWord: LongWord;
    procedure WriteLongWord(Value: LongWord);

    function InputCount: Integer;
    procedure WaitForWriteCompletion;
    procedure ClearInput;
    procedure ClearOutput;
    procedure Clear;
    procedure SendBreak(Duration: Integer = 0);
    procedure SendXOn;
    procedure SendXOff;
    procedure SetXOn;
    procedure SetXOff;
    procedure ClearDTR;
    procedure ClearRTS;
    procedure SetDTR;
    procedure SetRTS;

    function EnumDevices: TArray<TDevice>;

    property Handle: Integer read FHandle;
  published
    property About: string read stored False;
    property Active: Boolean read write default False;
    property BaudRate: TBaudRate read write default brDefault;
    property BlockMode: TBlockMode read write default bmNonBlocking;
    property Characters: TCharacters read write;
    property DataBits: TDataBits read write default dbDefault;
    property DeviceName: string read write;
    property InputBaudRate: Integer read write default 0;
    property InputInterval: Byte read write default 0;
    property InputOptions: TInputOptions read write default [];
    property InputRequired: Byte read write default 0;
    property InputTimeout: Integer read write default 0;
    property LogFile: string read write;
    property ModemStatus: TModemStatus read stored False;
    property Options: TOptions read write default [];
    property OutputBaudRate: Integer read write default 0;
    property OutputOptions: TOutputOptions read write default [];
    property Parity: TParity read write default paDefault;
    property StopBits: TStopBits read write default sbDefault;

    property AfterClose: TOpenCloseEvent read write;
    property AfterOpen: TOpenCloseEvent read write;
    property AfterRead: TReadWriteEvent read write;
    property AfterWrite: TReadWriteEvent read write;
    property BeforeClose: TOpenCloseEvent read write;
    property BeforeOpen: TOpenCloseEvent read write;
    property BeforeRead: TReadWriteEvent read write;
    property BeforeWrite: TReadWriteEvent read write;
    property OnError: TComErrorEvent read write;
  end;


What's new

Version 1.5
added Delphi 11 files


Only for V.I.P
Warning! You are not allowed to view this text.
  • 134