Python Library Stringtools
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592
  1. <!DOCTYPE html>
  2. <html class="writer-html4" lang="en" >
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <title>Welcome to stringtools’s documentation! &mdash; stringtools documentation</title>
  7. <link rel="stylesheet" href="_static/css/theme.css" type="text/css" />
  8. <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
  9. <!--[if lt IE 9]>
  10. <script src="_static/js/html5shiv.min.js"></script>
  11. <![endif]-->
  12. <script type="text/javascript" id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
  13. <script type="text/javascript" src="_static/jquery.js"></script>
  14. <script type="text/javascript" src="_static/underscore.js"></script>
  15. <script type="text/javascript" src="_static/doctools.js"></script>
  16. <script type="text/javascript" src="_static/language_data.js"></script>
  17. <script type="text/javascript" src="_static/js/theme.js"></script>
  18. <link rel="index" title="Index" href="genindex.html" />
  19. <link rel="search" title="Search" href="search.html" />
  20. </head>
  21. <body class="wy-body-for-nav">
  22. <div class="wy-grid-for-nav">
  23. <nav data-toggle="wy-nav-shift" class="wy-nav-side">
  24. <div class="wy-side-scroll">
  25. <div class="wy-side-nav-search" >
  26. <a href="#" class="icon icon-home" alt="Documentation Home"> stringtools
  27. </a>
  28. <div role="search">
  29. <form id="rtd-search-form" class="wy-form" action="search.html" method="get">
  30. <input type="text" name="q" placeholder="Search docs" />
  31. <input type="hidden" name="check_keywords" value="yes" />
  32. <input type="hidden" name="area" value="default" />
  33. </form>
  34. </div>
  35. </div>
  36. <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
  37. <!-- Local TOC -->
  38. <div class="local-toc"><ul>
  39. <li><a class="reference internal" href="#">Welcome to stringtools’s documentation!</a><ul>
  40. <li><a class="reference internal" href="#stringtools-stringtools">stringtools (Stringtools)</a></li>
  41. <li><a class="reference internal" href="#stringtools-csp-carriage-return-seperation-protocol">stringtools.csp (Carriage-Return seperation protocol)</a></li>
  42. <li><a class="reference internal" href="#stringtools-stp-serial-transfer-protocol">stringtools.stp (Serial transfer protocol)</a></li>
  43. </ul>
  44. </li>
  45. <li><a class="reference internal" href="#indices-and-tables">Indices and tables</a></li>
  46. </ul>
  47. </div>
  48. </div>
  49. </div>
  50. </nav>
  51. <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
  52. <nav class="wy-nav-top" aria-label="top navigation">
  53. <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
  54. <a href="#">stringtools</a>
  55. </nav>
  56. <div class="wy-nav-content">
  57. <div class="rst-content">
  58. <div role="navigation" aria-label="breadcrumbs navigation">
  59. <ul class="wy-breadcrumbs">
  60. <li><a href="#" class="icon icon-home"></a> &raquo;</li>
  61. <li>Welcome to stringtools’s documentation!</li>
  62. <li class="wy-breadcrumbs-aside">
  63. <a href="_sources/index.rst.txt" rel="nofollow"> View page source</a>
  64. </li>
  65. </ul>
  66. <hr/>
  67. </div>
  68. <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
  69. <div itemprop="articleBody">
  70. <div class="section" id="module-stringtools">
  71. <span id="welcome-to-stringtools-s-documentation"></span><h1>Welcome to stringtools’s documentation!<a class="headerlink" href="#module-stringtools" title="Permalink to this headline">¶</a></h1>
  72. <div class="section" id="stringtools-stringtools">
  73. <h2>stringtools (Stringtools)<a class="headerlink" href="#stringtools-stringtools" title="Permalink to this headline">¶</a></h2>
  74. <p><strong>Author:</strong></p>
  75. <ul class="simple">
  76. <li>Dirk Alders &lt;<a class="reference external" href="mailto:sudo-dirk&#37;&#52;&#48;mount-mockery&#46;de">sudo-dirk<span>&#64;</span>mount-mockery<span>&#46;</span>de</a>&gt;</li>
  77. </ul>
  78. <p><strong>Description:</strong></p>
  79. <blockquote>
  80. <div>This Module supports functionality around string operations.</div></blockquote>
  81. <p><strong>Submodules:</strong></p>
  82. <ul class="simple">
  83. <li><a class="reference internal" href="#module-stringtools.csp" title="stringtools.csp"><code class="xref py py-mod docutils literal notranslate"><span class="pre">stringtools.csp</span></code></a></li>
  84. <li><a class="reference internal" href="#module-stringtools.stp" title="stringtools.stp"><code class="xref py py-mod docutils literal notranslate"><span class="pre">stringtools.stp</span></code></a></li>
  85. <li><a class="reference internal" href="#stringtools.gzip_compress" title="stringtools.gzip_compress"><code class="xref py py-func docutils literal notranslate"><span class="pre">gzip_compress()</span></code></a></li>
  86. <li><a class="reference internal" href="#stringtools.gzip_extract" title="stringtools.gzip_extract"><code class="xref py py-func docutils literal notranslate"><span class="pre">gzip_extract()</span></code></a></li>
  87. <li><a class="reference internal" href="#stringtools.hexlify" title="stringtools.hexlify"><code class="xref py py-func docutils literal notranslate"><span class="pre">hexlify()</span></code></a></li>
  88. </ul>
  89. <p><strong>Unittest:</strong></p>
  90. <blockquote>
  91. <div>See also the <a class="reference download internal" download="" href="_downloads/412e50d5e5a6e9ca1556b611fbae3c9c/unittest.pdf"><code class="xref download docutils literal notranslate"><span class="pre">unittest</span></code></a> documentation.</div></blockquote>
  92. <p><strong>Module Documentation:</strong></p>
  93. <dl class="function">
  94. <dt id="stringtools.gzip_compress">
  95. <code class="descclassname">stringtools.</code><code class="descname">gzip_compress</code><span class="sig-paren">(</span><em>s</em>, <em>compresslevel=9</em><span class="sig-paren">)</span><a class="headerlink" href="#stringtools.gzip_compress" title="Permalink to this definition">¶</a></dt>
  96. <dd><p>Method to compress a stream of bytes.</p>
  97. <table class="docutils field-list" frame="void" rules="none">
  98. <col class="field-name" />
  99. <col class="field-body" />
  100. <tbody valign="top">
  101. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  102. <li><strong>s</strong> (<em>str</em>) – The bytestream (string) to be compressed</li>
  103. <li><strong>compresslevel</strong> (<em>int</em>) – An optional compressionn level (default is 9)</li>
  104. </ul>
  105. </td>
  106. </tr>
  107. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">The compressed bytestream</p>
  108. </td>
  109. </tr>
  110. <tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">str</p>
  111. </td>
  112. </tr>
  113. </tbody>
  114. </table>
  115. <p><strong>Example:</strong></p>
  116. <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">sys</span>
  117. <span class="n">sys</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s1">&#39;../..&#39;</span><span class="p">)</span>
  118. <span class="kn">import</span> <span class="nn">stringtools</span>
  119. <span class="kn">import</span> <span class="nn">report</span>
  120. <span class="n">report</span><span class="o">.</span><span class="n">stdoutLoggingConfigure</span><span class="p">(</span><span class="n">log_name_lvl</span><span class="o">=</span><span class="p">[(</span><span class="s1">&#39;root&#39;</span><span class="p">,</span> <span class="s1">&#39;DEBUG&#39;</span><span class="p">),</span> <span class="p">])</span>
  121. <span class="nb">print</span><span class="p">(</span><span class="n">stringtools</span><span class="o">.</span><span class="n">hexlify</span><span class="p">(</span><span class="n">stringtools</span><span class="o">.</span><span class="n">gzip_compress</span><span class="p">(</span><span class="mi">15</span> <span class="o">*</span> <span class="sa">b</span><span class="s1">&#39;</span><span class="se">\x00</span><span class="s1">&#39;</span> <span class="o">+</span> <span class="mi">15</span> <span class="o">*</span> <span class="sa">b</span><span class="s1">&#39;</span><span class="se">\xff</span><span class="s1">&#39;</span><span class="p">)))</span>
  122. </pre></div>
  123. </div>
  124. <p>Will result to the following output:</p>
  125. <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">2021</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">03</span> <span class="mi">20</span><span class="p">:</span><span class="mi">57</span><span class="p">:</span><span class="mi">12</span><span class="p">,</span><span class="mi">305</span><span class="p">:</span> <span class="n">root</span><span class="o">.</span><span class="n">stringtools</span> <span class="o">-</span> <span class="n">DEBUG</span> <span class="o">-</span> <span class="n">GZIP</span><span class="p">:</span> <span class="n">Finished</span> <span class="n">to</span> <span class="n">compress</span> <span class="n">a</span> <span class="n">string</span> <span class="p">(</span><span class="n">compression_rate</span><span class="o">=</span><span class="mf">0.867</span><span class="p">,</span> <span class="n">consumed_time</span><span class="o">=</span><span class="mf">0.0</span><span class="n">s</span><span class="p">)</span><span class="o">.</span>
  126. <span class="p">(</span><span class="mi">26</span><span class="p">):</span> <span class="mi">1</span><span class="n">f</span> <span class="mi">8</span><span class="n">b</span> <span class="mi">08</span> <span class="mi">00</span> <span class="mi">98</span> <span class="mi">21</span> <span class="n">f2</span> <span class="mi">5</span><span class="n">f</span> <span class="mi">02</span> <span class="n">ff</span> <span class="mi">63</span> <span class="mi">60</span> <span class="mi">40</span> <span class="mi">01</span> <span class="n">ff</span> <span class="mi">51</span> <span class="mi">01</span> <span class="mi">00</span> <span class="mi">2</span><span class="n">d</span> <span class="mi">8</span><span class="n">a</span> <span class="mi">7</span><span class="n">d</span> <span class="n">de</span> <span class="mi">1</span><span class="n">e</span> <span class="mi">00</span> <span class="mi">00</span> <span class="mi">00</span>
  127. </pre></div>
  128. </div>
  129. </dd></dl>
  130. <dl class="function">
  131. <dt id="stringtools.gzip_extract">
  132. <code class="descclassname">stringtools.</code><code class="descname">gzip_extract</code><span class="sig-paren">(</span><em>s</em><span class="sig-paren">)</span><a class="headerlink" href="#stringtools.gzip_extract" title="Permalink to this definition">¶</a></dt>
  133. <dd><p>Method to extract data from a compress stream of bytes.</p>
  134. <table class="docutils field-list" frame="void" rules="none">
  135. <col class="field-name" />
  136. <col class="field-body" />
  137. <tbody valign="top">
  138. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>s</strong> (<em>str</em>) – The compressed bytestream (string) to be extracted</td>
  139. </tr>
  140. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">The extracted data</td>
  141. </tr>
  142. <tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body">str</td>
  143. </tr>
  144. </tbody>
  145. </table>
  146. <p><strong>Example:</strong></p>
  147. <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">sys</span>
  148. <span class="n">sys</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s1">&#39;../..&#39;</span><span class="p">)</span>
  149. <span class="kn">import</span> <span class="nn">stringtools</span>
  150. <span class="kn">import</span> <span class="nn">report</span>
  151. <span class="n">report</span><span class="o">.</span><span class="n">stdoutLoggingConfigure</span><span class="p">(</span><span class="n">log_name_lvl</span><span class="o">=</span><span class="p">[(</span><span class="s1">&#39;root&#39;</span><span class="p">,</span> <span class="s1">&#39;DEBUG&#39;</span><span class="p">),</span> <span class="p">])</span>
  152. <span class="nb">print</span><span class="p">(</span><span class="n">stringtools</span><span class="o">.</span><span class="n">hexlify</span><span class="p">(</span><span class="n">stringtools</span><span class="o">.</span><span class="n">gzip_extract</span><span class="p">(</span><span class="sa">b</span><span class="s1">&#39;</span><span class="se">\x1f\x8b\x08\x00\xd0\x82\xe5\x5c\x02\xff\x63\x60\x40\x01\xff\x51\x01\x00\x2d\x8a\x7d\xde\x1e\x00\x00\x00</span><span class="s1">&#39;</span><span class="p">)))</span>
  153. </pre></div>
  154. </div>
  155. <p>Will result to the following output:</p>
  156. <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">2021</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">03</span> <span class="mi">20</span><span class="p">:</span><span class="mi">57</span><span class="p">:</span><span class="mi">12</span><span class="p">,</span><span class="mi">210</span><span class="p">:</span> <span class="n">root</span><span class="o">.</span><span class="n">stringtools</span> <span class="o">-</span> <span class="n">DEBUG</span> <span class="o">-</span> <span class="n">GZIP</span><span class="p">:</span> <span class="n">Finished</span> <span class="n">to</span> <span class="n">extract</span> <span class="n">a</span> <span class="n">string</span> <span class="p">(</span><span class="n">compression_rate</span><span class="o">=</span><span class="mf">0.867</span><span class="p">,</span> <span class="n">consumed_time</span><span class="o">=</span><span class="mf">0.0</span><span class="n">s</span><span class="p">)</span><span class="o">.</span>
  157. <span class="p">(</span><span class="mi">30</span><span class="p">):</span> <span class="mi">00</span> <span class="mi">00</span> <span class="mi">00</span> <span class="mi">00</span> <span class="mi">00</span> <span class="mi">00</span> <span class="mi">00</span> <span class="mi">00</span> <span class="mi">00</span> <span class="mi">00</span> <span class="mi">00</span> <span class="mi">00</span> <span class="mi">00</span> <span class="mi">00</span> <span class="mi">00</span> <span class="n">ff</span> <span class="n">ff</span> <span class="n">ff</span> <span class="n">ff</span> <span class="n">ff</span> <span class="n">ff</span> <span class="n">ff</span> <span class="n">ff</span> <span class="n">ff</span> <span class="n">ff</span> <span class="n">ff</span> <span class="n">ff</span> <span class="n">ff</span> <span class="n">ff</span> <span class="n">ff</span>
  158. </pre></div>
  159. </div>
  160. </dd></dl>
  161. <dl class="function">
  162. <dt id="stringtools.hexlify">
  163. <code class="descclassname">stringtools.</code><code class="descname">hexlify</code><span class="sig-paren">(</span><em>s</em><span class="sig-paren">)</span><a class="headerlink" href="#stringtools.hexlify" title="Permalink to this definition">¶</a></dt>
  164. <dd><p>Method to hexlify a string.</p>
  165. <table class="docutils field-list" frame="void" rules="none">
  166. <col class="field-name" />
  167. <col class="field-body" />
  168. <tbody valign="top">
  169. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>s</strong> (<em>str</em>) – A string including the bytes to be hexlified.</td>
  170. </tr>
  171. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">The hexlified string</td>
  172. </tr>
  173. <tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body">str</td>
  174. </tr>
  175. </tbody>
  176. </table>
  177. <p><strong>Example:</strong></p>
  178. <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">sys</span>
  179. <span class="n">sys</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s1">&#39;../..&#39;</span><span class="p">)</span>
  180. <span class="kn">import</span> <span class="nn">stringtools</span>
  181. <span class="nb">print</span><span class="p">(</span><span class="n">stringtools</span><span class="o">.</span><span class="n">hexlify</span><span class="p">(</span><span class="sa">b</span><span class="s1">&#39;A stringexample with non printable characters like </span><span class="se">\x12</span><span class="s1">&#39;</span><span class="p">))</span>
  182. </pre></div>
  183. </div>
  184. <p>Will result to the following output:</p>
  185. <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">(</span><span class="mi">52</span><span class="p">):</span> <span class="mi">41</span> <span class="mi">20</span> <span class="mi">73</span> <span class="mi">74</span> <span class="mi">72</span> <span class="mi">69</span> <span class="mi">6</span><span class="n">e</span> <span class="mi">67</span> <span class="mi">65</span> <span class="mi">78</span> <span class="mi">61</span> <span class="mi">6</span><span class="n">d</span> <span class="mi">70</span> <span class="mi">6</span><span class="n">c</span> <span class="mi">65</span> <span class="mi">20</span> <span class="mi">77</span> <span class="mi">69</span> <span class="mi">74</span> <span class="mi">68</span> <span class="mi">20</span> <span class="mi">6</span><span class="n">e</span> <span class="mi">6</span><span class="n">f</span> <span class="mi">6</span><span class="n">e</span> <span class="mi">20</span> <span class="mi">70</span> <span class="mi">72</span> <span class="mi">69</span> <span class="mi">6</span><span class="n">e</span> <span class="mi">74</span> <span class="mi">61</span> <span class="mi">62</span> <span class="mi">6</span><span class="n">c</span> <span class="mi">65</span> <span class="mi">20</span> <span class="mi">63</span> <span class="mi">68</span> <span class="mi">61</span> <span class="mi">72</span> <span class="mi">61</span> <span class="mi">63</span> <span class="mi">74</span> <span class="mi">65</span> <span class="mi">72</span> <span class="mi">73</span> <span class="mi">20</span> <span class="mi">6</span><span class="n">c</span> <span class="mi">69</span> <span class="mi">6</span><span class="n">b</span> <span class="mi">65</span> <span class="mi">20</span> <span class="mi">12</span>
  186. </pre></div>
  187. </div>
  188. </dd></dl>
  189. </div>
  190. <span class="target" id="module-stringtools.csp"></span><div class="section" id="stringtools-csp-carriage-return-seperation-protocol">
  191. <h2>stringtools.csp (Carriage-Return seperation protocol)<a class="headerlink" href="#stringtools-csp-carriage-return-seperation-protocol" title="Permalink to this headline">¶</a></h2>
  192. <p><strong>Author:</strong></p>
  193. <ul class="simple">
  194. <li>Dirk Alders &lt;<a class="reference external" href="mailto:sudo-dirk&#37;&#52;&#48;mount-mockery&#46;de">sudo-dirk<span>&#64;</span>mount-mockery<span>&#46;</span>de</a>&gt;</li>
  195. </ul>
  196. <p><strong>Description:</strong></p>
  197. <blockquote>
  198. <div>This module is a submodule of <a class="reference internal" href="#module-stringtools" title="stringtools"><code class="xref py py-mod docutils literal notranslate"><span class="pre">stringtools</span></code></a> and creates an frame to transmit and receive messages via an serial interface.</div></blockquote>
  199. <p><strong>Submodules:</strong></p>
  200. <ul class="simple">
  201. <li><a class="reference internal" href="#stringtools.csp.csp" title="stringtools.csp.csp"><code class="xref py py-class docutils literal notranslate"><span class="pre">stringtools.csp.csp</span></code></a></li>
  202. <li><a class="reference internal" href="#stringtools.csp.build_frame" title="stringtools.csp.build_frame"><code class="xref py py-func docutils literal notranslate"><span class="pre">stringtools.csp.build_frame()</span></code></a></li>
  203. </ul>
  204. <dl class="function">
  205. <dt id="stringtools.csp.build_frame">
  206. <code class="descclassname">stringtools.csp.</code><code class="descname">build_frame</code><span class="sig-paren">(</span><em>msg</em>, <em>seperator=b'\n'</em><span class="sig-paren">)</span><a class="headerlink" href="#stringtools.csp.build_frame" title="Permalink to this definition">¶</a></dt>
  207. <dd><p>This Method builds an “csp-frame” to be transfered via a stream.</p>
  208. <table class="docutils field-list" frame="void" rules="none">
  209. <col class="field-name" />
  210. <col class="field-body" />
  211. <tbody valign="top">
  212. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>data</strong> (<em>str</em>) – A String (Bytes) to be framed</td>
  213. </tr>
  214. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">The “csp-framed” message to be sent</td>
  215. </tr>
  216. <tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body">str</td>
  217. </tr>
  218. </tbody>
  219. </table>
  220. <p><strong>Example:</strong></p>
  221. <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">sys</span>
  222. <span class="n">sys</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s1">&#39;../..&#39;</span><span class="p">)</span>
  223. <span class="kn">import</span> <span class="nn">stringtools</span>
  224. <span class="n">data</span> <span class="o">=</span> <span class="sa">b</span><span class="s1">&#39;message&#39;</span>
  225. <span class="nb">print</span><span class="p">(</span><span class="n">stringtools</span><span class="o">.</span><span class="n">hexlify</span><span class="p">(</span><span class="n">data</span><span class="p">))</span>
  226. <span class="nb">print</span><span class="p">(</span><span class="n">stringtools</span><span class="o">.</span><span class="n">hexlify</span><span class="p">(</span><span class="n">stringtools</span><span class="o">.</span><span class="n">csp</span><span class="o">.</span><span class="n">build_frame</span><span class="p">(</span><span class="n">data</span><span class="p">)))</span>
  227. </pre></div>
  228. </div>
  229. <p>Will result to the following output:</p>
  230. <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">(</span><span class="mi">7</span><span class="p">):</span> <span class="mi">6</span><span class="n">d</span> <span class="mi">65</span> <span class="mi">73</span> <span class="mi">73</span> <span class="mi">61</span> <span class="mi">67</span> <span class="mi">65</span>
  231. <span class="p">(</span><span class="mi">8</span><span class="p">):</span> <span class="mi">6</span><span class="n">d</span> <span class="mi">65</span> <span class="mi">73</span> <span class="mi">73</span> <span class="mi">61</span> <span class="mi">67</span> <span class="mi">65</span> <span class="mi">0</span><span class="n">a</span>
  232. </pre></div>
  233. </div>
  234. </dd></dl>
  235. <dl class="class">
  236. <dt id="stringtools.csp.csp">
  237. <em class="property">class </em><code class="descclassname">stringtools.csp.</code><code class="descname">csp</code><span class="sig-paren">(</span><em>seperator=b'n'</em><span class="sig-paren">)</span><a class="headerlink" href="#stringtools.csp.csp" title="Permalink to this definition">¶</a></dt>
  238. <dd><p>This class extracts messages from an “csp-stream”.</p>
  239. <p><strong>Example:</strong></p>
  240. <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">sys</span>
  241. <span class="n">sys</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s1">&#39;../..&#39;</span><span class="p">)</span>
  242. <span class="kn">import</span> <span class="nn">report</span>
  243. <span class="kn">import</span> <span class="nn">stringtools</span>
  244. <span class="n">report</span><span class="o">.</span><span class="n">stdoutLoggingConfigure</span><span class="p">(</span><span class="n">log_name_lvl</span><span class="o">=</span><span class="p">[(</span><span class="s1">&#39;root&#39;</span><span class="p">,</span> <span class="s1">&#39;DEBUG&#39;</span><span class="p">),</span> <span class="p">])</span>
  245. <span class="n">s</span> <span class="o">=</span> <span class="n">stringtools</span><span class="o">.</span><span class="n">csp</span><span class="o">.</span><span class="n">csp</span><span class="p">()</span>
  246. <span class="k">for</span> <span class="n">byte</span> <span class="ow">in</span> <span class="sa">b</span><span class="s1">&#39;message</span><span class="se">\n</span><span class="s1">&#39;</span><span class="p">:</span>
  247. <span class="n">data</span> <span class="o">=</span> <span class="n">s</span><span class="o">.</span><span class="n">process</span><span class="p">(</span><span class="nb">bytes</span><span class="p">([</span><span class="n">byte</span><span class="p">]))</span>
  248. <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">data</span><span class="p">)</span> <span class="o">&gt;</span> <span class="mi">0</span><span class="p">:</span>
  249. <span class="nb">print</span><span class="p">(</span><span class="n">data</span><span class="p">)</span>
  250. </pre></div>
  251. </div>
  252. <p>Will result to the following output:</p>
  253. <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">2021</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">03</span> <span class="mi">20</span><span class="p">:</span><span class="mi">57</span><span class="p">:</span><span class="mi">12</span><span class="p">,</span><span class="mi">362</span><span class="p">:</span> <span class="n">root</span><span class="o">.</span><span class="n">stringtools</span><span class="o">.</span><span class="n">csp</span> <span class="o">-</span> <span class="n">DEBUG</span> <span class="o">-</span> <span class="n">CSP</span><span class="p">:</span> <span class="n">Leaving</span> <span class="n">data</span> <span class="ow">in</span> <span class="n">buffer</span> <span class="p">(</span><span class="n">to</span> <span class="n">be</span> <span class="n">processed</span> <span class="nb">next</span> <span class="n">time</span><span class="p">):</span> <span class="p">(</span><span class="mi">1</span><span class="p">):</span> <span class="mi">6</span><span class="n">d</span>
  254. <span class="mi">2021</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">03</span> <span class="mi">20</span><span class="p">:</span><span class="mi">57</span><span class="p">:</span><span class="mi">12</span><span class="p">,</span><span class="mi">362</span><span class="p">:</span> <span class="n">root</span><span class="o">.</span><span class="n">stringtools</span><span class="o">.</span><span class="n">csp</span> <span class="o">-</span> <span class="n">DEBUG</span> <span class="o">-</span> <span class="n">CSP</span><span class="p">:</span> <span class="n">Leaving</span> <span class="n">data</span> <span class="ow">in</span> <span class="n">buffer</span> <span class="p">(</span><span class="n">to</span> <span class="n">be</span> <span class="n">processed</span> <span class="nb">next</span> <span class="n">time</span><span class="p">):</span> <span class="p">(</span><span class="mi">2</span><span class="p">):</span> <span class="mi">6</span><span class="n">d</span> <span class="mi">65</span>
  255. <span class="mi">2021</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">03</span> <span class="mi">20</span><span class="p">:</span><span class="mi">57</span><span class="p">:</span><span class="mi">12</span><span class="p">,</span><span class="mi">362</span><span class="p">:</span> <span class="n">root</span><span class="o">.</span><span class="n">stringtools</span><span class="o">.</span><span class="n">csp</span> <span class="o">-</span> <span class="n">DEBUG</span> <span class="o">-</span> <span class="n">CSP</span><span class="p">:</span> <span class="n">Leaving</span> <span class="n">data</span> <span class="ow">in</span> <span class="n">buffer</span> <span class="p">(</span><span class="n">to</span> <span class="n">be</span> <span class="n">processed</span> <span class="nb">next</span> <span class="n">time</span><span class="p">):</span> <span class="p">(</span><span class="mi">3</span><span class="p">):</span> <span class="mi">6</span><span class="n">d</span> <span class="mi">65</span> <span class="mi">73</span>
  256. <span class="mi">2021</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">03</span> <span class="mi">20</span><span class="p">:</span><span class="mi">57</span><span class="p">:</span><span class="mi">12</span><span class="p">,</span><span class="mi">362</span><span class="p">:</span> <span class="n">root</span><span class="o">.</span><span class="n">stringtools</span><span class="o">.</span><span class="n">csp</span> <span class="o">-</span> <span class="n">DEBUG</span> <span class="o">-</span> <span class="n">CSP</span><span class="p">:</span> <span class="n">Leaving</span> <span class="n">data</span> <span class="ow">in</span> <span class="n">buffer</span> <span class="p">(</span><span class="n">to</span> <span class="n">be</span> <span class="n">processed</span> <span class="nb">next</span> <span class="n">time</span><span class="p">):</span> <span class="p">(</span><span class="mi">4</span><span class="p">):</span> <span class="mi">6</span><span class="n">d</span> <span class="mi">65</span> <span class="mi">73</span> <span class="mi">73</span>
  257. <span class="mi">2021</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">03</span> <span class="mi">20</span><span class="p">:</span><span class="mi">57</span><span class="p">:</span><span class="mi">12</span><span class="p">,</span><span class="mi">362</span><span class="p">:</span> <span class="n">root</span><span class="o">.</span><span class="n">stringtools</span><span class="o">.</span><span class="n">csp</span> <span class="o">-</span> <span class="n">DEBUG</span> <span class="o">-</span> <span class="n">CSP</span><span class="p">:</span> <span class="n">Leaving</span> <span class="n">data</span> <span class="ow">in</span> <span class="n">buffer</span> <span class="p">(</span><span class="n">to</span> <span class="n">be</span> <span class="n">processed</span> <span class="nb">next</span> <span class="n">time</span><span class="p">):</span> <span class="p">(</span><span class="mi">5</span><span class="p">):</span> <span class="mi">6</span><span class="n">d</span> <span class="mi">65</span> <span class="mi">73</span> <span class="mi">73</span> <span class="mi">61</span>
  258. <span class="mi">2021</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">03</span> <span class="mi">20</span><span class="p">:</span><span class="mi">57</span><span class="p">:</span><span class="mi">12</span><span class="p">,</span><span class="mi">362</span><span class="p">:</span> <span class="n">root</span><span class="o">.</span><span class="n">stringtools</span><span class="o">.</span><span class="n">csp</span> <span class="o">-</span> <span class="n">DEBUG</span> <span class="o">-</span> <span class="n">CSP</span><span class="p">:</span> <span class="n">Leaving</span> <span class="n">data</span> <span class="ow">in</span> <span class="n">buffer</span> <span class="p">(</span><span class="n">to</span> <span class="n">be</span> <span class="n">processed</span> <span class="nb">next</span> <span class="n">time</span><span class="p">):</span> <span class="p">(</span><span class="mi">6</span><span class="p">):</span> <span class="mi">6</span><span class="n">d</span> <span class="mi">65</span> <span class="mi">73</span> <span class="mi">73</span> <span class="mi">61</span> <span class="mi">67</span>
  259. <span class="mi">2021</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">03</span> <span class="mi">20</span><span class="p">:</span><span class="mi">57</span><span class="p">:</span><span class="mi">12</span><span class="p">,</span><span class="mi">362</span><span class="p">:</span> <span class="n">root</span><span class="o">.</span><span class="n">stringtools</span><span class="o">.</span><span class="n">csp</span> <span class="o">-</span> <span class="n">DEBUG</span> <span class="o">-</span> <span class="n">CSP</span><span class="p">:</span> <span class="n">Leaving</span> <span class="n">data</span> <span class="ow">in</span> <span class="n">buffer</span> <span class="p">(</span><span class="n">to</span> <span class="n">be</span> <span class="n">processed</span> <span class="nb">next</span> <span class="n">time</span><span class="p">):</span> <span class="p">(</span><span class="mi">7</span><span class="p">):</span> <span class="mi">6</span><span class="n">d</span> <span class="mi">65</span> <span class="mi">73</span> <span class="mi">73</span> <span class="mi">61</span> <span class="mi">67</span> <span class="mi">65</span>
  260. <span class="mi">2021</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">03</span> <span class="mi">20</span><span class="p">:</span><span class="mi">57</span><span class="p">:</span><span class="mi">12</span><span class="p">,</span><span class="mi">362</span><span class="p">:</span> <span class="n">root</span><span class="o">.</span><span class="n">stringtools</span><span class="o">.</span><span class="n">csp</span> <span class="o">-</span> <span class="n">INFO</span> <span class="o">-</span> <span class="n">CSP</span><span class="p">:</span> <span class="n">message</span> <span class="n">identified</span> <span class="o">-</span> <span class="p">(</span><span class="mi">7</span><span class="p">):</span> <span class="mi">6</span><span class="n">d</span> <span class="mi">65</span> <span class="mi">73</span> <span class="mi">73</span> <span class="mi">61</span> <span class="mi">67</span> <span class="mi">65</span>
  261. <span class="p">[</span><span class="sa">b</span><span class="s1">&#39;message&#39;</span><span class="p">]</span>
  262. </pre></div>
  263. </div>
  264. <dl class="method">
  265. <dt id="stringtools.csp.csp.process">
  266. <code class="descname">process</code><span class="sig-paren">(</span><em>data</em><span class="sig-paren">)</span><a class="headerlink" href="#stringtools.csp.csp.process" title="Permalink to this definition">¶</a></dt>
  267. <dd><p>This processes a byte out of a “stp-stream”.</p>
  268. <table class="docutils field-list" frame="void" rules="none">
  269. <col class="field-name" />
  270. <col class="field-body" />
  271. <tbody valign="top">
  272. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>data</strong> (<em>bytes</em>) – A byte stream</td>
  273. </tr>
  274. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">A list of the extracted message(s)</td>
  275. </tr>
  276. <tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body">list</td>
  277. </tr>
  278. </tbody>
  279. </table>
  280. </dd></dl>
  281. </dd></dl>
  282. </div>
  283. <span class="target" id="module-stringtools.stp"></span><div class="section" id="stringtools-stp-serial-transfer-protocol">
  284. <h2>stringtools.stp (Serial transfer protocol)<a class="headerlink" href="#stringtools-stp-serial-transfer-protocol" title="Permalink to this headline">¶</a></h2>
  285. <p><strong>Author:</strong></p>
  286. <ul class="simple">
  287. <li>Dirk Alders &lt;<a class="reference external" href="mailto:sudo-dirk&#37;&#52;&#48;mount-mockery&#46;de">sudo-dirk<span>&#64;</span>mount-mockery<span>&#46;</span>de</a>&gt;</li>
  288. </ul>
  289. <p><strong>Description:</strong></p>
  290. <blockquote>
  291. <div>This module is a submodule of <a class="reference internal" href="#module-stringtools" title="stringtools"><code class="xref py py-mod docutils literal notranslate"><span class="pre">stringtools</span></code></a> and creates an serial frame to transmit and receive messages via an serial interface.</div></blockquote>
  292. <p><strong>Submodules:</strong></p>
  293. <ul class="simple">
  294. <li><a class="reference internal" href="#stringtools.stp.stp" title="stringtools.stp.stp"><code class="xref py py-class docutils literal notranslate"><span class="pre">stringtools.stp.stp</span></code></a></li>
  295. <li><a class="reference internal" href="#stringtools.stp.build_frame" title="stringtools.stp.build_frame"><code class="xref py py-func docutils literal notranslate"><span class="pre">stringtools.stp.build_frame()</span></code></a></li>
  296. </ul>
  297. <dl class="data">
  298. <dt id="stringtools.stp.DATA_CLEAR_BUFFER">
  299. <code class="descclassname">stringtools.stp.</code><code class="descname">DATA_CLEAR_BUFFER</code><em class="property"> = b'&lt;'</em><a class="headerlink" href="#stringtools.stp.DATA_CLEAR_BUFFER" title="Permalink to this definition">¶</a></dt>
  300. <dd><p>The clear buffer byte (‘\x3a\x3c’ -&gt; start of message)</p>
  301. </dd></dl>
  302. <dl class="data">
  303. <dt id="stringtools.stp.DATA_STORE_SYNC_VALUE">
  304. <code class="descclassname">stringtools.stp.</code><code class="descname">DATA_STORE_SYNC_VALUE</code><em class="property"> = b'='</em><a class="headerlink" href="#stringtools.stp.DATA_STORE_SYNC_VALUE" title="Permalink to this definition">¶</a></dt>
  305. <dd><p>The store sync value byte (‘\x3a\x3d’ -&gt; ‘\x3a’ inside a message)</p>
  306. </dd></dl>
  307. <dl class="data">
  308. <dt id="stringtools.stp.DATA_SYNC">
  309. <code class="descclassname">stringtools.stp.</code><code class="descname">DATA_SYNC</code><em class="property"> = b':'</em><a class="headerlink" href="#stringtools.stp.DATA_SYNC" title="Permalink to this definition">¶</a></dt>
  310. <dd><p>The data sync byte</p>
  311. </dd></dl>
  312. <dl class="data">
  313. <dt id="stringtools.stp.DATA_VALID_MSG">
  314. <code class="descclassname">stringtools.stp.</code><code class="descname">DATA_VALID_MSG</code><em class="property"> = b'&gt;'</em><a class="headerlink" href="#stringtools.stp.DATA_VALID_MSG" title="Permalink to this definition">¶</a></dt>
  315. <dd><p>The valid message byte (‘\x3a\x3e’ -&gt; end of message)</p>
  316. </dd></dl>
  317. <dl class="data">
  318. <dt id="stringtools.stp.STP_STATE_ESCAPE_1">
  319. <code class="descclassname">stringtools.stp.</code><code class="descname">STP_STATE_ESCAPE_1</code><em class="property"> = 1</em><a class="headerlink" href="#stringtools.stp.STP_STATE_ESCAPE_1" title="Permalink to this definition">¶</a></dt>
  320. <dd><p>Escape 1 state definition (‘\x3a\x3c’ found)</p>
  321. </dd></dl>
  322. <dl class="data">
  323. <dt id="stringtools.stp.STP_STATE_ESCAPE_2">
  324. <code class="descclassname">stringtools.stp.</code><code class="descname">STP_STATE_ESCAPE_2</code><em class="property"> = 2</em><a class="headerlink" href="#stringtools.stp.STP_STATE_ESCAPE_2" title="Permalink to this definition">¶</a></dt>
  325. <dd><p>Escape 2 state definition (‘\x3a’ found inside a message)</p>
  326. </dd></dl>
  327. <dl class="data">
  328. <dt id="stringtools.stp.STP_STATE_IDLE">
  329. <code class="descclassname">stringtools.stp.</code><code class="descname">STP_STATE_IDLE</code><em class="property"> = 0</em><a class="headerlink" href="#stringtools.stp.STP_STATE_IDLE" title="Permalink to this definition">¶</a></dt>
  330. <dd><p>Idle state definition (default)</p>
  331. </dd></dl>
  332. <dl class="data">
  333. <dt id="stringtools.stp.STP_STATE_STORE_DATA">
  334. <code class="descclassname">stringtools.stp.</code><code class="descname">STP_STATE_STORE_DATA</code><em class="property"> = 3</em><a class="headerlink" href="#stringtools.stp.STP_STATE_STORE_DATA" title="Permalink to this definition">¶</a></dt>
  335. <dd><p>Store data state definition (start of message found; data will be stored)</p>
  336. </dd></dl>
  337. <dl class="function">
  338. <dt id="stringtools.stp.build_frame">
  339. <code class="descclassname">stringtools.stp.</code><code class="descname">build_frame</code><span class="sig-paren">(</span><em>data</em><span class="sig-paren">)</span><a class="headerlink" href="#stringtools.stp.build_frame" title="Permalink to this definition">¶</a></dt>
  340. <dd><p>This Method builds an “stp-frame” to be transfered via a stream.</p>
  341. <table class="docutils field-list" frame="void" rules="none">
  342. <col class="field-name" />
  343. <col class="field-body" />
  344. <tbody valign="top">
  345. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>data</strong> (<em>str</em>) – A String (Bytes) to be framed</td>
  346. </tr>
  347. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">The “stp-framed” message to be sent</td>
  348. </tr>
  349. <tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body">str</td>
  350. </tr>
  351. </tbody>
  352. </table>
  353. <p><strong>Example:</strong></p>
  354. <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">sys</span>
  355. <span class="n">sys</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s1">&#39;../..&#39;</span><span class="p">)</span>
  356. <span class="kn">import</span> <span class="nn">stringtools</span>
  357. <span class="nb">print</span><span class="p">(</span><span class="nb">repr</span><span class="p">(</span><span class="n">stringtools</span><span class="o">.</span><span class="n">stp</span><span class="o">.</span><span class="n">build_frame</span><span class="p">(</span><span class="sa">b</span><span class="s1">&#39;:message:&#39;</span><span class="p">)))</span>
  358. </pre></div>
  359. </div>
  360. <p>Will result to the following output:</p>
  361. <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="sa">b</span><span class="s1">&#39;:&lt;:=message:=:&gt;&#39;</span>
  362. </pre></div>
  363. </div>
  364. </dd></dl>
  365. <dl class="class">
  366. <dt id="stringtools.stp.stp">
  367. <em class="property">class </em><code class="descclassname">stringtools.stp.</code><code class="descname">stp</code><a class="headerlink" href="#stringtools.stp.stp" title="Permalink to this definition">¶</a></dt>
  368. <dd><p>This class extracts messages from an “stp-stream”.</p>
  369. <p><strong>Example:</strong></p>
  370. <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">sys</span>
  371. <span class="n">sys</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s1">&#39;../..&#39;</span><span class="p">)</span>
  372. <span class="kn">import</span> <span class="nn">report</span>
  373. <span class="kn">import</span> <span class="nn">stringtools</span>
  374. <span class="n">report</span><span class="o">.</span><span class="n">stdoutLoggingConfigure</span><span class="p">(</span><span class="n">log_name_lvl</span><span class="o">=</span><span class="p">[(</span><span class="s1">&#39;root&#39;</span><span class="p">,</span> <span class="s1">&#39;DEBUG&#39;</span><span class="p">),</span> <span class="p">])</span>
  375. <span class="n">s</span> <span class="o">=</span> <span class="n">stringtools</span><span class="o">.</span><span class="n">stp</span><span class="o">.</span><span class="n">stp</span><span class="p">()</span>
  376. <span class="k">for</span> <span class="n">byte</span> <span class="ow">in</span> <span class="sa">b</span><span class="s1">&#39;:&lt;:=message:=:&gt;&#39;</span><span class="p">:</span>
  377. <span class="n">data</span> <span class="o">=</span> <span class="n">s</span><span class="o">.</span><span class="n">process</span><span class="p">(</span><span class="nb">bytes</span><span class="p">([</span><span class="n">byte</span><span class="p">]))</span>
  378. <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">data</span><span class="p">)</span> <span class="o">&gt;</span> <span class="mi">0</span><span class="p">:</span>
  379. <span class="nb">print</span><span class="p">(</span><span class="n">data</span><span class="p">)</span>
  380. </pre></div>
  381. </div>
  382. <p>Will result to the following output:</p>
  383. <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">2021</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">03</span> <span class="mi">20</span><span class="p">:</span><span class="mi">57</span><span class="p">:</span><span class="mi">12</span><span class="p">,</span><span class="mi">157</span><span class="p">:</span> <span class="n">root</span><span class="o">.</span><span class="n">stringtools</span><span class="o">.</span><span class="n">stp</span> <span class="o">-</span> <span class="n">DEBUG</span> <span class="o">-</span> <span class="n">STP</span><span class="p">:</span> <span class="n">data</span> <span class="n">sync</span> <span class="p">(</span><span class="mi">3</span><span class="n">a</span><span class="p">)</span> <span class="n">received</span> <span class="o">=&gt;</span> <span class="n">changing</span> <span class="n">state</span> <span class="n">STP_STATE_IDLE</span> <span class="o">-&gt;</span> <span class="n">STP_STATE_ESCAPE_1</span>
  384. <span class="mi">2021</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">03</span> <span class="mi">20</span><span class="p">:</span><span class="mi">57</span><span class="p">:</span><span class="mi">12</span><span class="p">,</span><span class="mi">157</span><span class="p">:</span> <span class="n">root</span><span class="o">.</span><span class="n">stringtools</span><span class="o">.</span><span class="n">stp</span> <span class="o">-</span> <span class="n">DEBUG</span> <span class="o">-</span> <span class="n">STP</span><span class="p">:</span> <span class="n">start</span> <span class="n">pattern</span> <span class="p">(</span><span class="mi">3</span><span class="n">a</span> <span class="mi">3</span><span class="n">c</span><span class="p">)</span> <span class="n">received</span> <span class="o">=&gt;</span> <span class="n">changing</span> <span class="n">state</span> <span class="n">STP_STATE_ESCAPE_1</span> <span class="o">-&gt;</span> <span class="n">STP_STATE_STORE_DATA</span>
  385. <span class="mi">2021</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">03</span> <span class="mi">20</span><span class="p">:</span><span class="mi">57</span><span class="p">:</span><span class="mi">12</span><span class="p">,</span><span class="mi">157</span><span class="p">:</span> <span class="n">root</span><span class="o">.</span><span class="n">stringtools</span><span class="o">.</span><span class="n">stp</span> <span class="o">-</span> <span class="n">DEBUG</span> <span class="o">-</span> <span class="n">STP</span><span class="p">:</span> <span class="n">data</span> <span class="n">sync</span> <span class="p">(</span><span class="mi">3</span><span class="n">a</span><span class="p">)</span> <span class="n">received</span> <span class="o">=&gt;</span> <span class="n">changing</span> <span class="n">state</span> <span class="n">STP_STATE_STORE_DATA</span> <span class="o">-&gt;</span> <span class="n">STP_STATE_ESCAPE_2</span>
  386. <span class="mi">2021</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">03</span> <span class="mi">20</span><span class="p">:</span><span class="mi">57</span><span class="p">:</span><span class="mi">12</span><span class="p">,</span><span class="mi">157</span><span class="p">:</span> <span class="n">root</span><span class="o">.</span><span class="n">stringtools</span><span class="o">.</span><span class="n">stp</span> <span class="o">-</span> <span class="n">DEBUG</span> <span class="o">-</span> <span class="n">STP</span><span class="p">:</span> <span class="n">store</span> <span class="n">sync</span> <span class="n">pattern</span> <span class="p">(</span><span class="mi">3</span><span class="n">a</span> <span class="mi">3</span><span class="n">d</span><span class="p">)</span> <span class="n">received</span> <span class="o">=&gt;</span> <span class="n">changing</span> <span class="n">state</span> <span class="n">STP_STATE_ESCAPE_2</span> <span class="o">-&gt;</span> <span class="n">STP_STATE_STORE_DATA</span>
  387. <span class="mi">2021</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">03</span> <span class="mi">20</span><span class="p">:</span><span class="mi">57</span><span class="p">:</span><span class="mi">12</span><span class="p">,</span><span class="mi">157</span><span class="p">:</span> <span class="n">root</span><span class="o">.</span><span class="n">stringtools</span><span class="o">.</span><span class="n">stp</span> <span class="o">-</span> <span class="n">DEBUG</span> <span class="o">-</span> <span class="n">STP</span><span class="p">:</span> <span class="n">data</span> <span class="n">sync</span> <span class="p">(</span><span class="mi">3</span><span class="n">a</span><span class="p">)</span> <span class="n">received</span> <span class="o">=&gt;</span> <span class="n">changing</span> <span class="n">state</span> <span class="n">STP_STATE_STORE_DATA</span> <span class="o">-&gt;</span> <span class="n">STP_STATE_ESCAPE_2</span>
  388. <span class="mi">2021</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">03</span> <span class="mi">20</span><span class="p">:</span><span class="mi">57</span><span class="p">:</span><span class="mi">12</span><span class="p">,</span><span class="mi">157</span><span class="p">:</span> <span class="n">root</span><span class="o">.</span><span class="n">stringtools</span><span class="o">.</span><span class="n">stp</span> <span class="o">-</span> <span class="n">DEBUG</span> <span class="o">-</span> <span class="n">STP</span><span class="p">:</span> <span class="n">store</span> <span class="n">sync</span> <span class="n">pattern</span> <span class="p">(</span><span class="mi">3</span><span class="n">a</span> <span class="mi">3</span><span class="n">d</span><span class="p">)</span> <span class="n">received</span> <span class="o">=&gt;</span> <span class="n">changing</span> <span class="n">state</span> <span class="n">STP_STATE_ESCAPE_2</span> <span class="o">-&gt;</span> <span class="n">STP_STATE_STORE_DATA</span>
  389. <span class="mi">2021</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">03</span> <span class="mi">20</span><span class="p">:</span><span class="mi">57</span><span class="p">:</span><span class="mi">12</span><span class="p">,</span><span class="mi">157</span><span class="p">:</span> <span class="n">root</span><span class="o">.</span><span class="n">stringtools</span><span class="o">.</span><span class="n">stp</span> <span class="o">-</span> <span class="n">DEBUG</span> <span class="o">-</span> <span class="n">STP</span><span class="p">:</span> <span class="n">data</span> <span class="n">sync</span> <span class="p">(</span><span class="mi">3</span><span class="n">a</span><span class="p">)</span> <span class="n">received</span> <span class="o">=&gt;</span> <span class="n">changing</span> <span class="n">state</span> <span class="n">STP_STATE_STORE_DATA</span> <span class="o">-&gt;</span> <span class="n">STP_STATE_ESCAPE_2</span>
  390. <span class="mi">2021</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">03</span> <span class="mi">20</span><span class="p">:</span><span class="mi">57</span><span class="p">:</span><span class="mi">12</span><span class="p">,</span><span class="mi">157</span><span class="p">:</span> <span class="n">root</span><span class="o">.</span><span class="n">stringtools</span><span class="o">.</span><span class="n">stp</span> <span class="o">-</span> <span class="n">DEBUG</span> <span class="o">-</span> <span class="n">STP</span><span class="p">:</span> <span class="n">end</span> <span class="n">pattern</span> <span class="p">(</span><span class="mi">3</span><span class="n">a</span> <span class="mi">3</span><span class="n">e</span><span class="p">)</span> <span class="n">received</span> <span class="o">=&gt;</span> <span class="n">storing</span> <span class="n">message</span> <span class="ow">and</span> <span class="n">changing</span> <span class="n">state</span> <span class="n">STP_STATE_ESCAPE_2</span> <span class="o">-&gt;</span> <span class="n">STP_STATE_IDLE</span>
  391. <span class="mi">2021</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">03</span> <span class="mi">20</span><span class="p">:</span><span class="mi">57</span><span class="p">:</span><span class="mi">12</span><span class="p">,</span><span class="mi">157</span><span class="p">:</span> <span class="n">root</span><span class="o">.</span><span class="n">stringtools</span><span class="o">.</span><span class="n">stp</span> <span class="o">-</span> <span class="n">INFO</span> <span class="o">-</span> <span class="n">STP</span><span class="p">:</span> <span class="n">message</span> <span class="n">identified</span> <span class="o">-</span> <span class="p">(</span><span class="mi">9</span><span class="p">):</span> <span class="mi">3</span><span class="n">a</span> <span class="mi">6</span><span class="n">d</span> <span class="mi">65</span> <span class="mi">73</span> <span class="mi">73</span> <span class="mi">61</span> <span class="mi">67</span> <span class="mi">65</span> <span class="mi">3</span><span class="n">a</span>
  392. <span class="p">[</span><span class="sa">b</span><span class="s1">&#39;:message:&#39;</span><span class="p">]</span>
  393. </pre></div>
  394. </div>
  395. <dl class="method">
  396. <dt id="stringtools.stp.stp.process">
  397. <code class="descname">process</code><span class="sig-paren">(</span><em>data</em><span class="sig-paren">)</span><a class="headerlink" href="#stringtools.stp.stp.process" title="Permalink to this definition">¶</a></dt>
  398. <dd><p>This processes a byte out of a “stp-stream”.</p>
  399. <table class="docutils field-list" frame="void" rules="none">
  400. <col class="field-name" />
  401. <col class="field-body" />
  402. <tbody valign="top">
  403. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>data</strong> (<em>bytes</em>) – A byte stream</td>
  404. </tr>
  405. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">The extracted message or None, if no message is identified yet</td>
  406. </tr>
  407. <tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body">str</td>
  408. </tr>
  409. </tbody>
  410. </table>
  411. </dd></dl>
  412. </dd></dl>
  413. </div>
  414. <div class="toctree-wrapper compound">
  415. </div>
  416. </div>
  417. <div class="section" id="indices-and-tables">
  418. <h1>Indices and tables<a class="headerlink" href="#indices-and-tables" title="Permalink to this headline">¶</a></h1>
  419. <ul class="simple">
  420. <li><a class="reference internal" href="genindex.html"><span class="std std-ref">Index</span></a></li>
  421. <li><a class="reference internal" href="py-modindex.html"><span class="std std-ref">Module Index</span></a></li>
  422. <li><a class="reference internal" href="search.html"><span class="std std-ref">Search Page</span></a></li>
  423. </ul>
  424. </div>
  425. </div>
  426. </div>
  427. <footer>
  428. <hr/>
  429. <div role="contentinfo">
  430. <p>
  431. &copy; Copyright 2021, Dirk Alders
  432. </p>
  433. </div>
  434. Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a
  435. <a href="https://github.com/rtfd/sphinx_rtd_theme">theme</a>
  436. provided by <a href="https://readthedocs.org">Read the Docs</a>.
  437. </footer>
  438. </div>
  439. </div>
  440. </section>
  441. </div>
  442. <script type="text/javascript">
  443. jQuery(function () {
  444. SphinxRtdTheme.Navigation.enable(true);
  445. });
  446. </script>
  447. </body>
  448. </html>