OVERLAPPED Serial Communication
-
I am currenlty going through a former colleague's code who used OVERLAPPED I/O to receive asynchronous serial data. The program first declare a pointer variable pRxBuffer which will contain the received data. It then creates the port, then creates an overlapped event, and then reads the port which contains no data. The program then waits indefinitely using WaitForMultipleObjects function. When the data arrives, the pointer variable pRxBuffer is immediately filled with the received data without using the ReadFile fucntion (or so it seems) and prior to calling the GerOverlappedResult function. If this makes sense to someone, can you please explain to me how this is possible? How is the data transferred to pRxBuffer. Thanks
-
I am currenlty going through a former colleague's code who used OVERLAPPED I/O to receive asynchronous serial data. The program first declare a pointer variable pRxBuffer which will contain the received data. It then creates the port, then creates an overlapped event, and then reads the port which contains no data. The program then waits indefinitely using WaitForMultipleObjects function. When the data arrives, the pointer variable pRxBuffer is immediately filled with the received data without using the ReadFile fucntion (or so it seems) and prior to calling the GerOverlappedResult function. If this makes sense to someone, can you please explain to me how this is possible? How is the data transferred to pRxBuffer. Thanks
That's how it works. Basically, the initial ReadFile tells windows: here is a buffer, and here is the overlapped event is where I want you to tell me when you've filled the buffer. There should also be a check on the return of ReadFile to check if the data has already arrived (which is possible). Neil
-
That's how it works. Basically, the initial ReadFile tells windows: here is a buffer, and here is the overlapped event is where I want you to tell me when you've filled the buffer. There should also be a check on the return of ReadFile to check if the data has already arrived (which is possible). Neil