/usr/lib/python3/dist-packages/serial/__pycache__
Edit: /usr/lib/python3/dist-packages/serial/__pycache__/serialjava.cpython-310.pyc (7296B)
o
^_ ! @ sL d dl mZ d dlT dd Zdd ZeddgZd d
ZG dd deZd
S ) )absolute_import)*c C s2 t | }| d}|dd D ]}t||}q|S )N. )
__import__splitgetattr)namemod
componentscomp r
3/usr/lib/python3/dist-packages/serial/serialjava.py my_import s
r c
C s@ | D ]}zt |}|j |W S ttfy Y qw td)z1try given list of modules and return that importsz/No Java Communications API implementation found)r
SerialPortImportErrorAttributeError)namesr r
r
r
r detect_java_comm s
r z
javax.commzgnu.ioc C sL t j }g }| r | }| t jjkr|| | s|| S )z%Turn a port number into a device name) commCommPortIdentifiergetPortIdentifiershasMoreElementsnextElementgetPortTypePORT_SERIALappendgetName)
portnumberenumportselr
r
r device, s
r" c @ s e Zd ZdZdd Zdd Zdd Zedd Zd%ddZ d
d Z
dd Zdd Zd&ddZ
dd Zdd Zdd Zedd Zedd Zed d! Zed"d# Zd$S )'Serialz Serial port class, implemented with Java Communications API and
thus usable with jython and the appropriate java extension.
c
C s | j du r td| jrtdt| j tdkr!tj| j }n tjt| j }z |dd| _ W n t
yH } z d| _ td| d}~ww | | j | _
| j | _d| _dS ) zx Open port with current settings. This may throw a SerialException
if the port cannot be opened.
Nz.Port must be configured before it can be used.zPort is already open. zpython serial module
zCould not open port: %sT)_portSerialExceptionis_opentyper r getPortIdentifierr" opensPort Exception_reconfigurePortgetInputStream _instreamgetOutputStream
_outstream)selfportIdmsgr
r
r r+ = s$
zSerial.openc C s | j std| j d | jtkrtjj}n%| jtkr!tjj }n| jt
kr+tjj}n| jtkr5tjj
}ntd| j | jtkrFtjj}n| jtkrPtjj}n| jtkrZtjj}ntd| j | jtkrktjj}n/| jtkrutjj}n%| jtkrtjj}n| jtkrtjj}n| jtkrtjj}ntd| j d }}| jr|tjjO }|tjjO }| jr|tjj O }|tjj!O }| j "| j#||| | j $||B | j%dkr| j t&| j%d dS | j ' dS ) z,Set communication parameters on opened port.z'Can only operate on a valid port handle zunsupported bytesize: %rz"unsupported number of stopbits: %rzunsupported parity type: %rr i N)(r, r' enableReceiveTimeout _bytesizeFIVEBITSr r
DATABITS_5SIXBITS
DATABITS_6 SEVENBITS
DATABITS_7 EIGHTBITS
DATABITS_8
ValueError _stopbitsSTOPBITS_ONE
STOPBITS_1STOPBITS_ONE_POINT_FIVESTOPBITS_1_5STOPBITS_TWO
STOPBITS_2_parityPARITY_NONEPARITY_EVEN
PARITY_ODDPARITY_MARKPARITY_SPACE_rtsctsFLOWCONTROL_RTSCTS_INFLOWCONTROL_RTSCTS_OUT_xonxoffFLOWCONTROL_XONXOFF_INFLOWCONTROL_XONXOFF_OUTsetSerialPortParams _baudratesetFlowControlMode_timeoutintdisableReceiveTimeout)r3 jdatabits jstopbitsjparityjflowinjflowoutr
r
r r. T sT
zSerial._reconfigurePortc C s> | j r| jr| j | j | j d| _d| _ dS dS )z
Close portNF)r( r, r0 closer2 r3 r
r
r r` s
zSerial.closec C s | j st | j S )z>Return the number of characters currently in the input buffer.)r, PortNotOpenErrorr0 availablera r
r
r
in_waiting s
zSerial.in_waitingr c C sl | j st t }|dkr2t||k r2| j }|dkr'| jdkr& t|S n|| t||k st|S )z Read size bytes from the serial port. If a timeout is set it may
return less characters as requested. With no timeout it will block
until the requested number of bytes is read.
r ) r, rb bytearraylenr0 readtimeoutr bytes)r3 sizerh xr
r
r rh s
zSerial.readc C sB | j st t|ttfstdtt|f | j| t |S )z-Output the given string over the serial port.z expected %s or bytearray, got %s)
r, rb
isinstancerj rf TypeErrorr) r2 writerg )r3 datar
r
r ro s zSerial.writec C s" | j st | j| j dS )z9Clear input buffer, discarding all that is in the buffer.N)r, rb r0 skiprc ra r
r
r reset_input_buffer s zSerial.reset_input_bufferc C s | j st | j dS )zs Clear output buffer, aborting the current output and
discarding all that is in the buffer.
N)r, rb r2 flushra r
r
r reset_output_buffer s zSerial.reset_output_buffer ?c C s | j st | j |d dS )zHSend break condition. Timed, returns to idle state after given duration.g @@N)r, rb sendBreak)r3 durationr
r
r
send_break s zSerial.send_breakc C s | j du rt td)zBSet break: Controls TXD. When active, to transmitting is possible.Nz