options-group-audit-log.php000064400000011031147207151010011757 0ustar00

Audit Log logging mode is set to "Significant Events", all events except content changes will be recorded. "All Events" will include content-related events and may be used to monitor for unauthorized post or page changes. "Preview" and "Disabled" modes do not send any events to Central.', 'wordfence'), array('strong'=>array())); ?>

true, 'restoreDefaultsSection' => wfConfig::OPTIONS_TYPE_AUDIT_LOG, 'restoreDefaultsMessage' => __('Are you sure you want to restore the default Audit Log settings? This will undo any custom changes you have made to the options on this page.', 'wordfence'), ))->render(); ?>
  • 'auditLogMode', 'value' => wfAuditLog::shared()->mode(), 'title' => __('Audit Log logging mode', 'wordfence'), 'states' => array( array('value' => wfAuditLog::AUDIT_LOG_MODE_DISABLED, 'label' => __('Disabled', 'wordfence')), array('value' => wfAuditLog::AUDIT_LOG_MODE_PREVIEW, 'label' => __('Preview', 'wordfence'), 'disabled' => $wpTooOld), array('value' => wfAuditLog::AUDIT_LOG_MODE_SIGNIFICANT, 'labelHTML' => wp_kses(__('Significant Events', 'wordfence'),array('span' => array('class' => array('wf-hidden-xs')))), 'disabled' => $wpTooOld), array('value' => wfAuditLog::AUDIT_LOG_MODE_ALL, 'labelHTML' => wp_kses(__('All Events', 'wordfence'),array('span' => array('class' => array('wf-hidden-xs')))), 'disabled' => $wpTooOld), ), 'helpLink' => wfSupportController::supportURL(wfSupportController::ITEM_TOOLS_AUDIT_LOG_OPTION_MODE), 'alignment' => 'wf-right', 'noSpacer' => true, ))->render(); ?>
  • 'displayTopLevelAuditLog', 'enabledValue' => 1, 'disabledValue' => 0, 'value' => wfConfig::get('displayTopLevelAuditLog') ? 1 : 0, 'title' => __('Display Audit Log menu option', 'wordfence'), ))->render(); ?>
options-group-live-traffic.php000064400000013125147207151010012453 0ustar00

Traffic logging mode to "Security Only."', 'wordfence'), array('strong'=>array())); ?>

true, 'restoreDefaultsSection' => wfConfig::OPTIONS_TYPE_LIVE_TRAFFIC, 'restoreDefaultsMessage' => __('Are you sure you want to restore the default Live Traffic settings? This will undo any custom changes you have made to the options on this page.', 'wordfence'), ))->render(); ?>
  • 'liveTrafficEnabled', 'value' => wfConfig::get('liveTrafficEnabled') ? '1': '0', 'title' => __('Traffic logging mode', 'wordfence'), 'states' => array( array('value' => '0', 'label' => __('Security Only', 'wordfence')), array('value' => '1', 'label' => __('All Traffic', 'wordfence')), ), 'helpLink' => wfSupportController::supportURL(wfSupportController::ITEM_TOOLS_LIVE_TRAFFIC_OPTION_ENABLE), 'alignment' => 'wf-right', ))->render(); ?>
  • 'liveTraf_ignorePublishers', 'enabledValue' => 1, 'disabledValue' => 0, 'value' => wfConfig::get('liveTraf_ignorePublishers') ? 1 : 0, 'title' => __("Don't log signed-in users with publishing access", 'wordfence'), ))->render(); ?>
  • 'liveTraf_ignoreUsers', 'textValue' => wfConfig::get('liveTraf_ignoreUsers'), 'title' => __('List of comma separated usernames to ignore', 'wordfence'), ))->render(); ?>
  • 'liveTraf_ignoreIPs', 'textValue' => wfConfig::get('liveTraf_ignoreIPs'), 'title' => __('List of comma separated IP addresses to ignore', 'wordfence'), ))->render(); ?>
  • 'liveTraf_ignoreUA', 'textValue' => wfConfig::get('liveTraf_ignoreUA'), 'title' => __('Browser user-agent to ignore', 'wordfence'), ))->render(); ?>
  • 'liveTraf_maxRows', 'textValue' => wfConfig::get('liveTraf_maxRows'), 'title' => __('Amount of Live Traffic data to store (number of rows)', 'wordfence'), ))->render(); ?>
  • 'liveTraf_maxAge', 'textValue' => wfConfig::get('liveTraf_maxAge'), 'title' => __('Maximum days to keep Live Traffic data (1-30 days)', 'wordfence'), ))->render(); ?>
  • 'displayTopLevelLiveTraffic', 'enabledValue' => 1, 'disabledValue' => 0, 'value' => wfConfig::get('displayTopLevelLiveTraffic') ? 1 : 0, 'title' => __('Display Live Traffic menu option', 'wordfence'), ))->render(); ?>
options-group-2fa.php000064400000011553147207151010010553 0ustar00

and have control of your phone to log into your site. Upgrade to Premium now to enable this powerful feature.', 'wordfence'), array('em'=>array())) ?>

()

  • 'loginSec_requireAdminTwoFactor', 'enabledValue' => 1, 'disabledValue' => 0, 'value' => wfConfig::get('loginSec_requireAdminTwoFactor') ? 1 : 0, 'htmlTitle' => wp_kses(sprintf(/* translators: Support URL. */ __('Require Cellphone Sign-in for all Administrators (opens in new tab)
    Note: This setting requires at least one administrator to have Cellphone Sign-in enabled. On multisite, this option applies only to super admins.', 'wordfence'), esc_url($helpLink)), array('a'=>array('href'=>array(), 'target'=>array(), 'rel'=>array(), 'class'=>array()), 'strong'=>array(), 'br'=>array(), 'em'=>array(), 'span'=>array('class'=>array()))), ))->render(); ?>
  • 0; echo wfView::create('options/option-toggled', array( 'optionName' => 'loginSec_enableSeparateTwoFactor', 'enabledValue' => 1, 'disabledValue' => 0, 'value' => wfConfig::get('loginSec_enableSeparateTwoFactor') ? 1 : 0, 'htmlTitle' => wp_kses(sprintf(/* translators: Support URL. */ __('Enable Separate Prompt for Two-Factor Code (opens in new tab)
    Note: This setting changes the behavior for obtaining the two-factor authentication code from using the password field to showing a separate prompt. If your theme overrides the default login page, you may not be able to use this option.', 'wordfence'), $helpLink), array('a'=>array('href'=>array(), 'target'=>array(), 'rel'=>array(), 'class'=>array()), 'strong'=>array(), 'br'=>array(), 'em'=>array(), 'span'=>array('class'=>array()))) . ($allowSeparatePrompt ? '' : wp_kses(__('
    This setting will be ignored because the PHP configuration option output_buffering is off.', 'wordfence'), array('strong'=>array(), 'br'=>array()))), ))->render(); ?>
__init__.py000064400000000000147221704450006651 0ustar00__init__.pyc000064400000000220147221704450007020 0ustar00 ApMc@sdS(N((((s9/usr/lib/python2.7/site-packages/serial/tools/__init__.pytsminiterm.pyc000064400000043777147221704450007135 0ustar00 {QNc@sddlZddlZddlZddlZdadadZdZejddfkrodZ n d Z ej d krddl Z d e fd YZ e anej d kr&ddlZddlZddlZd e fdYZ e adZtjee_nedejdZdZdZdddfZdddfZddddfZde fdYZdZed krendS(!iNsscCs8t|}|dkr*dtd|St|SdS(s)generate a readable description for a keyi sCtrl+%ct@N(tordtrepr(t charactert ascii_code((s9/usr/lib/python2.7/site-packages/serial/tools/miniterm.pytkey_descriptions  cCsdi ttddd6ttd6ttd6tdd6td d 6td d 6td d6tdd6tdd6tdd6tdd6ttd6ttd6S(Nsw --- pySerial (%(version)s) - miniterm - help --- --- %(exit)-8s Exit program --- %(menu)-8s Menu escape key, followed by: --- Menu keys: --- %(itself)-7s Send the menu character itself to remote --- %(exchar)-7s Send the exit character itself to remote --- %(info)-7s Show info --- %(upload)-7s Upload file (prompt will be shown) --- Toggles: --- %(rts)-7s RTS %(echo)-7s local echo --- %(dtr)-7s DTR %(break)-7s BREAK --- %(lfm)-7s line feed %(repr)-7s Cycle repr mode --- --- Port settings (%(menu)s followed by the following): --- p change port --- 7 8 set data bits --- n e o s m change parity (None, Even, Odd, Space, Mark) --- 1 2 3 set stop bits (1, 2, 1.5) --- b change baud rate --- x X disable/enable software flow control --- r R disable/enable hardware flow control tVERSIONsunknown versiontversiontexittmenustrtssRstdtrs tlfmstbreakstechos tinfostuploadtitselftexchar(tgetattrtserialRt EXITCHARCTERt MENUCHARACTER(((s9/usr/lib/python2.7/site-packages/serial/tools/miniterm.pyt get_help_texts           iicCs |jdS(Ntlatin1(tdecode(tb((s9/usr/lib/python2.7/site-packages/serial/tools/miniterm.pyREscCs|S(N((R((s9/usr/lib/python2.7/site-packages/serial/tools/miniterm.pyRHstnttConsolecBs,eZdZdZdZdZRS(cCsdS(N((tself((s9/usr/lib/python2.7/site-packages/serial/tools/miniterm.pyt__init__QscCsdS(N((R((s9/usr/lib/python2.7/site-packages/serial/tools/miniterm.pytsetupTscCsdS(N((R((s9/usr/lib/python2.7/site-packages/serial/tools/miniterm.pytcleanupWscCsVxOtrQtj}|dks-|dkr:tjq|dkrJdS|SqWdS(Ntss s (tTruetmsvcrttgetch(Rtz((s9/usr/lib/python2.7/site-packages/serial/tools/miniterm.pytgetkeyZs    (t__name__t __module__RRR R&(((s9/usr/lib/python2.7/site-packages/serial/tools/miniterm.pyRPs   tposixcBs,eZdZdZdZdZRS(cCstjj|_dS(N(tsyststdintfilenotfd(R((s9/usr/lib/python2.7/site-packages/serial/tools/miniterm.pyRiscCstj|j|_tj|j}|dtj@tj@tj@|dtk rqtj||d|d|d|dd|_nX||_||_||_t|j|_t |_ t |_ t |_ dS(Ntparitytrtsctstxonxoffttimeouti(Rtserial_for_urltAttributeErrortSerialRt repr_modetconvert_outgoingtNEWLINE_CONVERISON_MAPtnewlineR"t dtr_statet rts_statetFalset break_state( RtporttbaudrateRDRERFRRLRK((s9/usr/lib/python2.7/site-packages/serial/tools/miniterm.pyRs1 1     cCsBt|_tjd|j|_|jjt|jjdS(sStart reader threadttargetN(R"t _reader_alivet threadingtThreadtreadertreceiver_threadt setDaemontstart(R((s9/usr/lib/python2.7/site-packages/serial/tools/miniterm.pyt _start_readers cCst|_|jjdS(s6Stop reader thread only, wait for clean exit of threadN(RQRVRZtjoin(R((s9/usr/lib/python2.7/site-packages/serial/tools/miniterm.pyt _stop_readers cCsLt|_|jtjd|j|_|jjt|jjdS(NRU( R"taliveR]RWRXtwriterttransmitter_threadR[R\(R((s9/usr/lib/python2.7/site-packages/serial/tools/miniterm.pyR\s   cCs t|_dS(N(RQR`(R((s9/usr/lib/python2.7/site-packages/serial/tools/miniterm.pytstopscCs'|jj|s#|jjndS(N(RbR^RZ(Rt transmit_only((s9/usr/lib/python2.7/site-packages/serial/tools/miniterm.pyR^s cCstjjd|jj|jj|jj|jj|jjftjjd|j r\dp_d|j rndpqd|j rdpdfyxtjjd|jj rdpd|jj rdpd|jjrdpd|jjrdpdfWntjk rnXtjjd|jjr8dp;dtjjd|jjr^dpadtjjdt|jt|jfdS( Ns --- Settings: %s %s,%s,%s,%s s&--- RTS: %-8s DTR: %-8s BREAK: %-8s tactivetinactives---- CTS: %-8s DSR: %-8s RI: %-8s CD: %-8s s--- software flow control: %s s--- hardware flow control: %s s$--- data escaping: %s linefeed: %s (R*tstderrtwriteRtportstrRTtbytesizeRDtstopbitsRPRORRtgetCTStgetDSRtgetRItgetCDtSerialExceptionRFREt REPR_MODESRKtLF_MODESRL(R((s9/usr/lib/python2.7/site-packages/serial/tools/miniterm.pytdump_port_settingss.       $&&  cCsyx|jr|jrt|jjd}|jdkr|dkrm|jtkrmtj j dqtj j |nF|jdkrW|jt kr|dkr|dkrtj j dqT|dkrTqTq|dkr |jt kr tj j dq|dkr7|jtkr7tj j dqtj j t |dd!no|jdkrtj j t |dd!n@|jdkrx.|D]#}tj j d |jd qWntj jqWWn"tjk r}t|_nXd S( sloop and copy serial->consoleiis s s iiis%s RBN(R`RVRRR:RKRLt CONVERT_CRR*tstdoutRht CONVERT_CRLFt CONVERT_LFRtencodetflushRpRQ(RtdataR;te((s9/usr/lib/python2.7/site-packages/serial/tools/miniterm.pyRYs6     $ c Cs> t}y x |jr" ytj}Wn#tk rJtjdg}nXt|}|rl|tksu|t kr|jj ||j rct j j |qcn|dkrt jj dt jjtjt jjjd}|ryt|d}t jj d|xftr|jjd}|sCPn|jj ||jj d|jjt jj dqWt jj d|Wqtk r}t jj d ||fqXntjn|d krt jj tnh|d krM|j |_|jj|jt jj d |jrBd pEdn|dkr|j |_|jj|jt jj d|jrd pdn|dkr|j |_|jj|jt jj d|jrd pdnr|dkr0|j |_ t jj d|j r%d p(dn3|dkrI|jn|dkr|j d7_ |j dkrd|_ nt jj dt!|j fn|dkr|j"d7_"|j"dkrd|_"nt#|j"|_$t jj dt%|j"fn\|dkrt jj dt jjtjyt jjj&}Wntk rld5}nXtj|rc||jj(krc|j)|jj*} yytj+|dt} Wn&t,k rtj-} || _(nX| j.| | j| j|j| j|j| j|jWn4t/k rk}t jj d |f| j0n4X|jj0| |_t jj d!|jj(f|j1qcn|d"krct jj d#t jjtj|jj2} y%t3t jjj&|j_2Wn6t4k rK}t jj d$|f| |j_2n X|jtjn|d%krtj5|j_6|jn|d&krtj7|j_6|jn|d'krtj8|j_9|jn|d(krtj:|j_9|jn`|d)kr+tj;|j_9|jn8|d*krStj<|j_9|jn|d+kr{tj=|j_9|jn|d,krtj>|j_?|jn|d-krtj@|j_?|jn|d.krtjA|j_?|jnp|d/kr|d0k|j_B|jnE|d1krI|d2k|j_C|jnt jj d3tD|t}q |tkrt}q |t kr|jEPq |d4kr|jj |j$|j r t j j |t j jq q |jj ||j r t j j |t j jq q WWnt|_nXd5S(6s Loop and copy console->serial until EXITCHARCTER character is found. When MENUCHARACTER is found, interpret the next key locally. iss --- File to upload: s trs--- Sending file %s --- t.s --- File %s sent --- s"--- ERROR opening file %s: %s --- shH?ss--- RTS %s --- ReRfss--- DTR %s --- ss--- BREAK %s --- ss--- local echo %s --- s siis--- escape data: %s --- s is--- line feed %s --- tpPs --- Enter port name: t do_not_opens#--- ERROR opening new port: %s --- s--- Port changed to: %s --- tbBs --- Baudrate: s#--- ERROR setting baudrate: %s --- t8t7teEtoOtmMtsStnNt1t2t3txXtXtrRtRs!--- unknown menu character %s -- s N(FRQR`R=R&tKeyboardInterruptRtto_bytesRRRRhRR*RuRgRyR R+treadlinetrstriptopenR"tIOErrorRRRPtsetRTSROtsetDTRRRtsetBreakRsRKRqRLRMRNRrtstriptNoneRSR_tgetSettingsDictRHRIRJtapplySettingsDictt ExceptiontcloseR]RTtintt ValueErrort EIGHTBITSRjt SEVENBITSt PARITY_EVENRDt PARITY_ODDt PARITY_MARKt PARITY_SPACEt PARITY_NONEt STOPBITS_ONERkt STOPBITS_TWOtSTOPBITS_ONE_POINT_FIVERFRERRc( Rt menu_activeRR;tfilenametfiletlineR{RStsettingst new_serialtbackup((s9/usr/lib/python2.7/site-packages/serial/tools/miniterm.pyRasF         !    &  &  &  &                          %                                   ( R'R(RQRvRR]R_R\RcR^RsRYRa(((s9/usr/lib/python2.7/site-packages/serial/tools/miniterm.pyRCs       (c Csddl}|jdddd}|jdddd d d d d|jd dddddddd dd d|jdddddd dd d|jddddddd dd t|jddd ddd d!d t|jd"dd#ddd d$d t|jd%dd&ddd d'd t|jd(dd)ddd d*d t|jd+d,dd-dd.d d/d d0|jd1dd2ddddd d3d d|jd4dd5ddddd d6d d|jd7d8dd9ddd d:d t|jd;dd<ddddd d=d d>|jd?dd@ddddd dAd dB|j\}}|jj|_|jdCkr|jdDn|j r|j r|jdEn|j |j kr|jdFnt |j at |j a|j}|j}|r|jdk r-|jdGn|jd0}|ryt|d0}Wn&tk r~|jdH|d0nX|jd0n|r|jdIqn|dkrd0}nt}|j rt}n|j rt}nyCt|||jd |jd#|jd|jdJ|d-|j}Wn=tjk ri}tj j!dK||ftj"dLnX|j#stj j!dM|jj$|jj|jj%|jj|jj&ftj j!dNt'tt'tt'tt'dOfn|j(dk rO|j#s-tj j!dP|j(r"dQp%dRn|jj)|j(|j(|_(n|j*dk r|j#stj j!dS|j*rdQpdRn|jj+|j*|j*|_*n|j,y|j-t.Wnt/k rnX|j#stj j!dTn|j-dS(UNitusages!%prog [options] [port [baudrate]]t descriptions9Miniterm - A simple terminal program for the serial port.s-ps--porttdestRSthelpsKport, a number or a device name. (deprecated option, use parameter instead)tdefaults-bs--baudRTtactiontstorettypeRsset baud rate, default %defaulti%s--parityRDs-set parity, one of [N, E, O, S, M], default=NtNs-es--echoRt store_truesenable local echo (default off)s--rtsctsREs)enable RTS/CTS flow control (default off)s --xonxoffRFs*enable software flow control (default off)s--crtcrsdo not send CR+LF, send CR onlys--lftlfsdo not send CR+LF, send LF onlys-Ds--debugRKtcountsdebug received data (escape non-printable chars) --debug can be given multiple times: 0: just print what is received 1: escape non-printable characters, do newlines as unusual 2: escape non-printable characters, newlines too 3: hex dump everythingis--rtsRPs2set initial RTS line state (possible values: 0, 1)s--dtrROs2set initial DTR line state (possible values: 0, 1)s-qs--quiettquietssuppress non error messagess --exit-chart exit_charsDASCII code of special character that is used to exit the applicationis --menu-chart menu_charsGASCII code of special character that is used to control miniterm (menu)itNEOSMsinvalid paritys)only one of --cr or --lf can be specifieds.--exit-char can not be the same as --menu-chars;no arguments are allowed, options only when --port is givens"baud rate must be a number, not %rstoo many argumentsRLscould not open port %r: %s is$--- Miniterm on %s: %d,%s,%s,%s --- s8--- Quit: %s | Menu: %s | Help: %s followed by %s --- ss--- forcing DTR %s ReRfs--- forcing RTS %s s --- exit --- (0toptparset OptionParsert add_optionRRQt parse_argsRDtupperterrorRRRRtchrRRRSRTtpopRRRvRtRwRCRERFRRKRRpR*RgRhRRRiRjRkRRORRPRR\R^R"R( RtparsertoptionstargsRSRTRLtminitermR{((s9/usr/lib/python2.7/site-packages/serial/tools/miniterm.pytmains0                                   & &   t__main__(R*R9RRWRRRRt version_infoRtnameR#tobjectRR=R.R>RtexitfunctNotImplementedErrortplatformRvRtRwRMRrRqRCRR'(((s9/usr/lib/python2.7/site-packages/serial/tools/miniterm.pyt s<0 (    $    ) list_ports.pyo000064400000005431147221704450007510 0ustar00 VNc@sdZddlZddlZddlZddlZejdkrRddlTn2ejdkrnddlTnedejfdZdZ e d kre ndS( sAThis module will provide a function called comports that returns an iterable (generator or list) that will enumerate available com ports. Note that on some systems non-existent ports may be listed. Additionally a grep function is supplied that can be used to search for ports based on their descriptions or hardware ID. iNtnt(t*tposixs;Sorry: no implementation for your platform ('%s') availableccsnxgtD]\\}}}tj||tjsUtj||sUtj||r |||fVq q WdS(s Search for ports using a regular expression. Port name, description and hardware ID are searched. The function returns an iterable that returns the same tuples as comport() would do. N(tcomportstretsearchtI(tregexptporttdescthwid((s;/usr/lib/python2.7/site-packages/serial/tools/list_ports.pytgrep#s<c Csddl}|jdddd}|jdddd d d td d |jddddd dd dd d|jddddd dd ddd|j\}}d}|rt|dkr|jdnd|dfGHtt|d}ntt }xW|D]O\}}}d|fGH|j dkr]d|fGHd|fGHn|d7}qW|j r|rd|fGHqd GHndS(!Nitusages%prog [options] []t descriptions9Miniterm - A simple terminal program for the serial port.s--debugthelps6print debug messages and tracebacks (development mode)tdesttdebugtdefaulttactiont store_trues-vs --verboses0show more messages (can be given multiple times)tverboseitcounts-qs--quietssuppress all messagest store_consttconstis"more than one regexp not supportedsFiltered list with regexp: %rs%-20ss desc: %ss hwid: %ss%d ports foundsno ports found( toptparset OptionParsert add_optiontFalset parse_argstlenterrortsortedR RR( RtparsertoptionstargsthitstiteratorRR R ((s;/usr/lib/python2.7/site-packages/serial/tools/list_ports.pytmain.sJ       t__main__( t__doc__tsystosRtnametserial.tools.list_ports_windowstserial.tools.list_ports_posixt ImportErrorR R%t__name__(((s;/usr/lib/python2.7/site-packages/serial/tools/list_ports.pyts$    4 miniterm.pyo000064400000043777147221704450007151 0ustar00 {QNc@sddlZddlZddlZddlZdadadZdZejddfkrodZ n d Z ej d krddl Z d e fd YZ e anej d kr&ddlZddlZddlZd e fdYZ e adZtjee_nedejdZdZdZdddfZdddfZddddfZde fdYZdZed krendS(!iNsscCs8t|}|dkr*dtd|St|SdS(s)generate a readable description for a keyi sCtrl+%ct@N(tordtrepr(t charactert ascii_code((s9/usr/lib/python2.7/site-packages/serial/tools/miniterm.pytkey_descriptions  cCsdi ttddd6ttd6ttd6tdd6td d 6td d 6td d6tdd6tdd6tdd6tdd6ttd6ttd6S(Nsw --- pySerial (%(version)s) - miniterm - help --- --- %(exit)-8s Exit program --- %(menu)-8s Menu escape key, followed by: --- Menu keys: --- %(itself)-7s Send the menu character itself to remote --- %(exchar)-7s Send the exit character itself to remote --- %(info)-7s Show info --- %(upload)-7s Upload file (prompt will be shown) --- Toggles: --- %(rts)-7s RTS %(echo)-7s local echo --- %(dtr)-7s DTR %(break)-7s BREAK --- %(lfm)-7s line feed %(repr)-7s Cycle repr mode --- --- Port settings (%(menu)s followed by the following): --- p change port --- 7 8 set data bits --- n e o s m change parity (None, Even, Odd, Space, Mark) --- 1 2 3 set stop bits (1, 2, 1.5) --- b change baud rate --- x X disable/enable software flow control --- r R disable/enable hardware flow control tVERSIONsunknown versiontversiontexittmenustrtssRstdtrs tlfmstbreakstechos tinfostuploadtitselftexchar(tgetattrtserialRt EXITCHARCTERt MENUCHARACTER(((s9/usr/lib/python2.7/site-packages/serial/tools/miniterm.pyt get_help_texts           iicCs |jdS(Ntlatin1(tdecode(tb((s9/usr/lib/python2.7/site-packages/serial/tools/miniterm.pyREscCs|S(N((R((s9/usr/lib/python2.7/site-packages/serial/tools/miniterm.pyRHstnttConsolecBs,eZdZdZdZdZRS(cCsdS(N((tself((s9/usr/lib/python2.7/site-packages/serial/tools/miniterm.pyt__init__QscCsdS(N((R((s9/usr/lib/python2.7/site-packages/serial/tools/miniterm.pytsetupTscCsdS(N((R((s9/usr/lib/python2.7/site-packages/serial/tools/miniterm.pytcleanupWscCsVxOtrQtj}|dks-|dkr:tjq|dkrJdS|SqWdS(Ntss s (tTruetmsvcrttgetch(Rtz((s9/usr/lib/python2.7/site-packages/serial/tools/miniterm.pytgetkeyZs    (t__name__t __module__RRR R&(((s9/usr/lib/python2.7/site-packages/serial/tools/miniterm.pyRPs   tposixcBs,eZdZdZdZdZRS(cCstjj|_dS(N(tsyststdintfilenotfd(R((s9/usr/lib/python2.7/site-packages/serial/tools/miniterm.pyRiscCstj|j|_tj|j}|dtj@tj@tj@|dtk rqtj||d|d|d|dd|_nX||_||_||_t|j|_t |_ t |_ t |_ dS(Ntparitytrtsctstxonxoffttimeouti(Rtserial_for_urltAttributeErrortSerialRt repr_modetconvert_outgoingtNEWLINE_CONVERISON_MAPtnewlineR"t dtr_statet rts_statetFalset break_state( RtporttbaudrateRDRERFRRLRK((s9/usr/lib/python2.7/site-packages/serial/tools/miniterm.pyRs1 1     cCsBt|_tjd|j|_|jjt|jjdS(sStart reader threadttargetN(R"t _reader_alivet threadingtThreadtreadertreceiver_threadt setDaemontstart(R((s9/usr/lib/python2.7/site-packages/serial/tools/miniterm.pyt _start_readers cCst|_|jjdS(s6Stop reader thread only, wait for clean exit of threadN(RQRVRZtjoin(R((s9/usr/lib/python2.7/site-packages/serial/tools/miniterm.pyt _stop_readers cCsLt|_|jtjd|j|_|jjt|jjdS(NRU( R"taliveR]RWRXtwriterttransmitter_threadR[R\(R((s9/usr/lib/python2.7/site-packages/serial/tools/miniterm.pyR\s   cCs t|_dS(N(RQR`(R((s9/usr/lib/python2.7/site-packages/serial/tools/miniterm.pytstopscCs'|jj|s#|jjndS(N(RbR^RZ(Rt transmit_only((s9/usr/lib/python2.7/site-packages/serial/tools/miniterm.pyR^s cCstjjd|jj|jj|jj|jj|jjftjjd|j r\dp_d|j rndpqd|j rdpdfyxtjjd|jj rdpd|jj rdpd|jjrdpd|jjrdpdfWntjk rnXtjjd|jjr8dp;dtjjd|jjr^dpadtjjdt|jt|jfdS( Ns --- Settings: %s %s,%s,%s,%s s&--- RTS: %-8s DTR: %-8s BREAK: %-8s tactivetinactives---- CTS: %-8s DSR: %-8s RI: %-8s CD: %-8s s--- software flow control: %s s--- hardware flow control: %s s$--- data escaping: %s linefeed: %s (R*tstderrtwriteRtportstrRTtbytesizeRDtstopbitsRPRORRtgetCTStgetDSRtgetRItgetCDtSerialExceptionRFREt REPR_MODESRKtLF_MODESRL(R((s9/usr/lib/python2.7/site-packages/serial/tools/miniterm.pytdump_port_settingss.       $&&  cCsyx|jr|jrt|jjd}|jdkr|dkrm|jtkrmtj j dqtj j |nF|jdkrW|jt kr|dkr|dkrtj j dqT|dkrTqTq|dkr |jt kr tj j dq|dkr7|jtkr7tj j dqtj j t |dd!no|jdkrtj j t |dd!n@|jdkrx.|D]#}tj j d |jd qWntj jqWWn"tjk r}t|_nXd S( sloop and copy serial->consoleiis s s iiis%s RBN(R`RVRRR:RKRLt CONVERT_CRR*tstdoutRht CONVERT_CRLFt CONVERT_LFRtencodetflushRpRQ(RtdataR;te((s9/usr/lib/python2.7/site-packages/serial/tools/miniterm.pyRYs6     $ c Cs> t}y x |jr" ytj}Wn#tk rJtjdg}nXt|}|rl|tksu|t kr|jj ||j rct j j |qcn|dkrt jj dt jjtjt jjjd}|ryt|d}t jj d|xftr|jjd}|sCPn|jj ||jj d|jjt jj dqWt jj d|Wqtk r}t jj d ||fqXntjn|d krt jj tnh|d krM|j |_|jj|jt jj d |jrBd pEdn|dkr|j |_|jj|jt jj d|jrd pdn|dkr|j |_|jj|jt jj d|jrd pdnr|dkr0|j |_ t jj d|j r%d p(dn3|dkrI|jn|dkr|j d7_ |j dkrd|_ nt jj dt!|j fn|dkr|j"d7_"|j"dkrd|_"nt#|j"|_$t jj dt%|j"fn\|dkrt jj dt jjtjyt jjj&}Wntk rld5}nXtj|rc||jj(krc|j)|jj*} yytj+|dt} Wn&t,k rtj-} || _(nX| j.| | j| j|j| j|j| j|jWn4t/k rk}t jj d |f| j0n4X|jj0| |_t jj d!|jj(f|j1qcn|d"krct jj d#t jjtj|jj2} y%t3t jjj&|j_2Wn6t4k rK}t jj d$|f| |j_2n X|jtjn|d%krtj5|j_6|jn|d&krtj7|j_6|jn|d'krtj8|j_9|jn|d(krtj:|j_9|jn`|d)kr+tj;|j_9|jn8|d*krStj<|j_9|jn|d+kr{tj=|j_9|jn|d,krtj>|j_?|jn|d-krtj@|j_?|jn|d.krtjA|j_?|jnp|d/kr|d0k|j_B|jnE|d1krI|d2k|j_C|jnt jj d3tD|t}q |tkrt}q |t kr|jEPq |d4kr|jj |j$|j r t j j |t j jq q |jj ||j r t j j |t j jq q WWnt|_nXd5S(6s Loop and copy console->serial until EXITCHARCTER character is found. When MENUCHARACTER is found, interpret the next key locally. iss --- File to upload: s trs--- Sending file %s --- t.s --- File %s sent --- s"--- ERROR opening file %s: %s --- shH?ss--- RTS %s --- ReRfss--- DTR %s --- ss--- BREAK %s --- ss--- local echo %s --- s siis--- escape data: %s --- s is--- line feed %s --- tpPs --- Enter port name: t do_not_opens#--- ERROR opening new port: %s --- s--- Port changed to: %s --- tbBs --- Baudrate: s#--- ERROR setting baudrate: %s --- t8t7teEtoOtmMtsStnNt1t2t3txXtXtrRtRs!--- unknown menu character %s -- s N(FRQR`R=R&tKeyboardInterruptRtto_bytesRRRRhRR*RuRgRyR R+treadlinetrstriptopenR"tIOErrorRRRPtsetRTSROtsetDTRRRtsetBreakRsRKRqRLRMRNRrtstriptNoneRSR_tgetSettingsDictRHRIRJtapplySettingsDictt ExceptiontcloseR]RTtintt ValueErrort EIGHTBITSRjt SEVENBITSt PARITY_EVENRDt PARITY_ODDt PARITY_MARKt PARITY_SPACEt PARITY_NONEt STOPBITS_ONERkt STOPBITS_TWOtSTOPBITS_ONE_POINT_FIVERFRERRc( Rt menu_activeRR;tfilenametfiletlineR{RStsettingst new_serialtbackup((s9/usr/lib/python2.7/site-packages/serial/tools/miniterm.pyRasF         !    &  &  &  &                          %                                   ( R'R(RQRvRR]R_R\RcR^RsRYRa(((s9/usr/lib/python2.7/site-packages/serial/tools/miniterm.pyRCs       (c Csddl}|jdddd}|jdddd d d d d|jd dddddddd dd d|jdddddd dd d|jddddddd dd t|jddd ddd d!d t|jd"dd#ddd d$d t|jd%dd&ddd d'd t|jd(dd)ddd d*d t|jd+d,dd-dd.d d/d d0|jd1dd2ddddd d3d d|jd4dd5ddddd d6d d|jd7d8dd9ddd d:d t|jd;dd<ddddd d=d d>|jd?dd@ddddd dAd dB|j\}}|jj|_|jdCkr|jdDn|j r|j r|jdEn|j |j kr|jdFnt |j at |j a|j}|j}|r|jdk r-|jdGn|jd0}|ryt|d0}Wn&tk r~|jdH|d0nX|jd0n|r|jdIqn|dkrd0}nt}|j rt}n|j rt}nyCt|||jd |jd#|jd|jdJ|d-|j}Wn=tjk ri}tj j!dK||ftj"dLnX|j#stj j!dM|jj$|jj|jj%|jj|jj&ftj j!dNt'tt'tt'tt'dOfn|j(dk rO|j#s-tj j!dP|j(r"dQp%dRn|jj)|j(|j(|_(n|j*dk r|j#stj j!dS|j*rdQpdRn|jj+|j*|j*|_*n|j,y|j-t.Wnt/k rnX|j#stj j!dTn|j-dS(UNitusages!%prog [options] [port [baudrate]]t descriptions9Miniterm - A simple terminal program for the serial port.s-ps--porttdestRSthelpsKport, a number or a device name. (deprecated option, use parameter instead)tdefaults-bs--baudRTtactiontstorettypeRsset baud rate, default %defaulti%s--parityRDs-set parity, one of [N, E, O, S, M], default=NtNs-es--echoRt store_truesenable local echo (default off)s--rtsctsREs)enable RTS/CTS flow control (default off)s --xonxoffRFs*enable software flow control (default off)s--crtcrsdo not send CR+LF, send CR onlys--lftlfsdo not send CR+LF, send LF onlys-Ds--debugRKtcountsdebug received data (escape non-printable chars) --debug can be given multiple times: 0: just print what is received 1: escape non-printable characters, do newlines as unusual 2: escape non-printable characters, newlines too 3: hex dump everythingis--rtsRPs2set initial RTS line state (possible values: 0, 1)s--dtrROs2set initial DTR line state (possible values: 0, 1)s-qs--quiettquietssuppress non error messagess --exit-chart exit_charsDASCII code of special character that is used to exit the applicationis --menu-chart menu_charsGASCII code of special character that is used to control miniterm (menu)itNEOSMsinvalid paritys)only one of --cr or --lf can be specifieds.--exit-char can not be the same as --menu-chars;no arguments are allowed, options only when --port is givens"baud rate must be a number, not %rstoo many argumentsRLscould not open port %r: %s is$--- Miniterm on %s: %d,%s,%s,%s --- s8--- Quit: %s | Menu: %s | Help: %s followed by %s --- ss--- forcing DTR %s ReRfs--- forcing RTS %s s --- exit --- (0toptparset OptionParsert add_optionRRQt parse_argsRDtupperterrorRRRRtchrRRRSRTtpopRRRvRtRwRCRERFRRKRRpR*RgRhRRRiRjRkRRORRPRR\R^R"R( RtparsertoptionstargsRSRTRLtminitermR{((s9/usr/lib/python2.7/site-packages/serial/tools/miniterm.pytmains0                                   & &   t__main__(R*R9RRWRRRRt version_infoRtnameR#tobjectRR=R.R>RtexitfunctNotImplementedErrortplatformRvRtRwRMRrRqRCRR'(((s9/usr/lib/python2.7/site-packages/serial/tools/miniterm.pyt s<0 (    $    ) list_ports_posix.pyo000064400000017666147221704450010747 0ustar00 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                          list_ports_posix.pyc000064400000017666147221704450010733 0ustar00 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                          list_ports_windows.pyo000064400000016305147221704450011264 0ustar00 Nc @s@ddlZddlZdZddlZddlmZmZddlmZddlm Z ddlm Z ddlm Z ddlm Z dd lm Z dd lmZdd lmZdd lmZdd lmZdZejZejZejZeje ZZejZZejeZe ZeZ dZ!dZ"dej#fdYZ$dej#fdYZ%eje%Z&dej#fdYZ'eje'Z(ejZ)ej*j+dZ,e,j-Z-ege-_.e e-_/e,j0Z1eje$ee e ge1_.ee1_/ee1_2e,j3Z3ee&eje$e e(ge3_.e e3_/e,j4Z5ee(e)e ee&ge5_.e e5_/e,j6Z7ee&e eee ege7_.e e7_/e,j8Z8ee&e e e e ge8_.ee8_/ej*j+dZ9e9j:Z:ege:_.e e:_/e9j;Z<eeeeeege<_.e e<_/e$dddeddddddd d!d"Z=d#Z>d$Z?dZ@d%ZAd&ZBd'ZCd(ZDd&ZEd&ZFd)ZGd&ZHejId*d+d,d-d.d/d0d1gZJd2ZKeLd3kr<ddlZx5eMeKD]!\ZNZOZPd4eNeOePfGHqWndS(5iNcCs|dkrtjn|S(Ni(tctypestWinError(tvaluetfunct arguments((sC/usr/lib/python2.7/site-packages/serial/tools/list_ports_windows.pyt ValidHandles (t ULONG_PTRtis_64bit(tHANDLE(tBOOL(tHWND(tDWORD(tWORD(tLONG(tULONG(tLPCSTR(tHKEY(tBYTEicCs t|S(sGet a buffer for a string(R(tlength((sC/usr/lib/python2.7/site-packages/serial/tools/list_ports_windows.pyt byte_buffer#scCsKg}x5|D]-}|dkr#Pn|jt|d@q Wdj|S(Niit(tappendtchrtjoin(tbuffertstc((sC/usr/lib/python2.7/site-packages/serial/tools/list_ports_windows.pytstring's   tGUIDcBs?eZdefdefdefdedfgZdZRS(tData1tData2tData3tData4ic Csnd|j|j|jdjg|jd D]}d|^q)djg|jdD]}d|^qSfS(Ns{%08x-%04x-%04x-%s-%s}Ris%02x(RRRRR (tselftd((sC/usr/lib/python2.7/site-packages/serial/tools/list_ports_windows.pyt__str__6s *(t__name__t __module__R R Rt_fields_R#(((sC/usr/lib/python2.7/site-packages/serial/tools/list_ports_windows.pyR/s    tSP_DEVINFO_DATAcBs;eZdefdefdefdefgZdZRS(tcbSizet ClassGuidtDevInsttReservedcCsd|j|jfS(NsClassGuid:%s DevInst:%s(R)R*(R!((sC/usr/lib/python2.7/site-packages/serial/tools/list_ports_windows.pyR#Fs(R$R%R RRR&R#(((sC/usr/lib/python2.7/site-packages/serial/tools/list_ports_windows.pyR'?s    tSP_DEVICE_INTERFACE_DATAcBs;eZdefdefdefdefgZdZRS(R(tInterfaceClassGuidtFlagsR+cCsd|j|jfS(NsInterfaceClassGuid:%s Flags:%s(R-R.(R!((sC/usr/lib/python2.7/site-packages/serial/tools/list_ports_windows.pyR#Qs(R$R%R RRR&R#(((sC/usr/lib/python2.7/site-packages/serial/tools/list_ports_windows.pyR,Js    tsetupapitAdvapi32lQ iiiiii>i0iisiiizii iiiPioiritiNiaimiec #sttjtd tttB}xtdD]}t }tj ||_ t |d tjt|tj|stj tkrtjnPntt|tj|d dtjd stj tkrtjqndtjffdY}|}tr6d|_ n d|_ t}tj ||_ t|tj|tj|d tj|stjntd}t|tj|td tj|tj |dd s t tkr tjq ntd}t|tj|td tj|tj |dd sptj tkr d }q q/t|tj|tdtt} td} ttj | } t| t d d tj| tj| t!| t"| t"|t"|fVq/Wt#|d S( sRThis generator scans the device registry for com ports and yields port, desc, hwidiit!SP_DEVICE_INTERFACE_DETAIL_DATA_Acs=eZdefdejejefgZdZRS(R(t DevicePathcSsd|jfS(Ns DevicePath:%s(R2(R!((sC/usr/lib/python2.7/site-packages/serial/tools/list_ports_windows.pyR#s( R$R%R tCHARRRtsizeofR&R#((tdwNeeded(sC/usr/lib/python2.7/site-packages/serial/tools/list_ports_windows.pyR1s #iiiiN($tSetupDiGetClassDevsRtbyreftGUID_CLASS_COMPORTtNonetNULLt DIGCF_PRESENTtDIGCF_DEVICEINTERFACEtrangeR,R4R(tSetupDiEnumDeviceInterfacest GetLastErrortERROR_NO_MORE_ITEMSRR tSetupDiGetDeviceInterfaceDetailtERROR_INSUFFICIENT_BUFFERt StructureRR'Rt SetupDiGetDeviceRegistryPropertytSPDRP_HARDWAREIDtSPDRP_FRIENDLYNAMEtSetupDiOpenDevRegKeytDICS_FLAG_GLOBALt DIREG_DEVtKEY_READRtRegQueryValueExtPortNamet RegCloseKeyRtSetupDiDestroyDeviceInfoList( tg_hditdwIndextdidR1tiddtdevinfot szHardwareIDtszFriendlyNamet port_namethkeytport_name_buffertport_name_length((R5sC/usr/lib/python2.7/site-packages/serial/tools/list_ports_windows.pytcomportssH" * -     6 = = $ + $t__main__s %s: %s [%s](QRtreRtserialt serial.win32RRtctypes.wintypesRR R R R R RRRRR:tc_void_ptHDEVINFOtc_char_ptPCTSTRtc_charR3tPOINTERtLPDWORDtPDWORDtLPBYTEtPBYTEtPHKEYt ACCESS_MASKtREGSAMRRRCRR'tPSP_DEVINFO_DATAR,tPSP_DEVICE_INTERFACE_DATAt PSP_DEVICE_INTERFACE_DETAIL_DATAtwindllt LoadLibraryR/RNtargtypestrestypetSetupDiGetClassDevsAR6terrcheckR>t SetupDiGetDeviceInterfaceDetailARAt!SetupDiGetDeviceRegistryPropertyARDRGtadvapi32RMtRegQueryValueExARKR8R;R<tINVALID_HANDLE_VALUERBRERFR@RHRIRJtREG_SZtto_bytesRLRZR$tsortedtporttdescthwid(((sC/usr/lib/python2.7/site-packages/serial/tools/list_ports_windows.pyts                    !             (' @  list_ports.py000064400000005637147221704450007341 0ustar00#!/usr/bin/env python # portable serial port access with python # this is a wrapper module for different platform implementations of the # port enumeration feature # # (C) 2011 Chris Liechti # this is distributed under a free software license, see license.txt """\ This module will provide a function called comports that returns an iterable (generator or list) that will enumerate available com ports. Note that on some systems non-existent ports may be listed. Additionally a grep function is supplied that can be used to search for ports based on their descriptions or hardware ID. """ import sys, os, re # chose an implementation, depending on os #~ if sys.platform == 'cli': #~ else: import os # chose an implementation, depending on os if os.name == 'nt': #sys.platform == 'win32': from serial.tools.list_ports_windows import * elif os.name == 'posix': from serial.tools.list_ports_posix import * #~ elif os.name == 'java': else: raise ImportError("Sorry: no implementation for your platform ('%s') available" % (os.name,)) def grep(regexp): """\ Search for ports using a regular expression. Port name, description and hardware ID are searched. The function returns an iterable that returns the same tuples as comport() would do. """ for port, desc, hwid in comports(): if re.search(regexp, port, re.I) or re.search(regexp, desc) or re.search(regexp, hwid): yield port, desc, hwid def main(): import optparse parser = optparse.OptionParser( usage = "%prog [options] []", description = "Miniterm - A simple terminal program for the serial port." ) parser.add_option("--debug", help="print debug messages and tracebacks (development mode)", dest="debug", default=False, action='store_true') parser.add_option("-v", "--verbose", help="show more messages (can be given multiple times)", dest="verbose", default=1, action='count') parser.add_option("-q", "--quiet", help="suppress all messages", dest="verbose", action='store_const', const=0) (options, args) = parser.parse_args() hits = 0 # get iteraror w/ or w/o filter if args: if len(args) > 1: parser.error('more than one regexp not supported') print "Filtered list with regexp: %r" % (args[0],) iterator = sorted(grep(args[0])) else: iterator = sorted(comports()) # list them for port, desc, hwid in iterator: print "%-20s" % (port,) if options.verbose > 1: print " desc: %s" % (desc,) print " hwid: %s" % (hwid,) hits += 1 if options.verbose: if hits: print "%d ports found" % (hits,) else: print "no ports found" # test if __name__ == '__main__': main() list_ports_windows.py000064400000017350147221704450011106 0ustar00import ctypes import re def ValidHandle(value, func, arguments): if value == 0: raise ctypes.WinError() return value import serial from serial.win32 import ULONG_PTR, is_64bit from ctypes.wintypes import HANDLE from ctypes.wintypes import BOOL from ctypes.wintypes import HWND from ctypes.wintypes import DWORD from ctypes.wintypes import WORD from ctypes.wintypes import LONG from ctypes.wintypes import ULONG from ctypes.wintypes import LPCSTR from ctypes.wintypes import HKEY from ctypes.wintypes import BYTE NULL = 0 HDEVINFO = ctypes.c_void_p PCTSTR = ctypes.c_char_p CHAR = ctypes.c_char LPDWORD = PDWORD = ctypes.POINTER(DWORD) #~ LPBYTE = PBYTE = ctypes.POINTER(BYTE) LPBYTE = PBYTE = ctypes.c_void_p # XXX avoids error about types PHKEY = ctypes.POINTER(HKEY) ACCESS_MASK = DWORD REGSAM = ACCESS_MASK def byte_buffer(length): """Get a buffer for a string""" return (BYTE*length)() def string(buffer): s = [] for c in buffer: if c == 0: break s.append(chr(c & 0xff)) # "& 0xff": hack to convert signed to unsigned return ''.join(s) class GUID(ctypes.Structure): _fields_ = [ ('Data1', DWORD), ('Data2', WORD), ('Data3', WORD), ('Data4', BYTE*8), ] def __str__(self): return "{%08x-%04x-%04x-%s-%s}" % ( self.Data1, self.Data2, self.Data3, ''.join(["%02x" % d for d in self.Data4[:2]]), ''.join(["%02x" % d for d in self.Data4[2:]]), ) class SP_DEVINFO_DATA(ctypes.Structure): _fields_ = [ ('cbSize', DWORD), ('ClassGuid', GUID), ('DevInst', DWORD), ('Reserved', ULONG_PTR), ] def __str__(self): return "ClassGuid:%s DevInst:%s" % (self.ClassGuid, self.DevInst) PSP_DEVINFO_DATA = ctypes.POINTER(SP_DEVINFO_DATA) class SP_DEVICE_INTERFACE_DATA(ctypes.Structure): _fields_ = [ ('cbSize', DWORD), ('InterfaceClassGuid', GUID), ('Flags', DWORD), ('Reserved', ULONG_PTR), ] def __str__(self): return "InterfaceClassGuid:%s Flags:%s" % (self.InterfaceClassGuid, self.Flags) PSP_DEVICE_INTERFACE_DATA = ctypes.POINTER(SP_DEVICE_INTERFACE_DATA) PSP_DEVICE_INTERFACE_DETAIL_DATA = ctypes.c_void_p setupapi = ctypes.windll.LoadLibrary("setupapi") SetupDiDestroyDeviceInfoList = setupapi.SetupDiDestroyDeviceInfoList SetupDiDestroyDeviceInfoList.argtypes = [HDEVINFO] SetupDiDestroyDeviceInfoList.restype = BOOL SetupDiGetClassDevs = setupapi.SetupDiGetClassDevsA SetupDiGetClassDevs.argtypes = [ctypes.POINTER(GUID), PCTSTR, HWND, DWORD] SetupDiGetClassDevs.restype = HDEVINFO SetupDiGetClassDevs.errcheck = ValidHandle SetupDiEnumDeviceInterfaces = setupapi.SetupDiEnumDeviceInterfaces SetupDiEnumDeviceInterfaces.argtypes = [HDEVINFO, PSP_DEVINFO_DATA, ctypes.POINTER(GUID), DWORD, PSP_DEVICE_INTERFACE_DATA] SetupDiEnumDeviceInterfaces.restype = BOOL SetupDiGetDeviceInterfaceDetail = setupapi.SetupDiGetDeviceInterfaceDetailA SetupDiGetDeviceInterfaceDetail.argtypes = [HDEVINFO, PSP_DEVICE_INTERFACE_DATA, PSP_DEVICE_INTERFACE_DETAIL_DATA, DWORD, PDWORD, PSP_DEVINFO_DATA] SetupDiGetDeviceInterfaceDetail.restype = BOOL SetupDiGetDeviceRegistryProperty = setupapi.SetupDiGetDeviceRegistryPropertyA SetupDiGetDeviceRegistryProperty.argtypes = [HDEVINFO, PSP_DEVINFO_DATA, DWORD, PDWORD, PBYTE, DWORD, PDWORD] SetupDiGetDeviceRegistryProperty.restype = BOOL SetupDiOpenDevRegKey = setupapi.SetupDiOpenDevRegKey SetupDiOpenDevRegKey.argtypes = [HDEVINFO, PSP_DEVINFO_DATA, DWORD, DWORD, DWORD, REGSAM] SetupDiOpenDevRegKey.restype = HKEY advapi32 = ctypes.windll.LoadLibrary("Advapi32") RegCloseKey = advapi32.RegCloseKey RegCloseKey.argtypes = [HKEY] RegCloseKey.restype = LONG RegQueryValueEx = advapi32.RegQueryValueExA RegQueryValueEx.argtypes = [HKEY, LPCSTR, LPDWORD, LPDWORD, LPBYTE, LPDWORD] RegQueryValueEx.restype = LONG GUID_CLASS_COMPORT = GUID(0x86e0d1e0L, 0x8089, 0x11d0, (BYTE*8)(0x9c, 0xe4, 0x08, 0x00, 0x3e, 0x30, 0x1f, 0x73)) DIGCF_PRESENT = 2 DIGCF_DEVICEINTERFACE = 16 INVALID_HANDLE_VALUE = 0 ERROR_INSUFFICIENT_BUFFER = 122 SPDRP_HARDWAREID = 1 SPDRP_FRIENDLYNAME = 12 ERROR_NO_MORE_ITEMS = 259 DICS_FLAG_GLOBAL = 1 DIREG_DEV = 0x00000001 KEY_READ = 0x20019 REG_SZ = 1 # workaround for compatibility between Python 2.x and 3.x PortName = serial.to_bytes([80, 111, 114, 116, 78, 97, 109, 101]) # "PortName" def comports(): """This generator scans the device registry for com ports and yields port, desc, hwid""" g_hdi = SetupDiGetClassDevs(ctypes.byref(GUID_CLASS_COMPORT), None, NULL, DIGCF_PRESENT|DIGCF_DEVICEINTERFACE); #~ for i in range(256): for dwIndex in range(256): did = SP_DEVICE_INTERFACE_DATA() did.cbSize = ctypes.sizeof(did) if not SetupDiEnumDeviceInterfaces(g_hdi, None, ctypes.byref(GUID_CLASS_COMPORT), dwIndex, ctypes.byref(did)): if ctypes.GetLastError() != ERROR_NO_MORE_ITEMS: raise ctypes.WinError() break dwNeeded = DWORD() # get the size if not SetupDiGetDeviceInterfaceDetail(g_hdi, ctypes.byref(did), None, 0, ctypes.byref(dwNeeded), None): # Ignore ERROR_INSUFFICIENT_BUFFER if ctypes.GetLastError() != ERROR_INSUFFICIENT_BUFFER: raise ctypes.WinError() # allocate buffer class SP_DEVICE_INTERFACE_DETAIL_DATA_A(ctypes.Structure): _fields_ = [ ('cbSize', DWORD), ('DevicePath', CHAR*(dwNeeded.value - ctypes.sizeof(DWORD))), ] def __str__(self): return "DevicePath:%s" % (self.DevicePath,) idd = SP_DEVICE_INTERFACE_DETAIL_DATA_A() if is_64bit(): idd.cbSize = 8 else: idd.cbSize = 5 devinfo = SP_DEVINFO_DATA() devinfo.cbSize = ctypes.sizeof(devinfo) if not SetupDiGetDeviceInterfaceDetail(g_hdi, ctypes.byref(did), ctypes.byref(idd), dwNeeded, None, ctypes.byref(devinfo)): raise ctypes.WinError() # hardware ID szHardwareID = byte_buffer(250) if not SetupDiGetDeviceRegistryProperty(g_hdi, ctypes.byref(devinfo), SPDRP_HARDWAREID, None, ctypes.byref(szHardwareID), ctypes.sizeof(szHardwareID) - 1, None): # Ignore ERROR_INSUFFICIENT_BUFFER if GetLastError() != ERROR_INSUFFICIENT_BUFFER: raise ctypes.WinError() # friendly name szFriendlyName = byte_buffer(250) if not SetupDiGetDeviceRegistryProperty(g_hdi, ctypes.byref(devinfo), SPDRP_FRIENDLYNAME, None, ctypes.byref(szFriendlyName), ctypes.sizeof(szFriendlyName) - 1, None): # Ignore ERROR_INSUFFICIENT_BUFFER if ctypes.GetLastError() != ERROR_INSUFFICIENT_BUFFER: #~ raise IOError("failed to get details for %s (%s)" % (devinfo, szHardwareID.value)) port_name = None else: # the real com port name has to read differently... hkey = SetupDiOpenDevRegKey(g_hdi, ctypes.byref(devinfo), DICS_FLAG_GLOBAL, 0, DIREG_DEV, KEY_READ) port_name_buffer = byte_buffer(250) port_name_length = ULONG(ctypes.sizeof(port_name_buffer)) RegQueryValueEx(hkey, PortName, None, None, ctypes.byref(port_name_buffer), ctypes.byref(port_name_length)) RegCloseKey(hkey) yield string(port_name_buffer), string(szFriendlyName), string(szHardwareID) SetupDiDestroyDeviceInfoList(g_hdi) # test if __name__ == '__main__': import serial for port, desc, hwid in sorted(comports()): print "%s: %s [%s]" % (port, desc, hwid) list_ports_windows.pyc000064400000016305147221704450011250 0ustar00 Nc @s@ddlZddlZdZddlZddlmZmZddlmZddlm Z ddlm Z ddlm Z ddlm Z dd lm Z dd lmZdd lmZdd lmZdd lmZdZejZejZejZeje ZZejZZejeZe ZeZ dZ!dZ"dej#fdYZ$dej#fdYZ%eje%Z&dej#fdYZ'eje'Z(ejZ)ej*j+dZ,e,j-Z-ege-_.e e-_/e,j0Z1eje$ee e ge1_.ee1_/ee1_2e,j3Z3ee&eje$e e(ge3_.e e3_/e,j4Z5ee(e)e ee&ge5_.e e5_/e,j6Z7ee&e eee ege7_.e e7_/e,j8Z8ee&e e e e ge8_.ee8_/ej*j+dZ9e9j:Z:ege:_.e e:_/e9j;Z<eeeeeege<_.e e<_/e$dddeddddddd d!d"Z=d#Z>d$Z?dZ@d%ZAd&ZBd'ZCd(ZDd&ZEd&ZFd)ZGd&ZHejId*d+d,d-d.d/d0d1gZJd2ZKeLd3kr<ddlZx5eMeKD]!\ZNZOZPd4eNeOePfGHqWndS(5iNcCs|dkrtjn|S(Ni(tctypestWinError(tvaluetfunct arguments((sC/usr/lib/python2.7/site-packages/serial/tools/list_ports_windows.pyt ValidHandles (t ULONG_PTRtis_64bit(tHANDLE(tBOOL(tHWND(tDWORD(tWORD(tLONG(tULONG(tLPCSTR(tHKEY(tBYTEicCs t|S(sGet a buffer for a string(R(tlength((sC/usr/lib/python2.7/site-packages/serial/tools/list_ports_windows.pyt byte_buffer#scCsKg}x5|D]-}|dkr#Pn|jt|d@q Wdj|S(Niit(tappendtchrtjoin(tbuffertstc((sC/usr/lib/python2.7/site-packages/serial/tools/list_ports_windows.pytstring's   tGUIDcBs?eZdefdefdefdedfgZdZRS(tData1tData2tData3tData4ic Csnd|j|j|jdjg|jd D]}d|^q)djg|jdD]}d|^qSfS(Ns{%08x-%04x-%04x-%s-%s}Ris%02x(RRRRR (tselftd((sC/usr/lib/python2.7/site-packages/serial/tools/list_ports_windows.pyt__str__6s *(t__name__t __module__R R Rt_fields_R#(((sC/usr/lib/python2.7/site-packages/serial/tools/list_ports_windows.pyR/s    tSP_DEVINFO_DATAcBs;eZdefdefdefdefgZdZRS(tcbSizet ClassGuidtDevInsttReservedcCsd|j|jfS(NsClassGuid:%s DevInst:%s(R)R*(R!((sC/usr/lib/python2.7/site-packages/serial/tools/list_ports_windows.pyR#Fs(R$R%R RRR&R#(((sC/usr/lib/python2.7/site-packages/serial/tools/list_ports_windows.pyR'?s    tSP_DEVICE_INTERFACE_DATAcBs;eZdefdefdefdefgZdZRS(R(tInterfaceClassGuidtFlagsR+cCsd|j|jfS(NsInterfaceClassGuid:%s Flags:%s(R-R.(R!((sC/usr/lib/python2.7/site-packages/serial/tools/list_ports_windows.pyR#Qs(R$R%R RRR&R#(((sC/usr/lib/python2.7/site-packages/serial/tools/list_ports_windows.pyR,Js    tsetupapitAdvapi32lQ iiiiii>i0iisiiizii iiiPioiritiNiaimiec #sttjtd tttB}xtdD]}t }tj ||_ t |d tjt|tj|stj tkrtjnPntt|tj|d dtjd stj tkrtjqndtjffdY}|}tr6d|_ n d|_ t}tj ||_ t|tj|tj|d tj|stjntd}t|tj|td tj|tj |dd s t tkr tjq ntd}t|tj|td tj|tj |dd sptj tkr d }q q/t|tj|tdtt} td} ttj | } t| t d d tj| tj| t!| t"| t"|t"|fVq/Wt#|d S( sRThis generator scans the device registry for com ports and yields port, desc, hwidiit!SP_DEVICE_INTERFACE_DETAIL_DATA_Acs=eZdefdejejefgZdZRS(R(t DevicePathcSsd|jfS(Ns DevicePath:%s(R2(R!((sC/usr/lib/python2.7/site-packages/serial/tools/list_ports_windows.pyR#s( R$R%R tCHARRRtsizeofR&R#((tdwNeeded(sC/usr/lib/python2.7/site-packages/serial/tools/list_ports_windows.pyR1s #iiiiN($tSetupDiGetClassDevsRtbyreftGUID_CLASS_COMPORTtNonetNULLt DIGCF_PRESENTtDIGCF_DEVICEINTERFACEtrangeR,R4R(tSetupDiEnumDeviceInterfacest GetLastErrortERROR_NO_MORE_ITEMSRR tSetupDiGetDeviceInterfaceDetailtERROR_INSUFFICIENT_BUFFERt StructureRR'Rt SetupDiGetDeviceRegistryPropertytSPDRP_HARDWAREIDtSPDRP_FRIENDLYNAMEtSetupDiOpenDevRegKeytDICS_FLAG_GLOBALt DIREG_DEVtKEY_READRtRegQueryValueExtPortNamet RegCloseKeyRtSetupDiDestroyDeviceInfoList( tg_hditdwIndextdidR1tiddtdevinfot szHardwareIDtszFriendlyNamet port_namethkeytport_name_buffertport_name_length((R5sC/usr/lib/python2.7/site-packages/serial/tools/list_ports_windows.pytcomportssH" * -     6 = = $ + $t__main__s %s: %s [%s](QRtreRtserialt serial.win32RRtctypes.wintypesRR R R R R RRRRR:tc_void_ptHDEVINFOtc_char_ptPCTSTRtc_charR3tPOINTERtLPDWORDtPDWORDtLPBYTEtPBYTEtPHKEYt ACCESS_MASKtREGSAMRRRCRR'tPSP_DEVINFO_DATAR,tPSP_DEVICE_INTERFACE_DATAt PSP_DEVICE_INTERFACE_DETAIL_DATAtwindllt LoadLibraryR/RNtargtypestrestypetSetupDiGetClassDevsAR6terrcheckR>t SetupDiGetDeviceInterfaceDetailARAt!SetupDiGetDeviceRegistryPropertyARDRGtadvapi32RMtRegQueryValueExARKR8R;R<tINVALID_HANDLE_VALUERBRERFR@RHRIRJtREG_SZtto_bytesRLRZR$tsortedtporttdescthwid(((sC/usr/lib/python2.7/site-packages/serial/tools/list_ports_windows.pyts                    !             (' @  list_ports.pyc000064400000005431147221704450007474 0ustar00 VNc@sdZddlZddlZddlZddlZejdkrRddlTn2ejdkrnddlTnedejfdZdZ e d kre ndS( sAThis module will provide a function called comports that returns an iterable (generator or list) that will enumerate available com ports. Note that on some systems non-existent ports may be listed. Additionally a grep function is supplied that can be used to search for ports based on their descriptions or hardware ID. iNtnt(t*tposixs;Sorry: no implementation for your platform ('%s') availableccsnxgtD]\\}}}tj||tjsUtj||sUtj||r |||fVq q WdS(s Search for ports using a regular expression. Port name, description and hardware ID are searched. The function returns an iterable that returns the same tuples as comport() would do. N(tcomportstretsearchtI(tregexptporttdescthwid((s;/usr/lib/python2.7/site-packages/serial/tools/list_ports.pytgrep#s<c Csddl}|jdddd}|jdddd d d td d |jddddd dd dd d|jddddd dd ddd|j\}}d}|rt|dkr|jdnd|dfGHtt|d}ntt }xW|D]O\}}}d|fGH|j dkr]d|fGHd|fGHn|d7}qW|j r|rd|fGHqd GHndS(!Nitusages%prog [options] []t descriptions9Miniterm - A simple terminal program for the serial port.s--debugthelps6print debug messages and tracebacks (development mode)tdesttdebugtdefaulttactiont store_trues-vs --verboses0show more messages (can be given multiple times)tverboseitcounts-qs--quietssuppress all messagest store_consttconstis"more than one regexp not supportedsFiltered list with regexp: %rs%-20ss desc: %ss hwid: %ss%d ports foundsno ports found( toptparset OptionParsert add_optiontFalset parse_argstlenterrortsortedR RR( RtparsertoptionstargsthitstiteratorRR R ((s;/usr/lib/python2.7/site-packages/serial/tools/list_ports.pytmain.sJ       t__main__( t__doc__tsystosRtnametserial.tools.list_ports_windowstserial.tools.list_ports_posixt ImportErrorR R%t__name__(((s;/usr/lib/python2.7/site-packages/serial/tools/list_ports.pyts$    4 __init__.pyo000064400000000220147221704450007034 0ustar00 ApMc@sdS(N((((s9/usr/lib/python2.7/site-packages/serial/tools/__init__.pytslist_ports_posix.py000064400000016315147221704450010556 0ustar00import glob import sys import os import re try: import subprocess except ImportError: def popen(argv): try: si, so = os.popen4(' '.join(argv)) return so.read().strip() except: raise IOError('lsusb failed') else: def popen(argv): try: return subprocess.check_output(argv, stderr=subprocess.STDOUT).strip() except: raise IOError('lsusb failed') # The comports function is expected to return an iterable that yields tuples of # 3 strings: port name, human readable description and a hardware ID. # # as currently no method is known to get the second two strings easily, they # are currently just identical to the port name. # try to detect the OS so that a device can be selected... plat = sys.platform.lower() def read_line(filename): """help function to read a single line from a file. returns none""" try: f = open(filename) line = f.readline().strip() f.close() return line except IOError: return None def re_group(regexp, text): """search for regexp in text, return 1st group on match""" m = re.search(regexp, text) if m: return m.group(1) if plat[:5] == 'linux': # Linux (confirmed) # try to extract descriptions from sysfs. this was done by experimenting, # no guarantee that it works for all devices or in the future... def usb_sysfs_hw_string(sysfs_path): """given a path to a usb device in sysfs, return a string describing it""" bus, dev = os.path.basename(os.path.realpath(sysfs_path)).split('-') snr = read_line(sysfs_path+'/serial') if snr: snr_txt = ' SNR=%s' % (snr,) else: snr_txt = '' return 'USB VID:PID=%s:%s%s' % ( read_line(sysfs_path+'/idVendor'), read_line(sysfs_path+'/idProduct'), snr_txt ) def usb_lsusb_string(sysfs_path): bus, dev = os.path.basename(os.path.realpath(sysfs_path)).split('-') try: desc = popen(['lsusb', '-v', '-s', '%s:%s' % (bus, dev)]) # descriptions from device iManufacturer = re_group('iManufacturer\s+\w+ (.+)', desc) iProduct = re_group('iProduct\s+\w+ (.+)', desc) iSerial = re_group('iSerial\s+\w+ (.+)', desc) or '' # descriptions from kernel idVendor = re_group('idVendor\s+0x\w+ (.+)', desc) idProduct = re_group('idProduct\s+0x\w+ (.+)', desc) # create descriptions. prefer text from device, fall back to the others return '%s %s %s' % (iManufacturer or idVendor, iProduct or idProduct, iSerial) except IOError: return base def describe(device): """\ 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. """ base = os.path.basename(device) # USB-Serial devices sys_dev_path = '/sys/class/tty/%s/device/driver/%s' % (base, base) if os.path.exists(sys_dev_path): sys_usb = os.path.dirname(os.path.dirname(os.path.realpath(sys_dev_path))) return usb_lsusb_string(sys_usb) # USB-CDC devices sys_dev_path = '/sys/class/tty/%s/device/interface' % (base,) if os.path.exists(sys_dev_path): return read_line(sys_dev_path) return base def hwinfo(device): """Try to get a HW identification using sysfs""" base = os.path.basename(device) if os.path.exists('/sys/class/tty/%s/device' % (base,)): # PCI based devices sys_id_path = '/sys/class/tty/%s/device/id' % (base,) if os.path.exists(sys_id_path): return read_line(sys_id_path) # USB-Serial devices sys_dev_path = '/sys/class/tty/%s/device/driver/%s' % (base, base) if os.path.exists(sys_dev_path): sys_usb = os.path.dirname(os.path.dirname(os.path.realpath(sys_dev_path))) return usb_sysfs_hw_string(sys_usb) # USB-CDC devices if base.startswith('ttyACM'): sys_dev_path = '/sys/class/tty/%s/device' % (base,) if os.path.exists(sys_dev_path): return usb_sysfs_hw_string(sys_dev_path + '/..') return 'n/a' # XXX directly remove these from the list? def comports(): devices = glob.glob('/dev/ttyS*') + glob.glob('/dev/ttyUSB*') + glob.glob('/dev/ttyACM*') return [(d, describe(d), hwinfo(d)) for d in devices] elif plat == 'cygwin': # cygwin/win32 def comports(): devices = glob.glob('/dev/com*') return [(d, d, d) for d in devices] elif plat == 'openbsd3': # BSD def comports(): devices = glob.glob('/dev/ttyp*') return [(d, d, d) for d in devices] elif plat[:3] == 'bsd' or \ plat[:7] == 'freebsd' or \ plat[:7] == 'openbsd': # BSD def comports(): devices = glob.glob('/dev/cuad*') return [(d, d, d) for d in devices] elif plat[:6] == 'darwin': # OS X (confirmed) def comports(): """scan for available ports. return a list of device names.""" devices = glob.glob('/dev/tty.*') return [(d, d, d) for d in devices] elif plat[:6] == 'netbsd': # NetBSD def comports(): """scan for available ports. return a list of device names.""" devices = glob.glob('/dev/dty*') return [(d, d, d) for d in devices] elif plat[:4] == 'irix': # IRIX def comports(): """scan for available ports. return a list of device names.""" devices = glob.glob('/dev/ttyf*') return [(d, d, d) for d in devices] elif plat[:2] == 'hp': # HP-UX (not tested) def comports(): """scan for available ports. return a list of device names.""" devices = glob.glob('/dev/tty*p0') return [(d, d, d) for d in devices] elif plat[:5] == 'sunos': # Solaris/SunOS def comports(): """scan for available ports. return a list of device names.""" devices = glob.glob('/dev/tty*c') return [(d, d, d) for d in devices] elif plat[:3] == 'aix': # AIX def comports(): """scan for available ports. return a list of device names.""" devices = glob.glob('/dev/tty*') return [(d, d, d) for d in devices] else: # platform detection has failed... sys.stderr.write("""\ don'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... """ % (sys.platform, os.name, serial.VERSION)) raise ImportError("Sorry: no implementation for your platform ('%s') available" % (os.name,)) # test if __name__ == '__main__': for port, desc, hwid in sorted(comports()): print "%s: %s [%s]" % (port, desc, hwid) miniterm.py000064400000062756147221704450006770 0ustar00#!/usr/bin/env python # Very simple serial terminal # (C)2002-2011 Chris Liechti # Input characters are sent directly (only LF -> CR/LF/CRLF translation is # done), received characters are displayed as is (or escaped trough pythons # repr, useful for debug purposes) import sys, os, serial, threading EXITCHARCTER = '\x1d' # GS/CTRL+] MENUCHARACTER = '\x14' # Menu: CTRL+T def key_description(character): """generate a readable description for a key""" ascii_code = ord(character) if ascii_code < 32: return 'Ctrl+%c' % (ord('@') + ascii_code) else: return repr(character) # help text, starts with blank line! it's a function so that the current values # for the shortcut keys is used and not the value at program start def get_help_text(): return """ --- pySerial (%(version)s) - miniterm - help --- --- %(exit)-8s Exit program --- %(menu)-8s Menu escape key, followed by: --- Menu keys: --- %(itself)-7s Send the menu character itself to remote --- %(exchar)-7s Send the exit character itself to remote --- %(info)-7s Show info --- %(upload)-7s Upload file (prompt will be shown) --- Toggles: --- %(rts)-7s RTS %(echo)-7s local echo --- %(dtr)-7s DTR %(break)-7s BREAK --- %(lfm)-7s line feed %(repr)-7s Cycle repr mode --- --- Port settings (%(menu)s followed by the following): --- p change port --- 7 8 set data bits --- n e o s m change parity (None, Even, Odd, Space, Mark) --- 1 2 3 set stop bits (1, 2, 1.5) --- b change baud rate --- x X disable/enable software flow control --- r R disable/enable hardware flow control """ % { 'version': getattr(serial, 'VERSION', 'unknown version'), 'exit': key_description(EXITCHARCTER), 'menu': key_description(MENUCHARACTER), 'rts': key_description('\x12'), 'repr': key_description('\x01'), 'dtr': key_description('\x04'), 'lfm': key_description('\x0c'), 'break': key_description('\x02'), 'echo': key_description('\x05'), 'info': key_description('\x09'), 'upload': key_description('\x15'), 'itself': key_description(MENUCHARACTER), 'exchar': key_description(EXITCHARCTER), } if sys.version_info >= (3, 0): def character(b): return b.decode('latin1') else: def character(b): return b # first choose a platform dependant way to read single characters from the console global console if os.name == 'nt': import msvcrt class Console(object): def __init__(self): pass def setup(self): pass # Do nothing for 'nt' def cleanup(self): pass # Do nothing for 'nt' def getkey(self): while True: z = msvcrt.getch() if z == '\0' or z == '\xe0': # functions keys, ignore msvcrt.getch() else: if z == '\r': return '\n' return z console = Console() elif os.name == 'posix': import termios, sys, os class Console(object): def __init__(self): self.fd = sys.stdin.fileno() def setup(self): self.old = termios.tcgetattr(self.fd) new = termios.tcgetattr(self.fd) new[3] = new[3] & ~termios.ICANON & ~termios.ECHO & ~termios.ISIG new[6][termios.VMIN] = 1 new[6][termios.VTIME] = 0 termios.tcsetattr(self.fd, termios.TCSANOW, new) def getkey(self): c = os.read(self.fd, 1) return c def cleanup(self): termios.tcsetattr(self.fd, termios.TCSAFLUSH, self.old) console = Console() def cleanup_console(): console.cleanup() console.setup() sys.exitfunc = cleanup_console # terminal modes have to be restored on exit... else: raise NotImplementedError("Sorry no implementation for your platform (%s) available." % sys.platform) CONVERT_CRLF = 2 CONVERT_CR = 1 CONVERT_LF = 0 NEWLINE_CONVERISON_MAP = ('\n', '\r', '\r\n') LF_MODES = ('LF', 'CR', 'CR/LF') REPR_MODES = ('raw', 'some control', 'all control', 'hex') class Miniterm(object): def __init__(self, port, baudrate, parity, rtscts, xonxoff, echo=False, convert_outgoing=CONVERT_CRLF, repr_mode=0): try: self.serial = serial.serial_for_url(port, baudrate, parity=parity, rtscts=rtscts, xonxoff=xonxoff, timeout=1) except AttributeError: # happens when the installed pyserial is older than 2.5. use the # Serial class directly then. self.serial = serial.Serial(port, baudrate, parity=parity, rtscts=rtscts, xonxoff=xonxoff, timeout=1) self.echo = echo self.repr_mode = repr_mode self.convert_outgoing = convert_outgoing self.newline = NEWLINE_CONVERISON_MAP[self.convert_outgoing] self.dtr_state = True self.rts_state = True self.break_state = False def _start_reader(self): """Start reader thread""" self._reader_alive = True # start serial->console thread self.receiver_thread = threading.Thread(target=self.reader) self.receiver_thread.setDaemon(True) self.receiver_thread.start() def _stop_reader(self): """Stop reader thread only, wait for clean exit of thread""" self._reader_alive = False self.receiver_thread.join() def start(self): self.alive = True self._start_reader() # enter console->serial loop self.transmitter_thread = threading.Thread(target=self.writer) self.transmitter_thread.setDaemon(True) self.transmitter_thread.start() def stop(self): self.alive = False def join(self, transmit_only=False): self.transmitter_thread.join() if not transmit_only: self.receiver_thread.join() def dump_port_settings(self): sys.stderr.write("\n--- Settings: %s %s,%s,%s,%s\n" % ( self.serial.portstr, self.serial.baudrate, self.serial.bytesize, self.serial.parity, self.serial.stopbits)) sys.stderr.write('--- RTS: %-8s DTR: %-8s BREAK: %-8s\n' % ( (self.rts_state and 'active' or 'inactive'), (self.dtr_state and 'active' or 'inactive'), (self.break_state and 'active' or 'inactive'))) try: sys.stderr.write('--- CTS: %-8s DSR: %-8s RI: %-8s CD: %-8s\n' % ( (self.serial.getCTS() and 'active' or 'inactive'), (self.serial.getDSR() and 'active' or 'inactive'), (self.serial.getRI() and 'active' or 'inactive'), (self.serial.getCD() and 'active' or 'inactive'))) except serial.SerialException: # on RFC 2217 ports it can happen to no modem state notification was # yet received. ignore this error. pass sys.stderr.write('--- software flow control: %s\n' % (self.serial.xonxoff and 'active' or 'inactive')) sys.stderr.write('--- hardware flow control: %s\n' % (self.serial.rtscts and 'active' or 'inactive')) sys.stderr.write('--- data escaping: %s linefeed: %s\n' % ( REPR_MODES[self.repr_mode], LF_MODES[self.convert_outgoing])) def reader(self): """loop and copy serial->console""" try: while self.alive and self._reader_alive: data = character(self.serial.read(1)) if self.repr_mode == 0: # direct output, just have to care about newline setting if data == '\r' and self.convert_outgoing == CONVERT_CR: sys.stdout.write('\n') else: sys.stdout.write(data) elif self.repr_mode == 1: # escape non-printable, let pass newlines if self.convert_outgoing == CONVERT_CRLF and data in '\r\n': if data == '\n': sys.stdout.write('\n') elif data == '\r': pass elif data == '\n' and self.convert_outgoing == CONVERT_LF: sys.stdout.write('\n') elif data == '\r' and self.convert_outgoing == CONVERT_CR: sys.stdout.write('\n') else: sys.stdout.write(repr(data)[1:-1]) elif self.repr_mode == 2: # escape all non-printable, including newline sys.stdout.write(repr(data)[1:-1]) elif self.repr_mode == 3: # escape everything (hexdump) for c in data: sys.stdout.write("%s " % c.encode('hex')) sys.stdout.flush() except serial.SerialException, e: self.alive = False # would be nice if the console reader could be interruptted at this # point... raise def writer(self): """\ Loop and copy console->serial until EXITCHARCTER character is found. When MENUCHARACTER is found, interpret the next key locally. """ menu_active = False try: while self.alive: try: b = console.getkey() except KeyboardInterrupt: b = serial.to_bytes([3]) c = character(b) if menu_active: if c == MENUCHARACTER or c == EXITCHARCTER: # Menu character again/exit char -> send itself self.serial.write(b) # send character if self.echo: sys.stdout.write(c) elif c == '\x15': # CTRL+U -> upload file sys.stderr.write('\n--- File to upload: ') sys.stderr.flush() console.cleanup() filename = sys.stdin.readline().rstrip('\r\n') if filename: try: file = open(filename, 'r') sys.stderr.write('--- Sending file %s ---\n' % filename) while True: line = file.readline().rstrip('\r\n') if not line: break self.serial.write(line) self.serial.write('\r\n') # Wait for output buffer to drain. self.serial.flush() sys.stderr.write('.') # Progress indicator. sys.stderr.write('\n--- File %s sent ---\n' % filename) except IOError, e: sys.stderr.write('--- ERROR opening file %s: %s ---\n' % (filename, e)) console.setup() elif c in '\x08hH?': # CTRL+H, h, H, ? -> Show help sys.stderr.write(get_help_text()) elif c == '\x12': # CTRL+R -> Toggle RTS self.rts_state = not self.rts_state self.serial.setRTS(self.rts_state) sys.stderr.write('--- RTS %s ---\n' % (self.rts_state and 'active' or 'inactive')) elif c == '\x04': # CTRL+D -> Toggle DTR self.dtr_state = not self.dtr_state self.serial.setDTR(self.dtr_state) sys.stderr.write('--- DTR %s ---\n' % (self.dtr_state and 'active' or 'inactive')) elif c == '\x02': # CTRL+B -> toggle BREAK condition self.break_state = not self.break_state self.serial.setBreak(self.break_state) sys.stderr.write('--- BREAK %s ---\n' % (self.break_state and 'active' or 'inactive')) elif c == '\x05': # CTRL+E -> toggle local echo self.echo = not self.echo sys.stderr.write('--- local echo %s ---\n' % (self.echo and 'active' or 'inactive')) elif c == '\x09': # CTRL+I -> info self.dump_port_settings() elif c == '\x01': # CTRL+A -> cycle escape mode self.repr_mode += 1 if self.repr_mode > 3: self.repr_mode = 0 sys.stderr.write('--- escape data: %s ---\n' % ( REPR_MODES[self.repr_mode], )) elif c == '\x0c': # CTRL+L -> cycle linefeed mode self.convert_outgoing += 1 if self.convert_outgoing > 2: self.convert_outgoing = 0 self.newline = NEWLINE_CONVERISON_MAP[self.convert_outgoing] sys.stderr.write('--- line feed %s ---\n' % ( LF_MODES[self.convert_outgoing], )) elif c in 'pP': # P -> change port sys.stderr.write('\n--- Enter port name: ') sys.stderr.flush() console.cleanup() try: port = sys.stdin.readline().strip() except KeyboardInterrupt: port = None console.setup() if port and port != self.serial.port: # reader thread needs to be shut down self._stop_reader() # save settings settings = self.serial.getSettingsDict() try: try: new_serial = serial.serial_for_url(port, do_not_open=True) except AttributeError: # happens when the installed pyserial is older than 2.5. use the # Serial class directly then. new_serial = serial.Serial() new_serial.port = port # restore settings and open new_serial.applySettingsDict(settings) new_serial.open() new_serial.setRTS(self.rts_state) new_serial.setDTR(self.dtr_state) new_serial.setBreak(self.break_state) except Exception, e: sys.stderr.write('--- ERROR opening new port: %s ---\n' % (e,)) new_serial.close() else: self.serial.close() self.serial = new_serial sys.stderr.write('--- Port changed to: %s ---\n' % (self.serial.port,)) # and restart the reader thread self._start_reader() elif c in 'bB': # B -> change baudrate sys.stderr.write('\n--- Baudrate: ') sys.stderr.flush() console.cleanup() backup = self.serial.baudrate try: self.serial.baudrate = int(sys.stdin.readline().strip()) except ValueError, e: sys.stderr.write('--- ERROR setting baudrate: %s ---\n' % (e,)) self.serial.baudrate = backup else: self.dump_port_settings() console.setup() elif c == '8': # 8 -> change to 8 bits self.serial.bytesize = serial.EIGHTBITS self.dump_port_settings() elif c == '7': # 7 -> change to 8 bits self.serial.bytesize = serial.SEVENBITS self.dump_port_settings() elif c in 'eE': # E -> change to even parity self.serial.parity = serial.PARITY_EVEN self.dump_port_settings() elif c in 'oO': # O -> change to odd parity self.serial.parity = serial.PARITY_ODD self.dump_port_settings() elif c in 'mM': # M -> change to mark parity self.serial.parity = serial.PARITY_MARK self.dump_port_settings() elif c in 'sS': # S -> change to space parity self.serial.parity = serial.PARITY_SPACE self.dump_port_settings() elif c in 'nN': # N -> change to no parity self.serial.parity = serial.PARITY_NONE self.dump_port_settings() elif c == '1': # 1 -> change to 1 stop bits self.serial.stopbits = serial.STOPBITS_ONE self.dump_port_settings() elif c == '2': # 2 -> change to 2 stop bits self.serial.stopbits = serial.STOPBITS_TWO self.dump_port_settings() elif c == '3': # 3 -> change to 1.5 stop bits self.serial.stopbits = serial.STOPBITS_ONE_POINT_FIVE self.dump_port_settings() elif c in 'xX': # X -> change software flow control self.serial.xonxoff = (c == 'X') self.dump_port_settings() elif c in 'rR': # R -> change hardware flow control self.serial.rtscts = (c == 'R') self.dump_port_settings() else: sys.stderr.write('--- unknown menu character %s --\n' % key_description(c)) menu_active = False elif c == MENUCHARACTER: # next char will be for menu menu_active = True elif c == EXITCHARCTER: self.stop() break # exit app elif c == '\n': self.serial.write(self.newline) # send newline character(s) if self.echo: sys.stdout.write(c) # local echo is a real newline in any case sys.stdout.flush() else: self.serial.write(b) # send byte if self.echo: sys.stdout.write(c) sys.stdout.flush() except: self.alive = False raise def main(): import optparse parser = optparse.OptionParser( usage = "%prog [options] [port [baudrate]]", description = "Miniterm - A simple terminal program for the serial port." ) parser.add_option("-p", "--port", dest = "port", help = "port, a number or a device name. (deprecated option, use parameter instead)", default = None ) parser.add_option("-b", "--baud", dest = "baudrate", action = "store", type = 'int', help = "set baud rate, default %default", default = 9600 ) parser.add_option("--parity", dest = "parity", action = "store", help = "set parity, one of [N, E, O, S, M], default=N", default = 'N' ) parser.add_option("-e", "--echo", dest = "echo", action = "store_true", help = "enable local echo (default off)", default = False ) parser.add_option("--rtscts", dest = "rtscts", action = "store_true", help = "enable RTS/CTS flow control (default off)", default = False ) parser.add_option("--xonxoff", dest = "xonxoff", action = "store_true", help = "enable software flow control (default off)", default = False ) parser.add_option("--cr", dest = "cr", action = "store_true", help = "do not send CR+LF, send CR only", default = False ) parser.add_option("--lf", dest = "lf", action = "store_true", help = "do not send CR+LF, send LF only", default = False ) parser.add_option("-D", "--debug", dest = "repr_mode", action = "count", help = """debug received data (escape non-printable chars) --debug can be given multiple times: 0: just print what is received 1: escape non-printable characters, do newlines as unusual 2: escape non-printable characters, newlines too 3: hex dump everything""", default = 0 ) parser.add_option("--rts", dest = "rts_state", action = "store", type = 'int', help = "set initial RTS line state (possible values: 0, 1)", default = None ) parser.add_option("--dtr", dest = "dtr_state", action = "store", type = 'int', help = "set initial DTR line state (possible values: 0, 1)", default = None ) parser.add_option("-q", "--quiet", dest = "quiet", action = "store_true", help = "suppress non error messages", default = False ) parser.add_option("--exit-char", dest = "exit_char", action = "store", type = 'int', help = "ASCII code of special character that is used to exit the application", default = 0x1d ) parser.add_option("--menu-char", dest = "menu_char", action = "store", type = 'int', help = "ASCII code of special character that is used to control miniterm (menu)", default = 0x14 ) (options, args) = parser.parse_args() options.parity = options.parity.upper() if options.parity not in 'NEOSM': parser.error("invalid parity") if options.cr and options.lf: parser.error("only one of --cr or --lf can be specified") if options.menu_char == options.exit_char: parser.error('--exit-char can not be the same as --menu-char') global EXITCHARCTER, MENUCHARACTER EXITCHARCTER = chr(options.exit_char) MENUCHARACTER = chr(options.menu_char) port = options.port baudrate = options.baudrate if args: if options.port is not None: parser.error("no arguments are allowed, options only when --port is given") port = args.pop(0) if args: try: baudrate = int(args[0]) except ValueError: parser.error("baud rate must be a number, not %r" % args[0]) args.pop(0) if args: parser.error("too many arguments") else: if port is None: port = 0 convert_outgoing = CONVERT_CRLF if options.cr: convert_outgoing = CONVERT_CR elif options.lf: convert_outgoing = CONVERT_LF try: miniterm = Miniterm( port, baudrate, options.parity, rtscts=options.rtscts, xonxoff=options.xonxoff, echo=options.echo, convert_outgoing=convert_outgoing, repr_mode=options.repr_mode, ) except serial.SerialException, e: sys.stderr.write("could not open port %r: %s\n" % (port, e)) sys.exit(1) if not options.quiet: sys.stderr.write('--- Miniterm on %s: %d,%s,%s,%s ---\n' % ( miniterm.serial.portstr, miniterm.serial.baudrate, miniterm.serial.bytesize, miniterm.serial.parity, miniterm.serial.stopbits, )) sys.stderr.write('--- Quit: %s | Menu: %s | Help: %s followed by %s ---\n' % ( key_description(EXITCHARCTER), key_description(MENUCHARACTER), key_description(MENUCHARACTER), key_description('\x08'), )) if options.dtr_state is not None: if not options.quiet: sys.stderr.write('--- forcing DTR %s\n' % (options.dtr_state and 'active' or 'inactive')) miniterm.serial.setDTR(options.dtr_state) miniterm.dtr_state = options.dtr_state if options.rts_state is not None: if not options.quiet: sys.stderr.write('--- forcing RTS %s\n' % (options.rts_state and 'active' or 'inactive')) miniterm.serial.setRTS(options.rts_state) miniterm.rts_state = options.rts_state miniterm.start() try: miniterm.join(True) except KeyboardInterrupt: pass if not options.quiet: sys.stderr.write("\n--- exit ---\n") miniterm.join() if __name__ == '__main__': main() ttree.html000064400000071547147556271640006614 0ustar00 Template::Tools::ttree

SYNOPSIS

Top
ttree [options] [files]

DESCRIPTION

Top

The ttree script is used to process entire directory trees containing template files. The resulting output from processing each file is then written to a corresponding file in a destination directory. The script compares the modification times of source and destination files (where they already exist) and processes only those files that have been modified. In other words, it is the equivalent of 'make' for the Template Toolkit.

It supports a number of options which can be used to configure behaviour, define locations and set Template Toolkit options. The script first reads the .ttreerc configuration file in the HOME directory, or an alternative file specified in the TTREERC environment variable. Then, it processes any command line arguments, including any additional configuration files specified via the -f (file) option.

The .ttreerc Configuration File

Top

When you run ttree for the first time it will ask you if you want it to create a .ttreerc file for you. This will be created in your home directory.

$ ttree
Do you want me to create a sample '.ttreerc' file for you?
(file: /home/abw/.ttreerc)   [y/n]: y
/home/abw/.ttreerc created.  Please edit accordingly and re-run ttree

The purpose of this file is to set any global configuration options that you want applied every time ttree is run. For example, you can use the ignore and copy option to provide regular expressions that specify which files should be ignored and which should be copied rather than being processed as templates. You may also want to set flags like verbose and recurse according to your preference.

A minimal .ttreerc:

# ignore these files
ignore = \b(CVS|RCS)\b
ignore = ^#
ignore = ~$

# copy these files
copy   = \.(gif|png|jpg|pdf)$ 

# recurse into directories
recurse

# provide info about what's going on
verbose

In most cases, you'll want to create a different ttree configuration file for each project you're working on. The cfg option allows you to specify a directory where ttree can find further configuration files.

cfg = /home/abw/.ttree

The -f command line option can be used to specify which configuration file should be used. You can specify a filename using an absolute or relative path:

$ ttree -f /home/abw/web/example/etc/ttree.cfg
$ ttree -f ./etc/ttree.cfg
$ ttree -f ../etc/ttree.cfg

If the configuration file does not begin with / or . or something that looks like a MS-DOS absolute path (e.g. C:\\etc\\ttree.cfg) then ttree will look for it in the directory specified by the cfg option.

$ ttree -f test1          # /home/abw/.ttree/test1

The cfg option can only be used in the .ttreerc file. All the other options can be used in the .ttreerc or any other ttree configuration file. They can all also be specified as command line options.

Remember that .ttreerc is always processed before any configuration file specified with the -f option. Certain options like lib can be used any number of times and accumulate their values.

For example, consider the following configuration files:

/home/abw/.ttreerc:

cfg = /home/abw/.ttree
lib = /usr/local/tt2/templates

/home/abw/.ttree/myconfig:

lib = /home/abw/web/example/templates/lib

When ttree is invoked as follows:

$ ttree -f myconfig

the lib option will be set to the following directories:

/usr/local/tt2/templates
/home/abw/web/example/templates/lib

Any templates located under /usr/local/tt2/templates will be used in preference to those located under /home/abw/web/example/templates/lib. This may be what you want, but then again, it might not. For this reason, it is good practice to keep the .ttreerc as simple as possible and use different configuration files for each ttree project.

Directory Options

Top

The src option is used to define the directory containing the source templates to be processed. It can be provided as a command line option or in a configuration file as shown here:

src = /home/abw/web/example/templates/src

Each template in this directory typically corresponds to a single web page or other document.

The dest option is used to specify the destination directory for the generated output.

dest = /home/abw/web/example/html

The lib option is used to define one or more directories containing additional library templates. These templates are not documents in their own right and typically comprise of smaller, modular components like headers, footers and menus that are incorporated into pages templates.

lib = /home/abw/web/example/templates/lib
lib = /usr/local/tt2/templates

The lib option can be used repeatedly to add further directories to the search path.

A list of templates can be passed to ttree as command line arguments.

$ ttree foo.html bar.html

It looks for these templates in the src directory and processes them through the Template Toolkit, using any additional template components from the lib directories. The generated output is then written to the corresponding file in the dest directory.

If ttree is invoked without explicitly specifying any templates to be processed then it will process every file in the src directory. If the -r (recurse) option is set then it will additionally iterate down through sub-directories and process and other template files it finds therein.

$ ttree -r

If a template has been processed previously, ttree will compare the modification times of the source and destination files. If the source template (or one it is dependant on) has not been modified more recently than the generated output file then ttree will not process it. The -a (all) option can be used to force ttree to process all files regardless of modification time.

$ tree -a

Any templates explicitly named as command line argument are always processed and the modification time checking is bypassed.

File Options

Top

The ignore, copy and accept options are used to specify Perl regexen to filter file names. Files that match any of the ignore options will not be processed. Remaining files that match any of the copy regexen will be copied to the destination directory. Remaining files that then match any of the accept criteria are then processed via the Template Toolkit. If no accept parameter is specified then all files will be accepted for processing if not already copied or ignored.

# ignore these files
ignore = \b(CVS|RCS)\b
ignore = ^#
ignore = ~$

# copy these files
copy   = \.(gif|png|jpg|pdf)$ 

# accept only .tt2 templates
accept = \.tt2$

The suffix option is used to define mappings between the file extensions for source templates and the generated output files. The following example specifies that source templates with a .tt2 suffix should be output as .html files:

suffix tt2=html

Or on the command line,

--suffix tt2=html

You can provide any number of different suffix mappings by repeating this option.

Template Dependencies

Top

The depend and depend_file options allow you to specify how any given template file depends on another file or group of files. The depend option is used to express a single dependency.

$ ttree --depend foo=bar,baz

This command line example shows the --depend option being used to specify that the foo file is dependant on the bar and baz templates. This option can be used many time on the command line:

$ ttree --depend foo=bar,baz --depend crash=bang,wallop

or in a configuration file:

depend foo=bar,baz
depend crash=bang,wallop

The file appearing on the left of the = is specified relative to the src or lib directories. The file(s) appearing on the right can be specified relative to any of these directories or as absolute file paths.

For example:

$ ttree --depend foo=bar,/tmp/baz

To define a dependency that applies to all files, use * on the left of the =.

$ ttree --depend *=header,footer

or in a configuration file:

depend *=header,footer

Any templates that are defined in the pre_process, post_process, process or wrapper options will automatically be added to the list of global dependencies that apply to all templates.

The depend_file option can be used to specify a file that contains dependency information.

$ ttree --depend_file=/home/abw/web/example/etc/ttree.dep

Here is an example of a dependency file:

# This is a comment. It is ignored.

index.html: header footer menubar 

header: titlebar hotlinks

menubar: menuitem

# spanning multiple lines with the backslash
another.html: header footer menubar \
sidebar searchform

Lines beginning with the # character are comments and are ignored. Blank lines are also ignored. All other lines should provide a filename followed by a colon and then a list of dependant files separated by whitespace, commas or both. Whitespace around the colon is also optional. Lines ending in the \ character are continued onto the following line.

Files that contain spaces can be quoted. That is only necessary for files after the colon (':'). The file before the colon may be quoted if it contains a colon.

As with the command line options, the * character can be used as a wildcard to specify a dependency for all templates.

* : config,header

Template Toolkit Options

Top

ttree also provides access to the usual range of Template Toolkit options. For example, the --pre_chomp and --post_chomp ttree options correspond to the PRE_CHOMP and POST_CHOMP options.

Run ttree -h for a summary of the options available.

AUTHORS

Top

Andy Wardley <abw@wardley.org>

http://www.wardley.org

With contributions from Dylan William Hardison (support for dependencies), Bryce Harrington (absolute and relative options), Mark Anderson (suffix and debug options), Harald Joerg and Leon Brocard who gets everywhere, it seems.

COPYRIGHT

Top

Copyright (C) 1996-2007 Andy Wardley. All Rights Reserved.

This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.


tpage.html000064400000026376147556271640006571 0ustar00 Template::Tools::tpage

USAGE

Top
tpage [ --define var=value ] file(s)

DESCRIPTION

Top

The tpage script is a simple wrapper around the Template Toolkit processor. Files specified by name on the command line are processed in turn by the template processor and the resulting output is sent to STDOUT and can be redirected accordingly. e.g.

tpage myfile > myfile.out
tpage header myfile footer > myfile.html

If no file names are specified on the command line then tpage will read STDIN for input.

The --define option can be used to set the values of template variables. e.g.

tpage --define author="Andy Wardley" skeleton.pm > MyModule.pm

The .tpagerc Configuration File

Top

You can use a .tpagerc file in your home directory.

The purpose of this file is to set any global configuration options that you want applied every time tpage is run. For example, you can use the include_path to use template files from a generic template directory.

Run tpage -h for a summary of the options available.

See Template for general information about the Perl Template Toolkit and the template language and features.

AUTHOR

Top

Andy Wardley http://wardley.org/

COPYRIGHT

Top

Copyright (C) 1996-2008 Andy Wardley. All Rights Reserved.

This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

SEE ALSO

Top

index.html000064400000021745147556271640006573 0ustar00 Template::Tools

Template Tools

Top

The Template Toolkit includes the following command line tools for processing templates.

tpage

Top

The tpage script can be used to process a single template using the Template Toolkit.

$ tpage --define msg="Hello World" greeting.tt2

Use the -h option to get a summary of options:

$ tpage -h

See the Template::Tools::tpage documentation for further information and examples of use.

ttree

Top

The ttree script can be used to process an entire directory of templates.

$ ttree --src /path/to/templates --dest /path/to/output

Use the -h option to get a summary of options:

$ ttree -h

See the Template::Tools::ttree documentation for further information and examples of use.