• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 179
  • Last Modified:

Changing COM Port Settings

Hi there,
When im using the API WriteFile/ReadFile procedures to access the com port
how can i change the baud rate to 9600 and the flow control to Xon/Xoff?
0
tomerlei
Asked:
tomerlei
1 Solution
 
mokuleCommented:
var
  dcbPort:TDCB;
  hPort: THandle;
begin
    hPort := CreateFile('COM1',
                      GENERIC_READ or GENERIC_WRITE,
                      0, nil,
                      OPEN_EXISTING,
                      FILE_ATTRIBUTE_NORMAL,
                      LongInt(0));
    if hPort <> INVALID_HANDLE_VALUE then
      begin
      if GetCommState(hPort, dcbPort) then
        begin
        dcbPort.BaudRate := 9600;
        dcbPort.XoffChar := ;
        dcbPort.XonChar := ;
        SetCommState(hPort, dcbPort);
        end;
    end;
  end
end;
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now