
Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­
<!DOCTYPE html>
<html>
3
MÊ]Wõ  ã               @   sn   d dl Z d dlZd dlmZ G dd„ dejƒZdd„ Zedkrjx*eeƒ ƒD ]\Z	Z
Zedje	e
eƒƒ qJW dS )	é    N)Úlist_ports_commonc                   s(   e Zd ZdZ‡ fdd„Zdd„ Z‡  ZS )ÚSysFSz-Wrapper for easy sysfs access and device infoc                s°  t t| ƒj|ƒ tjj|ƒ| _d | _tjjdj	| jƒƒrrtjj
dj	| jƒƒ| _tjjtjj
tjj| jdƒƒƒ| _nd | _d | _| jdkr¢tjjtjj| jƒƒ| _n"| jdkr¾tjj| jƒ| _nd | _| jd k	�rLt| j| jdƒdƒ| _t| j| jdƒdƒ| _| j| jdƒ| _tjj| jƒ| _| j| jd	ƒ| _| j| jd
ƒ| _| j| jdƒ| _| jdk�rb| jƒ  nJ| jdk�rˆ| j| _| j| jdƒ| _n$| jdk�r¬| j| _tjj| jƒ| _d S )Nz/sys/class/tty/{}/deviceÚ	subsystemú
usb-serialÚusbZidVendoré   Z	idProductÚserialÚmanufacturerÚproductÚ	interfaceZpnpÚidZamba)r   r   )Úsuperr   Ú__init__ÚosÚpathÚbasenameÚnameZusb_device_pathÚexistsÚformatÚrealpathZdevice_pathÚjoinr   ÚdirnameÚintÚ	read_lineZvidÚpidZserial_numberÚlocationr	   r
   r   Zapply_usb_infoÚdescriptionÚhwid)ÚselfZdevice)Ú	__class__© ú&/usr/lib/python3.6/list_ports_linux.pyr      s:    $


zSysFS.__init__c             G   sF   y,t tjj|Ž ƒ�}|jƒ jƒ }W dQ R X |S  tk
r@   dS X dS )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   ÚreadlineÚstripÚIOError)r   ÚargsÚfÚliner    r    r!   r   8   s    zSysFS.read_line)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   Ú__classcell__r    r    )r   r!   r      s   %r   c              C   sb   t j dƒ} | jt j dƒƒ | jt j dƒƒ | jt j dƒƒ | jt j dƒƒ dd„ dd„ | D ƒD ƒS )	Nz
/dev/ttyS*z/dev/ttyUSB*z/dev/ttyACM*z/dev/ttyAMA*z/dev/rfcomm*c             S   s   g | ]}|j d kr|‘qS )Úplatform)r   )Ú.0Úinfor    r    r!   ú
<listcomp>L   s   zcomports.<locals>.<listcomp>c             S   s   g | ]}t |ƒ‘qS r    )r   )r/   Údr    r    r!   r1   M   s    )ÚglobÚextend)Zdevicesr    r    r!   ÚcomportsF   s    
r5   Ú__main__z{}: {} [{}])r3   r   Zserial.toolsr   ZListPortInfor   r5   r)   ÚsortedZportZdescr   Úprintr   r    r    r    r!   Ú<module>   s   6