| Moteur de recherche de fiches techniques de composants électroniques |
|
AN197 Fiches technique(PDF) 6 Page - Silicon Laboratories |
|
|
|||||||||||||||||||||||||||||
AN197 Fiches technique(HTML) 6 Page - Silicon Laboratories |
|
6 / 14 page ![]() AN197 6 Rev. 0.6 5. Closing the COM Port After all communication is finished, then the COM port should then be closed. First, the COM port should be set back to its initial state, and then the handle to the COM port should be closed and set to an invalid handle. Example code is shown below: SetCommState(hMasterCOM, &dcbMasterInitState); Delay(60); CloseHandle(hMasterCOM); hMasterCOM = INVALID_HANDLE_VALUE; The SetCommState() function works the same as described in "3.3. Setting up a DCB Structure to Set the New COM State" on page 2. A delay of 60 ms is used to make sure the settings have time to be set. Finally the device is closed using the CloseHandle() function. This function just takes in the handle of the COM port. After this function is called, it is important to set the variable to an INVALID_HANDLE_VALUE. 6. Sample program to Demonstrate Serial Communications Included in the AN197SW.zip is a directory named "CP210xSerialTest" which contains the source code and executables for a Visual Studio project that makes use of all the serial communication functions described in section 3., section 4., and section 5. The program is a basic dialog based application that accepts two COM port numbers, and then will send a test array of 64 bytes of data back and forth between them. 7. Discovering CP210x COM Port To use the described functionality with a COM port, the number of the COM port needs to be known. In order to find out the COM port number of a CP210x device, the VID, PID, and serial number are used to lookup a registry key. This key is different between Windows XP/2000/Server 2003/Vista and Windows 98. Here are the keys that will need to be looked up: WinXP/2000/Server 2003/Vista (Driver Version 5.0 and higher): HKLM\System\CurrentControlSet\Enum\USB\Vid_xxxx&Pid_yyyy\zzzz\DeviceParameters\PortName WinXP/2000/Server 2003/Vista (Driver Version 4.40 and lower): HKLM\System\CurrentControlSet\Enum\USB\Vid_xxxx&Pid_yyyy&Mi_00\zzzz_00\DeviceParameters\PortName (where xxxx is the VID, yyyy is the PID, and zzzz is the serial number) |
|
|
Lien URL |
| ALLDATASHEET vous a-t-il été utile ? [ DONATE ] |
À propos de Alldatasheet | Publicité | Contactez-nous | Politique de confidentialité | Lien vers la fiche technique | Echange de liens | Fabricants All Rights Reserved©Alldatasheet.com |
| Russian : Alldatasheetru.com | Korean : Alldatasheet.co.kr | Spanish : Alldatasheet.es | French : Alldatasheet.fr | Italian : Alldatasheetit.com Portuguese : Alldatasheetpt.com | Polish : Alldatasheet.pl | Vietnamese : Alldatasheet.vn Indian : Alldatasheet.in | Mexican : Alldatasheet.com.mx | British : Alldatasheet.co.uk | New Zealand : Alldatasheet.co.nz |
|
Family Site : ic2ic.com |
icmetro.com |