Serial Port Synchronization in Delphi

后端 未结 5 2039
醉酒成梦
醉酒成梦 2021-01-15 08:18

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:51

    After using a number of serial-port-components, I've got the best results until now, by using CreateFile('\\?\COM1',GENERIC_READ or GENERIC_WRITE,0,nil,OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL,0), passing that handle to a THandleStream instance, and starting a dedicated thread to read from it. I know threads take a little more work than writing an event handler, but it still is the best way to handle any synchronization issues that arise from using serial ports.

提交回复
热议问题