Serial Port Synchronization in Delphi

后端 未结 5 467
不知归路
不知归路 2021-01-15 07:59

I am still having issues with the TComPort component but this time is not the component itself is the logic behind it. I have a device witch sends some ascii strings via ser

5条回答
  •  暖寄归人
    2021-01-15 08:49

    For certain amount of character we can use delay some miliseconds before ReadStr to make sure the data is completely sent. Example for 4 amount of character:

    procedure TForm1.ComPort1RxChar(Sender: TObject; Count: Integer);
    var
      Str: String;
      tegangan : real;
    begin
      sleep(100); //delay for 100ms
      ComPort1.ReadStr(Str, 4);
    

    ...

提交回复
热议问题