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-6741a593ad599740214654-i/]and [crayon-6741a593ad5a3191580977-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-6741a593ad5a5513544549/]

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

[crayon-6741a593ad5a8138564697/]

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-6741a593ad5aa972115422/]
[crayon-6741a593ad5ab813294775/]

TComport has [crayon-6741a593ad5ad132756893-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-6741a593ad5b0604581873/]

Now let’s update [crayon-6741a593ad5b1157213835-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-6741a593ad5b2079739502/]

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