![ComPort for FireMonkey | Embarcadero RAD Studio Delphi C++Builder Blogs ComPort for FireMonkey](https://i0.wp.com/blogs.embarcadero.com/wp-content/uploads/2020/08/comport1200x675.jpg?resize=1140%2C675&ssl=1)
ComPort for FireMonkey (TFComport) it’s an easy to use and very powerful component to communicate with devices connected to the serial port.
You can download a trial version of the component from the creator web WinSoft.
Features of TFComport
- It’s easy to use and very powerful
- Can communicate with any device connected to the serial port using RS232 protocol
- It’s using multithreading and overlapping for maximum performance
- Source code included in the registered version
- It’s supporting Delphi/C++ Builder XE2 – 10.4 on Windows 32/64-bit
- Royalty-free distribution in applications
Installation
Installation is quite simple and automatic: download the installer from here, run it and follow the steps (close the IDE before start to install).
Usage
The creators offer a good demo project here as an example of use but we will extend little by communicating with a GSM mobile phone.
Usually, a GSM mobile phone has an integrated modem with who we can communicate using serial port and use standard AT commands.
The plan is to use TFComport to send some AT commands to the phone and read the phone answer.
I will use a Samsung Galaxy A10e for our tests. The phone will be connected to the computer by USB cable and normally Windows 10 will install required drivers.
After drivers install finished we will see a modem device in devices manager. COM5 will be the serial port what we will use to communicate with the phone.
![Modem port | Embarcadero RAD Studio Delphi C++Builder Blogs Modem port](https://i0.wp.com/blogs.embarcadero.com/wp-content/uploads/2020/08/device_manager01.jpg?resize=750%2C551&ssl=1)
Let’s start the IDE, open the demo project and run it.
In order to communicate with any device be serial port we have to respect the next steps: set the communication parameters and open communication.
![demo_app03-6657335](https://i0.wp.com/blogs.embarcadero.com/wp-content/uploads/2020/08/demo_app03-6657335.jpg?w=750&ssl=1)
![demo_app04-9316602](https://i0.wp.com/blogs.embarcadero.com/wp-content/uploads/2020/08/demo_app04-9316602.jpg?w=750&ssl=1)
![demo_app06-2642346](https://i0.wp.com/blogs.embarcadero.com/wp-content/uploads/2020/08/demo_app06-2642346.jpg?w=750&ssl=1)
We drop a TEdit (EditCommand) for the command and a TButton (ButtonSend) to send command to the phone.
![| Embarcadero RAD Studio Delphi C++Builder Blogs](https://i0.wp.com/blogs.embarcadero.com/wp-content/uploads/2020/08/demo_app08.jpg?resize=600%2C412&ssl=1)
TFComport has an AfterOpen event, which is 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.
![FComportAfterOpen01 | Embarcadero RAD Studio Delphi C++Builder Blogs](https://i0.wp.com/blogs.embarcadero.com/wp-content/uploads/2020/08/FComportAfterOpen01.jpg?resize=750%2C570&ssl=1)
We modify the UpdateComInfo procedure to include our EditCommand and SendButton:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
procedure TFormMain.UpdateComInfo; begin if not FDisableUpdate then with FComPort do begin if Active then ButtonOpenClose.Text := 'Close' else ButtonOpenClose.Text := 'Open'; Memo.Enabled := Active; if Active then Memo.SetFocus; ComboBoxDeviceName.Enabled := not Active; ButtonConfig.Enabled := not Active; ButtonSetRTS.Enabled := Active; ButtonClearRTS.Enabled := Active; ButtonSetDTR.Enabled := Active; ButtonClearDTR.Enabled := Active; //---- our addtition ButtonSend.Enabled := Active; EditCommand.Enabled := Active; end; end; |
Now we need to send command to the phone at the Click event for our ButtonSend:
1 2 3 4 5 |
procedure TFormMain.ButtonSendClick(Sender: TObject); begin Memo.Lines.Add('AT Command sent: '+EditCommand.Text); FComPort.Write(EditCommand.Text+#13#10,TEncoding.ANSI); end; |
And here is the result:
![demoapp09 | Embarcadero RAD Studio Delphi C++Builder Blogs](https://i0.wp.com/blogs.embarcadero.com/wp-content/uploads/2020/08/demo_app09.jpg?resize=725%2C534&ssl=1)
If ComPort for FireMonkey is the tool you need just go to WinSoft and and check out the full version!
Like what you see? You can get the ComPort Component Suite together with over 100 other fantastic WinSoft components with our Enterprise Component Pack. For a limited time, when you purchase RAD Studio Enterprise or Architect Edition at special Upgrade Pricing, you will also get this package of third-party software worth over $13,000, including the full WinSoft Component Library, at NO EXTRA COST! Step up to RAD Studio 10.4 today!
Design. Code. Compile. Deploy.
Start Free Trial Upgrade Today
Free Delphi Community Edition Free C++Builder Community Edition
The component is working windows10(development PC). But giving I/O Error 103 in Windows 7(deployment PC). Am I missing something?
Hello
I am glad you use the component, I will check it in Windows 7 too and come back to you.
Hello
I have test it in Windows 7 and I not get any error, can you give more info? (like computer hardware, windows build version)
Thank you
Is this component also working in RS485?