Have an amazing solution built in RAD Studio? Let us know. Looking for discounts? Visit our Special Offers page!
C++CodeDelphi

Learn How To Easily Work With A COMPort On Linux In Delphi Using A WINSOFT Library

comport-2

Using this awesome library you can track and use all available ComPorts on your linux machine.

To make it work just download and add the library path, declare the units and call its functions, it is easy, fast and efficient.

Follow the tutorial to learn how to implement this. In my case i was working with a Windows host running Ubuntu on VirtualBox.

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 on your windows machine, and send it to your linux machine:

C:Program Files (x86)EmbarcaderoStudio21.0PAServerLinuxPAServer21.0.tar.gz
2. Unpack the LinuxPAServer21.0.tar.gz file.
  1. Right-click the folder where you have unpacked the LinuxPAServer21.0.tar.gz file, and then click Open in Terminal.
  2. Enter ./paserver in terminal. Then, press Enter.
  3. Set your password.

Click here to see the full tutorial and how to install on Red Hat.

Now that the machine is ready to receive the deploy from windows, lets check how to implement the code, by the way, there are a simple demo showing how to work whit the library, you can download it here.

After download and open the demo project, follow the steps below to setup and deploy.

Remember to download the SDK for the target Linux OS.

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.
  4. Click Finish.

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

As you can see on the demo project, just declare the unit LComPort, to track and use the Ports declare the following variables:

Then you can use the following code to list them all:

and to send some data through the Port:

Hope you guys succeeded to make it work, looking forward to see what comes next.

WINSOFT Library link here, full tutorial Link here.


What's New for RAD Studio 11

Reduce development time and get to market faster with RAD Studio, Delphi, or C++Builder.
Design. Code. Compile. Deploy.
Start Free Trial   Upgrade Today

   Free Delphi Community Edition   Free C++Builder Community Edition

Related posts
DelphiRAD Studio

Delphi in the Galileo Project in Brazil

CodeDelphiNews

Everything You Need To Build A WSL GUI Tool Today

CodeDelphi

5 Ways To Improve Your Code: What You Need To Know

DelphiDeveloper InterviewsInterviewNews

What Is It Like To Be A Developer Dalija Prasnikar?

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

IN THE ARTICLES