Nc @s@ddlZddlZdZddlZddlmZmZddlmZddlm Z ddlm Z ddlm Z ddlm Z dd lm Z dd lmZdd lmZdd lmZdd lmZdZejZejZejZeje ZZejZZejeZe ZeZ dZ!dZ"dej#fdYZ$dej#fdYZ%eje%Z&dej#fdYZ'eje'Z(ejZ)ej*j+dZ,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+dZ9e9j: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/d0d1gZJd2ZKeLd3kr<ddlZx5eMeKD]!\ZNZOZPd4eNeOePfGHqWndS(5iNcCs|dkrtjn|S(Ni(tctypestWinError(tvaluetfunct arguments((sC/usr/lib/python2.7/site-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/site-packages/serial/tools/list_ports_windows.pyt byte_buffer#scCsKg}x5|D]-}|dkr#Pn|jt|d@q Wdj|S(Niit(tappendtchrtjoin(tbuffertstc((sC/usr/lib/python2.7/site-packages/serial/tools/list_ports_windows.pytstring's   tGUIDcBs?eZdefdefdefdedfgZdZRS(tData1tData2tData3tData4ic Csnd|j|j|jdjg|jd D]}d|^q)djg|jdD]}d|^qSfS(Ns{%08x-%04x-%04x-%s-%s}Ris%02x(RRRRR (tselftd((sC/usr/lib/python2.7/site-packages/serial/tools/list_ports_windows.pyt__str__6s *(t__name__t __module__R R Rt_fields_R#(((sC/usr/lib/python2.7/site-packages/serial/tools/list_ports_windows.pyR/s    tSP_DEVINFO_DATAcBs;eZdefdefdefdefgZdZRS(tcbSizet ClassGuidtDevInsttReservedcCsd|j|jfS(NsClassGuid:%s DevInst:%s(R)R*(R!((sC/usr/lib/python2.7/site-packages/serial/tools/list_ports_windows.pyR#Fs(R$R%R RRR&R#(((sC/usr/lib/python2.7/site-packages/serial/tools/list_ports_windows.pyR'?s    tSP_DEVICE_INTERFACE_DATAcBs;eZdefdefdefdefgZdZRS(R(tInterfaceClassGuidtFlagsR+cCsd|j|jfS(NsInterfaceClassGuid:%s Flags:%s(R-R.(R!((sC/usr/lib/python2.7/site-packages/serial/tools/list_ports_windows.pyR#Qs(R$R%R RRR&R#(((sC/usr/lib/python2.7/site-packages/serial/tools/list_ports_windows.pyR,Js    tsetupapitAdvapi32lQ iiiiii>i0iisiiizii iiiPioiritiNiaimiec #sttjtd tttB}xtdD]}t }tj ||_ t |d tjt|tj|stj tkrtjnPntt|tj|d dtjd stj tkrtjqndtjffdY}|}tr6d|_ n d|_ t}tj ||_ t|tj|tj|d tj|stjntd}t|tj|td tj|tj |dd s t tkr tjq 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=eZdefdejejefgZdZRS(R(t DevicePathcSsd|jfS(Ns DevicePath:%s(R2(R!((sC/usr/lib/python2.7/site-packages/serial/tools/list_ports_windows.pyR#s( R$R%R tCHARRRtsizeofR&R#((tdwNeeded(sC/usr/lib/python2.7/site-packages/serial/tools/list_ports_windows.pyR1s #iiiiN($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/site-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/site-packages/serial/tools/list_ports_windows.pyts                    !             (' @