rainit2006 / My_Windows

0 stars 0 forks source link

串口通信 #25

Open rainit2006 opened 6 years ago

rainit2006 commented 6 years ago

rainit2006 commented 6 years ago

Windows CreateFile : opens a communications port.

hPort1 = CreateFile (TEXT("COM5"),                      // Name of the port 
                        GENERIC_READ | GENERIC_WRITE,     // Access (read-write) mode 
                        0,                                  
                        NULL,                             
                        OPEN_EXISTING,
                        FILE_ATTRIBUTE_NORMAL,                     
                        NULL);                 

Writefile: transmitting data out the communications port . ReadFile: Reading Data from the Port. CloseHandle(hComm): close the serial port,

There are number of factors effecting read and write behaviours baud-rate, time-outs,Software flow control etc. These all values should be properly configured before read and write operations. ex. COMMTIMEOUTS,