Hi,
In Synaser, we can read the logic states of DSR and CTS pins, but not RTS and DTR.
RTS and DTR pin logic states can only be written by using the EscapeCommFunction, that is declared in redef.inc
In redef.inc, we have this: DeviceIoControl, that in theory can access to the logic states of RTS and DTR pins.
I tried to test it in this very basic code:
function TBlockSerial.GetRTSF;
var
iostatus, tmp: DWORD;
testlw: longword;
olp: POVERLAPPED;
begin
{$IFNDEF MSWINDOWS}
{$ELSE}
DeviceIoControl(FHandle, 1769592{IOCTL_SERIAL_GET_DTRRTS}, @testlw, 0, @iostatus, sizeof(iostatus), @tmp, @olp);
result := true;
{$ENDIF}
end;
But the problem is IOCTL_SERIAL_GET_DTRRTS is a macro, that is only defined in ntddser.h header file.
https://doxygen.reactos.org/d5/d2e/ntddser_8h_source.html#l00056 1769592 is a value for that according to chatgpt, but it is deffinitly wrong.
Is there a way to get use that macro? Or is it defined in some unit?
Or is there a better way to get the logic states of those pins?
More info:
https://stackoverflow.com/questions/59408368/getting-dtr-and-rts-pin-of-serial-port-in-c-on-windows-platformhttps://learn.microsoft.com/en-us/windows/win32/devio/calling-deviceiocontrol