Delphi Xe5 Serial Communication Port

Posted : admin On 26.08.2019
Delphi Xe5 Serial Communication Port 4,7/5 5449 votes
Port
  1. Delphi Xe5 Serial Communication Port Authority

Arduino Tutorial Delphi 10.2 and Serial Port. Interface created with Delphi that you can control the serial port to Arduino turning on and off a Led, handle the LCD and receive messages towards the PC. The Delphi environment with the pascal language is still current and its use in Arduino is growing more and more. Delphi source code. ZylSerialPort is a Delphi / CBuilder thread based asynchronous serial port component. Use ZylSerialPort component to easily communicate with external devices on serial port connection, such as modems, bar code readers, GSM modules and others. New: Revised the serial communication subsystem to improve compatibility with standard serial ports and even more serial port adapters. New: Every unhandled exception that. New: Added support for Embarcadero Delphi XE5, C++ Builder XE5 and RAD Studio XE5 (Win32 and Win64 target platforms).

Active6 years, 11 months ago

Hi I have the need to find the Baud rate and other settings for a serial port, Looking about on the web, it looks like I should be using GetCommConfig, This returns a TCommConfig record with what I assume is the data I need. The problem is the function I wote returns the wrong values.

The code below looks like it is working, but the baud rate is always 1200, which looking in windows device manager (and altering port settings), is wrong.

I have tried calling it like so:

the first 4 are valid but return 1200 and the 5th is invalid and returns 0

Stepping through the code, the first 4 always hit the line Result := CommConfig;, so the GetCommConfig is retuning a valid code, so I must be missing something.

I have tryed verious other things, such as setting the length of the dcb record, but all have the same result, as baud of 1200.

Does anyone know where I am going wrong?

Mike
31.5k22 gold badges88 silver badges159 bronze badges
Re0slessRe0sless
8,3744 gold badges44 silver badges63 bronze badges

2 Answers

Delphi Xe5 Serial Communication Port Authority

The baud rate and other settings for a serial port, are set when the serial port is opened.I think you are reading default values.

lg.lg.

It turns out I was using the wrong function, I should have been using GetDefaultCommConfig and not the GetCommConfig that I was using.

By the look if it, and please correct me if I am wrong, GetDefaultCommConfig returns the settings from windows and GetCommConfig returns the settings of the open connection to the port, writefile opens the port up as it see fit (ignoring the default settings), which is where the 1200 baud rate was coming from.

Delphi xe5 serial communication port authority

If this helps anyone in the future, here is the function I came up with.

Re0slessDelphi xe5 serial portRe0sless
8,3744 gold badges44 silver badges63 bronze badges

Not the answer you're looking for? Browse other questions tagged delphiserial-portcommunicationbaud-rate or ask your own question.