Win32 Call to WriteFile Not Returning
-
6 พฤศจิกายน 2554 23:25
I've been using some serial comms code which uses WriteFile to write to an underlying port. I've found that on some occasions WriteFile does not return and I was wondering what the reasons might be which can cause WriteFile to not return.
I am aware that passing a number of bytes to be written which is larger than the actual data being written can cause it to not return but can anyone think of any other reasons?
ตอบทั้งหมด
-
7 พฤศจิกายน 2554 20:45
You can use the SetCommTimeouts function to change the WriteTimeout to whatever you need it to be in your application.
Does your driver support full duplex? If you have another thread doing a readfile or waitcommevent that is waiting for data with an infinite timeout, your writefile will wait until the port is free to write data (could be infinite if the readfile never returns).
-PaulH
- เสนอเป็นคำตอบโดย Jesse JiangMicrosoft, Moderator 8 พฤศจิกายน 2554 6:19
- ทำเครื่องหมายเป็นคำตอบโดย Jesse JiangMicrosoft, Moderator 2 ธันวาคม 2554 6:32