Quickly Work With A COMPort On Linux With Delphi Using A WINSOFT library

For you who works with COM Port Applications on linux, this is the most easy and fast way to connect, write and read info.

Using  COMPORT for linux you can do it within literally few minutes, you just need to download the library and add it on your project, and this is it.

First of all you need to prepare your linux machine to deploy your Console application from a Windows.

On this example I’m using a Windows host running VM VirtualBox with Ubuntu.

Installing Development Packages

To install the development packages on Ubuntu:
  1. Right-click your desktop and select Open Terminal.
  2. To upgrade the packages you have already installed , type sudo apt update && sudo apt upgrade && sudo apt dist-upgrade in the terminal.
  3. Type your user password and press Enter
  4. Wait until prompted to agree to the package upgrade operation. Type Y and press Enter
  5. Wait until the package upgrade operation is complete. It may take a few minutes to complete.
  6. To add the development packages, type sudo apt install joe wget p7zip-full curl openssh-server build-essential zlib1g-dev libcurl4-gnutls-dev libncurses5 in the terminal.
  7. Type your user password and press Enter
  8. Wait until prompted to agree to the package installation operation. Type Y and press Enter
  9. Wait until the pacjage installation operation is complete. It may take a few minutes to complete.

Preparing Your Linux Machine

To create Linux applications, you need to add a virtual machine PAServer:

  1. Find the LinuxPAServer21.0.tar.gz file in the following location: C:Program Files (x86)EmbarcaderoStudio21.0PAServerLinuxPAServer21.0.tar.gz
  2. Unpack the LinuxPAServer21.0.tar.gz file.
  3. If needed Install the zlib library to your Ubuntu machine with the following command: sudo apt-get install zlib1g-dev
  4. Open the current dir on terminal and run it using ./paserver

Now that the Linux Machine is ready lets download and use the COMPORT Library.

Preparing Your Delphi application

Creating a Connection Profile

  1. On the Tools > Options > Environment Options > Connection Profile Manager page, click the Add button. The Create a Connection Profile wizard opens
  2. On the Profile information page, enter the following:
    • In the Profile name field, enter the needed name.
    • In the Platform field, click the 64-bit Linux platform.
    • Click Next.
  3. On the Remote machine information page, enter the following:
    • In the Remote machine field, enter the IP address or Machine name.
    • Click Test Connection to check if the values are valid.

Adding the Installed SDK to RAD Studio

  1. On the Tools > Options > Environment Options > SDK Manager page, click the Add button.
  2. In the Add a New SDK dialog, enter the following:
    • In the Select a platform field, click 64-bit Linux.
    • In the Select a profile to connect, select a created profile from the drop-down list.
    • In the Select an SDK version field, the name of the SDK that you just installed will automatically appear. If you have not installed SDK previously, you can do it on this step. If you have already installed SDK, move on to the next step.
Download the package from WINSOFT, unzip it and open the demo application with Delphi, after that just add the library path on the project properties.

The entire Tutorial for this process is here (available for Red Hat too).