Site icon Embarcadero RAD Studio, Delphi, & C++Builder Blogs

Powerful Serial Communication Component for Delphi and C++ Builder on Windows

ComPort for Windows

Some days ago I wrote about Comport for Firemonkey by WinSoft but even if you are not planning to use FireMonkey we still have a great component for you: Comport for Windows (TComport) by WinSoft. 
Let’s download the trial version from here and install it (don’t forget to close RAD Studio before).

Features of TComport

Usage

The makers offer a good example of use but as always we will extend it a little and communicate with a GSM phone by reading full information using the phone internal modem.
I will be using a Samsung J3 for our tests and the phone will be connected to the computer by USB cable. After drivers install is finished we will see a modem in devices manager, in my case COM4, this being the serial port I will use to communicate with the phone.

Check out this step-by-step guide on how to download and use the ComPort DLL Library to make your developer life easy and increase your efficiency.


Let’s start the RAD Studio, open the demo project and run it. In order to communicate with the phone, we have to set up communications parameters and open communication.

Let’s add a TSpeedButton which will be used to send commands for reading the phone extended informations.

TComport has [crayon-6647047f9fecd386963612-i/]and [crayon-6647047f9fed7360788942-i/]events, which are very useful in case we want to do something when the port is open or closed. The demo already contains a procedure named UpdateComInfo which enables or disables the buttons according to the Active property of the port. We will add our SpeedButtonPhoneInfo inside this procedure too.

[crayon-6647047f9fed9408249366/]

Now on the [crayon-6647047f9fedb665820383-i/] event of our SpeedButtonPhoneInfo, we will send to the phone all the commands that are needed to read the full info.

[crayon-6647047f9fedc667373775/]

And here is the result:

But we see something strange, we see both commands sent but no answer and then we see answers to both commands, not very neat, so let’s correct this by adding a variable and two functions.

[crayon-6647047f9fede409941165/]
[crayon-6647047f9fedf553085359/]

TComport has [crayon-6647047f9fee1252624554-i/]event where we will set the HaveAnswer variable to true and in this way, we will know that phone has answered to our command (and before sending any command to the phone we will set the HaveAnswer variable to false).

[crayon-6647047f9fee3776339694/]

Now let’s update [crayon-6647047f9fee5344679363-i/] event for our SpeedButtonPhoneInfo with the new functions. I changed the Memo font size as the text was too big and set Memo.WordWrap to true, to can see the full phone info.

[crayon-6647047f9fee6214330961/]

And here is the new result:

So, if ComPort for Windows is the tool you need just go to WinSoft and and check out the full version!

Exit mobile version