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-676e010a5bc56242769201-i/]and [crayon-676e010a5bc5e738784980-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-676e010a5bc60815634295/]

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

[crayon-676e010a5bc64487725040/]

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-676e010a5bc65389787010/]
[crayon-676e010a5bc66386281563/]

TComport has [crayon-676e010a5bc67165236269-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-676e010a5bc6b552773318/]

Now let’s update [crayon-676e010a5bc6c688151331-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-676e010a5bc6d185817173/]

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