3
M]W
@ sn d dl Z d dlZd dlmZ G dd dejZdd Zedkrjx*ee D ]\Z Z
Zedj
e e
e qJW dS ) N)list_ports_commonc s( e Zd ZdZ fddZdd Z ZS )SysFSz-Wrapper for easy sysfs access and device infoc s t t| j| tjj|| _d | _tjjdj | jrrtjj
dj | j| _tjjtjj
tjj| jd| _
nd | _d | _
| j
dkrtjjtjj| j| _n"| j
dkrtjj| j| _nd | _| jd k rLt| j| jdd| _t| j| jdd| _| j| jd| _tjj| j| _| j| jd | _| j| jd
| _| j| jd| _| j
dkrb| j nJ| j
dkr| j| _| j| jd
| _n$| j
dkr| j| _tjj| j| _d S )Nz/sys/class/tty/{}/device subsystem
usb-serialusbZidVendor Z idProductserialmanufacturerproduct interfaceZpnpidZamba)r r )superr __init__ospathbasenamenameZusb_device_pathexistsformatrealpathZdevice_pathjoinr dirnameint read_lineZvidpidZ
serial_numberlocationr r
r Zapply_usb_infodescriptionhwid)selfZdevice) __class__ &/usr/lib/python3.6/list_ports_linux.pyr s: $
zSysFS.__init__c G sF y,t tjj| }|j j }W dQ R X |S tk
r@ dS X dS )z Helper function to read a single line from a file.
One or more parameters are allowed, they are joined with os.path.join.
Returns None on errors..
N)openr r r readlinestripIOError)r argsfliner r r! r 8 s zSysFS.read_line)__name__
__module____qualname____doc__r r
__classcell__r r )r r! r s %r c C sb t j d} | jt j d | jt j d | jt j d | jt j d dd dd | D D S ) Nz
/dev/ttyS*z/dev/ttyUSB*z/dev/ttyACM*z/dev/ttyAMA*z/dev/rfcomm*c S s g | ]}|j d kr|qS )platform)r ).0infor r r!