ó ¸ˆ°Nc @s@ddlZddlZd„ZddlZddlmZmZddlmZddlm Z ddlm Z ddlm Z ddlm Z dd lm Z dd lmZdd lmZdd lmZdd lmZdZejZejZejZeje ƒZZejZZejeƒZe ZeZ d„Z!d„Z"dej#fd„ƒYZ$dej#fd„ƒYZ%eje%ƒZ&dej#fd„ƒYZ'eje'ƒZ(ejZ)ej*j+dƒZ,e,j-Z-ege-_.e e-_/e,j0Z1eje$ƒee e ge1_.ee1_/ee1_2e,j3Z3ee&eje$ƒe e(ge3_.e e3_/e,j4Z5ee(e)e ee&ge5_.e e5_/e,j6Z7ee&e eee ege7_.e e7_/e,j8Z8ee&e e e e ge8_.ee8_/ej*j+dƒZ9e9j:Z:ege:_.e e:_/e9j;Z<eeeeeege<_.e e<_/e$dddeddddddd d!d"ƒƒZ=d#Z>d$Z?dZ@d%ZAd&ZBd'ZCd(ZDd&ZEd&ZFd)ZGd&ZHejId*d+d,d-d.d/d0d1gƒZJd2„ZKeLd3kr<ddlZx5eMeKƒƒD]!\ZNZOZPd4eNeOePfGHqWndS(5iÿÿÿÿNcCs|dkrtjƒ‚n|S(Ni(tctypestWinError(tvaluetfunct arguments((sC/usr/lib/python2.7/dist-packages/serial/tools/list_ports_windows.pyt ValidHandles (t ULONG_PTRtis_64bit(tHANDLE(tBOOL(tHWND(tDWORD(tWORD(tLONG(tULONG(tLPCSTR(tHKEY(tBYTEicCs t|ƒS(sGet a buffer for a string(R(tlength((sC/usr/lib/python2.7/dist-packages/serial/tools/list_ports_windows.pyt byte_buffer#scCsKg}x5|D]-}|dkr#Pn|jt|d@ƒƒq Wdj|ƒS(Niiÿt(tappendtchrtjoin(tbuffertstc((sC/usr/lib/python2.7/dist-packages/serial/tools/list_ports_windows.pytstring's   tGUIDcBs?eZdefdefdefdedfgZd„ZRS(tData1tData2tData3tData4ic Csnd|j|j|jdjg|jd D]}d|^q)ƒdjg|jdD]}d|^qSƒfS(Ns{%08x-%04x-%04x-%s-%s}Ris%02x(RRRRR (tselftd((sC/usr/lib/python2.7/dist-packages/serial/tools/list_ports_windows.pyt__str__6s *(t__name__t __module__R R Rt_fields_R#(((sC/usr/lib/python2.7/dist-packages/serial/tools/list_ports_windows.pyR/s    tSP_DEVINFO_DATAcBs;eZdefdefdefdefgZd„ZRS(tcbSizet ClassGuidtDevInsttReservedcCsd|j|jfS(NsClassGuid:%s DevInst:%s(R)R*(R!((sC/usr/lib/python2.7/dist-packages/serial/tools/list_ports_windows.pyR#Fs(R$R%R RRR&R#(((sC/usr/lib/python2.7/dist-packages/serial/tools/list_ports_windows.pyR'?s    tSP_DEVICE_INTERFACE_DATAcBs;eZdefdefdefdefgZd„ZRS(R(tInterfaceClassGuidtFlagsR+cCsd|j|jfS(NsInterfaceClassGuid:%s Flags:%s(R-R.(R!((sC/usr/lib/python2.7/dist-packages/serial/tools/list_ports_windows.pyR#Qs(R$R%R RRR&R#(((sC/usr/lib/python2.7/dist-packages/serial/tools/list_ports_windows.pyR,Js    tsetupapitAdvapi32làQÁ i‰€iÐiiœiäi>i0iisiiizii iiiPioiritiNiaimiec #sttjtƒd tttBƒ}xétdƒD]Û}t ƒ}tj |ƒ|_ t |d tjtƒ|tj|ƒƒsŸtj ƒtkr›tjƒ‚nPntƒ‰t|tj|ƒd dtjˆƒd ƒsùtj ƒtkrùtjƒ‚qùndtjf‡fd†ƒY}|ƒ}tƒr6d|_ n d|_ tƒ}tj |ƒ|_ t|tj|ƒtj|ƒˆd tj|ƒƒsŸtjƒ‚ntdƒ}t|tj|ƒtd tj|ƒtj |ƒdd ƒs t ƒtkr tjƒ‚q ntdƒ}t|tj|ƒtd tj|ƒtj |ƒdd ƒsptj ƒtkr d }q q/t|tj|ƒtdttƒ} tdƒ} ttj | ƒƒ} t| t d d tj| ƒtj| ƒƒt!| ƒt"| ƒt"|ƒt"|ƒfVq/Wt#|ƒd S( sRThis generator scans the device registry for com ports and yields port, desc, hwidiit!SP_DEVICE_INTERFACE_DETAIL_DATA_Acs=eZdefdeˆjejeƒfgZd„ZRS(R(t DevicePathcSsd|jfS(Ns DevicePath:%s(R2(R!((sC/usr/lib/python2.7/dist-packages/serial/tools/list_ports_windows.pyR#¦s( R$R%R tCHARRRtsizeofR&R#((tdwNeeded(sC/usr/lib/python2.7/dist-packages/serial/tools/list_ports_windows.pyR1¡s #iiiúiN($tSetupDiGetClassDevsRtbyreftGUID_CLASS_COMPORTtNonetNULLt DIGCF_PRESENTtDIGCF_DEVICEINTERFACEtrangeR,R4R(tSetupDiEnumDeviceInterfacest GetLastErrortERROR_NO_MORE_ITEMSRR tSetupDiGetDeviceInterfaceDetailtERROR_INSUFFICIENT_BUFFERt StructureRR'Rt SetupDiGetDeviceRegistryPropertytSPDRP_HARDWAREIDtSPDRP_FRIENDLYNAMEtSetupDiOpenDevRegKeytDICS_FLAG_GLOBALt DIREG_DEVtKEY_READRtRegQueryValueExtPortNamet RegCloseKeyRtSetupDiDestroyDeviceInfoList( tg_hditdwIndextdidR1tiddtdevinfot szHardwareIDtszFriendlyNamet port_namethkeytport_name_buffertport_name_length((R5sC/usr/lib/python2.7/dist-packages/serial/tools/list_ports_windows.pytcomportssH" * -     6 = = $ + $t__main__s %s: %s [%s](QRtreRtserialt serial.win32RRtctypes.wintypesRR R R R R RRRRR:tc_void_ptHDEVINFOtc_char_ptPCTSTRtc_charR3tPOINTERtLPDWORDtPDWORDtLPBYTEtPBYTEtPHKEYt ACCESS_MASKtREGSAMRRRCRR'tPSP_DEVINFO_DATAR,tPSP_DEVICE_INTERFACE_DATAt PSP_DEVICE_INTERFACE_DETAIL_DATAtwindllt LoadLibraryR/RNtargtypestrestypetSetupDiGetClassDevsAR6terrcheckR>t SetupDiGetDeviceInterfaceDetailARAt!SetupDiGetDeviceRegistryPropertyARDRGtadvapi32RMtRegQueryValueExARKR8R;R<tINVALID_HANDLE_VALUERBRERFR@RHRIRJtREG_SZtto_bytesRLRZR$tsortedtporttdescthwid(((sC/usr/lib/python2.7/dist-packages/serial/tools/list_ports_windows.pytsš                    !             (' @