Home > Software engineering > Question 2 API driver serial port communication device, the use of readfile (), writefile (), progra
Question 2 API driver serial port communication device, the use of readfile (), writefile (), progra
Time:10-08
Recently want to write a Win32 console application, mainly and a serial port communication equipment, you want to send commands to the device, and then received equipment returned data display on the console window, looking for some course, also know about the whole of the serial port driver, reading and writing process, is creatfile () configuration, DCB configuration, such as, but found the readfile () and writeflie () is in the main function call, and I want to have a serial port to read and write, has been constantly sending and receiving data, so I don't understand the data transfer is how to deal with, only know data from readfile () to my buff, so want to ask the next data from the equipment through a serial port communication to print to my console, what after? The buffer where it? Program is in the background of reading data from the interrupt way?
CodePudding user response:
Because I just turn around, from the aspects of embedded so familiar with commonly used microcontroller serial port interrupt way, speaking, reading and writing, and the concept of windos programming and application mechanism may not be very clear,,,, always feel that a serial port to read and write in the main function execution can realize real-time and background,,,,
CodePudding user response:
I want to realize the function,,, console procedures, instructions, and then input device after receiving instructions have been send the data to the host, the console interface, brush brush to flowing from these data.
CodePudding user response:
Using a serial port control MSCOMM baidu MSCOMM programming data under a pile of You want to send data suggest that you open a thread to send, receive is automatically receive, as long as there is data over a serial port, automatically triggers the receiving function that is more convenient,
CodePudding user response:
See the MSDN documentation Serial Communications in Win32