MNc@s_ddlZddlZddlZddlZyddlZWnek r\dZn XdZejjZ dZ dZ e d dkrdZ d Z d Zd Zd ZnPe d krdZn8e dkrdZn e d dks'e d dks'e d dkr3dZne d dkrOdZne d dkrkdZne d dkrdZne d d krd!Znte d d"krd#ZnXe d d$krd%Zn<ejjd&ejejejfed'ejfed(kr[x5eeD]!\ZZZd)eeefGHq3WndS(*iNcCsLy2tjdj|\}}|jjSWntdnXdS(Nt s lsusb failed(tostpopen4tjointreadtstriptIOError(targvtsitso((sA/usr/lib/python2.7/site-packages/serial/tools/list_ports_posix.pytpopen s cCs:y tj|dtjjSWntdnXdS(Ntstderrs lsusb failed(t subprocesst check_outputtSTDOUTRR(R((sA/usr/lib/python2.7/site-packages/serial/tools/list_ports_posix.pyR s cCsIy0t|}|jj}|j|SWntk rDdSXdS(s=help function to read a single line from a file. returns noneN(topentreadlineRtcloseRtNone(tfilenametftline((sA/usr/lib/python2.7/site-packages/serial/tools/list_ports_posix.pyt read_line s   cCs)tj||}|r%|jdSdS(s4search for regexp in text, return 1st group on matchiN(tretsearchtgroup(tregexpttexttm((sA/usr/lib/python2.7/site-packages/serial/tools/list_ports_posix.pytre_group*sitlinuxcCs~tjjtjj|jd\}}t|d}|rSd|f}nd}dt|dt|d|fS(sDgiven a path to a usb device in sysfs, return a string describing itt-s/serials SNR=%stsUSB VID:PID=%s:%s%ss /idVendors /idProduct(RtpathtbasenametrealpathtsplitR(t sysfs_pathtbustdevtsnrtsnr_txt((sA/usr/lib/python2.7/site-packages/serial/tools/list_ports_posix.pytusb_sysfs_hw_string4s-  c Cstjjtjj|jd\}}ytdddd||fg}td|}td|}td|pd }td |}td |}d |p||p||fSWntk rtSXdS( NRtlsusbs-vs-ss%s:%ssiManufacturer\s+\w+ (.+)siProduct\s+\w+ (.+)siSerial\s+\w+ (.+)R sidVendor\s+0x\w+ (.+)sidProduct\s+0x\w+ (.+)s%s %s %s( RR!R"R#R$R RRtbase( R%R&R'tdesct iManufacturertiProducttiSerialtidVendort idProduct((sA/usr/lib/python2.7/site-packages/serial/tools/list_ports_posix.pytusb_lsusb_stringBs-"! cCstjj|}d||f}tjj|rhtjjtjjtjj|}t|Sd|f}tjj|rt|S|S(s Get a human readable description. For USB-Serial devices try to run lsusb to get a human readable description. For USB-CDC devices read the description from sysfs. s"/sys/class/tty/%s/device/driver/%ss"/sys/class/tty/%s/device/interface(RR!R"texiststdirnameR#R3R(tdeviceR,t sys_dev_pathtsys_usb((sA/usr/lib/python2.7/site-packages/serial/tools/list_ports_posix.pytdescribeRs*   cCstjj|}tjjd|frd|f}tjj|rTt|Sd||f}tjj|rtjjtjjtjj|}t|S|jdrd|f}tjj|rt|dSqndS(s*Try to get a HW identification using sysfss/sys/class/tty/%s/devices/sys/class/tty/%s/device/ids"/sys/class/tty/%s/device/driver/%stttyACMs/..sn/a( RR!R"R4RR5R#R*t startswith(R6R,t sys_id_pathR7R8((sA/usr/lib/python2.7/site-packages/serial/tools/list_ports_posix.pythwinfods  *  cCsUtjdtjdtjd}g|D]!}|t|t|f^q0S(Ns /dev/ttyS*s /dev/ttyUSB*s /dev/ttyACM*(tglobR9R=(tdevicestd((sA/usr/lib/python2.7/site-packages/serial/tools/list_ports_posix.pytcomportsxs)tcygwincCs/tjd}g|D]}|||f^qS(Ns /dev/com*(R>(R?R@((sA/usr/lib/python2.7/site-packages/serial/tools/list_ports_posix.pyRA}stopenbsd3cCs/tjd}g|D]}|||f^qS(Ns /dev/ttyp*(R>(R?R@((sA/usr/lib/python2.7/site-packages/serial/tools/list_ports_posix.pyRAsitbsditfreebsdtopenbsdcCs/tjd}g|D]}|||f^qS(Ns /dev/cuad*(R>(R?R@((sA/usr/lib/python2.7/site-packages/serial/tools/list_ports_posix.pyRAsitdarwincCs/tjd}g|D]}|||f^qS(s8scan for available ports. return a list of device names.s /dev/tty.*(R>(R?R@((sA/usr/lib/python2.7/site-packages/serial/tools/list_ports_posix.pyRAstnetbsdcCs/tjd}g|D]}|||f^qS(s8scan for available ports. return a list of device names.s /dev/dty*(R>(R?R@((sA/usr/lib/python2.7/site-packages/serial/tools/list_ports_posix.pyRAsitirixcCs/tjd}g|D]}|||f^qS(s8scan for available ports. return a list of device names.s /dev/ttyf*(R>(R?R@((sA/usr/lib/python2.7/site-packages/serial/tools/list_ports_posix.pyRAsithpcCs/tjd}g|D]}|||f^qS(s8scan for available ports. return a list of device names.s /dev/tty*p0(R>(R?R@((sA/usr/lib/python2.7/site-packages/serial/tools/list_ports_posix.pyRAstsunoscCs/tjd}g|D]}|||f^qS(s8scan for available ports. return a list of device names.s /dev/tty*c(R>(R?R@((sA/usr/lib/python2.7/site-packages/serial/tools/list_ports_posix.pyRAstaixcCs/tjd}g|D]}|||f^qS(s8scan for available ports. return a list of device names.s /dev/tty*(R>(R?R@((sA/usr/lib/python2.7/site-packages/serial/tools/list_ports_posix.pyRAss0don't know how to enumerate ttys on this system. ! I you know how the serial ports are named send this information to ! the author of this module: sys.platform = %r os.name = %r pySerial version = %s also add the naming scheme of the serial ports and with a bit luck you can get this module running... s;Sorry: no implementation for your platform ('%s') availablet__main__s %s: %s [%s](R>tsysRRR t ImportErrorR tplatformtlowertplatRRR*R3R9R=RAR twritetnametserialtVERSIONt__name__tsortedtportR-thwid(((sA/usr/lib/python2.7/site-packages/serial/tools/list_ports_posix.pytsV