Moteur de recherche de fiches techniques de composants électroniques
  French  ▼
ALLDATASHEET.FR

X  

AN197 Fiches technique(PDF) 7 Page - Silicon Laboratories

No de pièce AN197
Description  SERIAL COMMUNICATIONS GUIDE FOR THE CP210X
PDF  14 Pages
Scroll/Zoom Zoom In 100%  Zoom Out
Fabricant  SILABS [Silicon Laboratories]
Site Internet  http://www.silabs.com
Logo SILABS - Silicon Laboratories

AN197 Fiches technique(HTML) 7 Page - Silicon Laboratories

Back Button AN197 Datasheet HTML 3Page - Silicon Laboratories AN197 Datasheet HTML 4Page - Silicon Laboratories AN197 Datasheet HTML 5Page - Silicon Laboratories AN197 Datasheet HTML 6Page - Silicon Laboratories AN197 Datasheet HTML 7Page - Silicon Laboratories AN197 Datasheet HTML 8Page - Silicon Laboratories AN197 Datasheet HTML 9Page - Silicon Laboratories AN197 Datasheet HTML 10Page - Silicon Laboratories AN197 Datasheet HTML 11Page - Silicon Laboratories Next Button
Zoom Inzoom in Zoom Outzoom out
 7 / 14 page
background image
AN197
Rev. 0.6
7
7.1. Windows XP/2000/Server 2003/Vista
To find the port number in Windows XP/2000/Server 2003/Vista, the corresponding key listed above needs to be
opened. This is done using several registry calls using Windows API functions. The function is passed the VID,
PID, and serial number, and the return value is either the port number that the CP210x is located on, or a –1 if
there is a failure. The function below will find the CP210x port number in Windows XP/2000/Server 2003/Vista (this
function can be copied straight into application code that needs to discover the COM port number):
int GetPortNumXP2000Vista(WORD vid, WORD pid, char* ser)
{
//Variables used for Registry access
HKEY tmpKey, tmpSubKey, tmpPortKey;
CString portKeyString;
DWORD valtype;
char* portString;
DWORD length = 100;
portString = new char[101];
//Set portnum to -1, so if there is an error we will
//know by returning a negative port value
int portNum = -1;
//
Open keys to get to the key where the port number is located. This key is:
//
HKLM\System\CurrentControlSet\Enum\USB\Vid_xxxx&Pid_yyyy&Mi_00\zzzz_00\DeviceParameters\PortN
ame
if (ERROR_SUCCESS == RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\", 0,
KEY_READ, &tmpKey))
{
if (ERROR_SUCCESS == RegOpenKey(tmpKey, "Enum\\USB\\", &tmpSubKey))
{
//Loop through and replace spaces for WinXP2000Vista
int i = 0;
while (ser[i] != '\0')
{
if (ser[i] == 0x20)
ser[i] = '_';
i++;
}
//The portkey string should look like this
//"Vid_XXXX&Pid_XXXX&MI_00\\XXXX_00" where the XXXX's are Vid, Pid and serial string
- version less than 5.0
//"Vid_XXXX&Pid_XXXX\\XXXX" where the XXXX's are Vid, Pid and serial string -
version greater than or equal to 5.0
portKeyString.Format("Vid_%04x&Pid_%04x&Mi_00\\%s_00\\Device
Parameters\\",
vid,
pid, ser);
//If the portkey string is in the registry, then go ahead and open the portname
if
(ERROR_SUCCESS
==
RegOpenKeyEx(tmpSubKey,
portKeyString,
0,
KEY_READ,
&tmpPortKey))
{
if (ERROR_SUCCESS == RegQueryValueEx(tmpPortKey, "PortName", NULL, &valtype,
(unsigned char *)portString, &length))
{
// When we obtain this key, it will be in string format of
// "COMXX" where XX is the port. Simply make the first three
// elements of the string 0, and call the atoi function to obtain
// the number of the port.



Html Pages

1 2 3 4 5 6 7 8 9 10 11 12 13 14


Fiches technique Télécharger

Go To PDF Page


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


Mirror Sites
English : Alldatasheet.com  |   English : Alldatasheet.net  |   Chinese : Alldatasheetcn.com  |   German : Alldatasheetde.com  |   Japanese : Alldatasheet.jp
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