c g !bddlmZddlTdZdZeddgZdZGdd eZd S) )absolute_import)*ct|}|d}|ddD]}t||}|S)N.) __import__splitgetattr)namemod componentscomps a/home/jenkins/workspace/simtester-sanitize/venv/lib/python3.11/site-packages/serial/serialjava.py my_importrsK T  CCJ122!!c4   Jc|D]3} t|}|j|cS#ttf$rY0wxYwtd)z1try given list of modules and return that importsz/No Java Communications API implementation found)r SerialPort ImportErrorAttributeError)namesr r s rdetect_java_commrse D//C NNJJJ^,    D  G H HHs  44z javax.commzgnu.iocftj}g}|rd|}|tjjkr|||d||S)z%Turn a port number into a device name) commCommPortIdentifiergetPortIdentifiershasMoreElements nextElement getPortType PORT_SERIALappendgetName) portnumberenumportsels rdevicer&,s  " 5 5 7 7D E          >>  t6B B B LL          $ $ & &&rceZdZdZdZdZdZedZddZ dZ d Z d Z dd Z d ZdZdZedZedZedZedZdS)Serialz Serial port class, implemented with Java Communications API and thus usable with jython and the appropriate java extension. c|jtd|jrtdt|jtdkr%tj|j}n1tjt|j} |dd|_ n+#t$r}d|_ td|zd}~wwxYw| |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_opentyperrgetPortIdentifierr&opensPort Exception_reconfigurePortgetInputStream _instreamgetOutputStream _outstream)selfportIdmsgs rr1z Serial.open=s. : !"RSS S < ;!"9:: :   tBxx ' ',>>tzJJFF,>>vdj?Q?QRRF C%;R@@DJJ C C CDJ!";c"ABB B C 2244*4466 s)C C-C((C-c |jstd|jd|jtkrt jj}n}|jtkrt jj }n[|jtkrt jj }n9|jtkrt jj }ntd|jz|jt krt jj}n[|jt$krt jj}n9|jt(krt jj}ntd|jz|jt.krt jj}n|jt0krt jj}n}|jt2krt jj}n[|jt4krt jj}n9|jt6krt jj}ntd|jzdx}}|jr(|t jjz}|t jjz}|jr(|t jj z}|t jj!z}|j"|j#||||j$||z|j%dkr1|jtM|j%dzdS|j'dS) z,Set communication parameters on opened port.z'Can only operate on a valid port handlezunsupported bytesize: %rz"unsupported number of stopbits: %rzunsupported parity type: %rriN)(r2r-enableReceiveTimeout _bytesizeFIVEBITSrr DATABITS_5SIXBITS DATABITS_6 SEVENBITS DATABITS_7 EIGHTBITS DATABITS_8 ValueError _stopbits STOPBITS_ONE STOPBITS_1STOPBITS_ONE_POINT_FIVE STOPBITS_1_5 STOPBITS_TWO STOPBITS_2_parity PARITY_NONE PARITY_EVEN PARITY_ODD PARITY_MARK PARITY_SPACE_rtsctsFLOWCONTROL_RTSCTS_INFLOWCONTROL_RTSCTS_OUT_xonxoffFLOWCONTROL_XONXOFF_INFLOWCONTROL_XONXOFF_OUTsetSerialPortParams _baudratesetFlowControlMode_timeoutintdisableReceiveTimeout)r9 jdatabits jstopbitsjparityjflowinjflowouts rr4zSerial._reconfigurePortTsz M!"KLL L ''+++ >X % %2II ^w & &2II ^y ( (2II ^y ( (2II7$.HII I >\ ) )2II ^6 6 64II ^| + +2IIADNRSS S <; & &o1GG \[ ( (o1GG \Z ' 'o0GG \[ ( (o1GG \\ ) )o2GG:T\IJJ J( < ? t< >H = @ t= =G ? ?H &&t~y)WUUU %%g&8999 =A   J + +C d0B,C,C D D D D D J , , . . . . .rc|jrb|jrR|j|j|jd|_d|_dSdS)z Close portNF)r.r2r6closer8r9s rrhz Serial.closesn < !z "$$&&&%%'''   """!  DLLL  ! !rc^|jst|jS)z>Return the number of characters currently in the input buffer.)r2PortNotOpenErrorr6 availableris r in_waitingzSerial.in_waitings.z %"$$ $~'')))rrc@|jstt}|dkrgt||krT|j}|dkr |jdkrn)n||t||kTt|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) r2rk bytearraylenr6readtimeoutr bytes)r9sizerrxs rrrz Serial.reads z %"$$ ${{ !88d))d""N''))77|q(()KKNNN d))d""T{{rc|jstt|ttfs't dtdt ||j|t|S)z-Output the given string over the serial port.z expected z or bytearray, got ) r2rk isinstancertrp TypeErrorr/r8writerq)r9datas rrzz Serial.writessz %"$$ $$ 233 V)%%%dTUU U d###4yyrc|jst|j|jdS)z9Clear input buffer, discarding all that is in the buffer.N)r2rkr6skiprlris rreset_input_bufferzSerial.reset_input_buffersBz %"$$ $ DN446677777rcb|jst|jdS)zs Clear output buffer, aborting the current output and discarding all that is in the buffer. N)r2rkr8flushris rreset_output_bufferzSerial.reset_output_buffers4 z %"$$ $ r?cj|jst|j|dzdS)zHSend break condition. Timed, returns to idle state after given duration.g@@N)r2rk sendBreak)r9durations r send_breakzSerial.send_breaks8z %"$$ $ Xf_-----rcJ|jttd)zBSet break: Controls TXD. When active, to transmitting is possible.Nzrs'&&&&& I I I  '''DDDDDZDDDDDr