Python Library Stringtools
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

index.html 55KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  2. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml">
  4. <head>
  5. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  6. <title>Welcome to stringtools’s documentation! &#8212; stringtools documentation</title>
  7. <link rel="stylesheet" href="_static/alabaster.css" type="text/css" />
  8. <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
  9. <script type="text/javascript">
  10. var DOCUMENTATION_OPTIONS = {
  11. URL_ROOT: './',
  12. VERSION: '',
  13. COLLAPSE_INDEX: false,
  14. FILE_SUFFIX: '.html',
  15. HAS_SOURCE: true,
  16. SOURCELINK_SUFFIX: '.txt'
  17. };
  18. </script>
  19. <script type="text/javascript" src="_static/jquery.js"></script>
  20. <script type="text/javascript" src="_static/underscore.js"></script>
  21. <script type="text/javascript" src="_static/doctools.js"></script>
  22. <link rel="index" title="Index" href="genindex.html" />
  23. <link rel="search" title="Search" href="search.html" />
  24. <link rel="stylesheet" href="_static/custom.css" type="text/css" />
  25. <meta name="viewport" content="width=device-width, initial-scale=0.9, maximum-scale=0.9" />
  26. </head>
  27. <body>
  28. <div class="document">
  29. <div class="documentwrapper">
  30. <div class="bodywrapper">
  31. <div class="body" role="main">
  32. <div class="section" id="module-stringtools">
  33. <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>
  34. <div class="section" id="stringtools-stringtools">
  35. <h2>stringtools (Stringtools)<a class="headerlink" href="#stringtools-stringtools" title="Permalink to this headline">¶</a></h2>
  36. <p><strong>Author:</strong></p>
  37. <ul class="simple">
  38. <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>
  39. </ul>
  40. <p><strong>Description:</strong></p>
  41. <blockquote>
  42. <div>This Module supports functionality around string operations.</div></blockquote>
  43. <p><strong>Submodules:</strong></p>
  44. <ul class="simple">
  45. <li><a class="reference internal" href="#module-stringtools.csp" title="stringtools.csp"><code class="xref py py-mod docutils literal"><span class="pre">stringtools.csp</span></code></a></li>
  46. <li><a class="reference internal" href="#module-stringtools.stp" title="stringtools.stp"><code class="xref py py-mod docutils literal"><span class="pre">stringtools.stp</span></code></a></li>
  47. <li><a class="reference internal" href="#stringtools.gzip_compress" title="stringtools.gzip_compress"><code class="xref py py-func docutils literal"><span class="pre">gzip_compress()</span></code></a></li>
  48. <li><a class="reference internal" href="#stringtools.gzip_extract" title="stringtools.gzip_extract"><code class="xref py py-func docutils literal"><span class="pre">gzip_extract()</span></code></a></li>
  49. <li><a class="reference internal" href="#stringtools.hexlify" title="stringtools.hexlify"><code class="xref py py-func docutils literal"><span class="pre">hexlify()</span></code></a></li>
  50. </ul>
  51. <p><strong>Unittest:</strong></p>
  52. <blockquote>
  53. <div>See also the <a class="reference download internal" href="_downloads/unittest.pdf" download=""><code class="xref download docutils literal"><span class="pre">unittest</span></code></a> documentation.</div></blockquote>
  54. <p><strong>Module Documentation:</strong></p>
  55. <dl class="function">
  56. <dt id="stringtools.gzip_compress">
  57. <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>
  58. <dd><p>Method to compress a stream of bytes.</p>
  59. <table class="docutils field-list" frame="void" rules="none">
  60. <col class="field-name" />
  61. <col class="field-body" />
  62. <tbody valign="top">
  63. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  64. <li><strong>s</strong> (<em>str</em>) – The bytestream (string) to be compressed</li>
  65. <li><strong>compresslevel</strong> (<em>int</em>) – An optional compressionn level (default is 9)</li>
  66. </ul>
  67. </td>
  68. </tr>
  69. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">The compressed bytestream</p>
  70. </td>
  71. </tr>
  72. <tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">str</p>
  73. </td>
  74. </tr>
  75. </tbody>
  76. </table>
  77. <p><strong>Example:</strong></p>
  78. <div class="highlight-default"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">stringtools</span>
  79. <span class="kn">import</span> <span class="nn">report</span>
  80. <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="n">stringtools</span><span class="o">.</span><span class="n">logger_name</span><span class="p">,</span> <span class="s1">&#39;DEBUG&#39;</span><span class="p">),</span> <span class="p">])</span>
  81. <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>
  82. </pre></div>
  83. </div>
  84. <p>Will result to the following output:</p>
  85. <div class="highlight-default"><div class="highlight"><pre><span></span><span class="mi">2020</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">28</span> <span class="mi">21</span><span class="p">:</span><span class="mi">45</span><span class="p">:</span><span class="mi">24</span><span class="p">,</span><span class="mi">558</span><span class="p">:</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>
  86. <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">64</span> <span class="mi">9</span><span class="n">d</span> <span class="mi">30</span> <span class="mi">5</span><span class="n">e</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>
  87. </pre></div>
  88. </div>
  89. </dd></dl>
  90. <dl class="function">
  91. <dt id="stringtools.gzip_extract">
  92. <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>
  93. <dd><p>Method to extract data from a compress stream of bytes.</p>
  94. <table class="docutils field-list" frame="void" rules="none">
  95. <col class="field-name" />
  96. <col class="field-body" />
  97. <tbody valign="top">
  98. <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>
  99. </tr>
  100. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">The extracted data</td>
  101. </tr>
  102. <tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body">str</td>
  103. </tr>
  104. </tbody>
  105. </table>
  106. <p><strong>Example:</strong></p>
  107. <div class="highlight-default"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">stringtools</span>
  108. <span class="kn">import</span> <span class="nn">report</span>
  109. <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="n">stringtools</span><span class="o">.</span><span class="n">logger_name</span><span class="p">,</span> <span class="s1">&#39;DEBUG&#39;</span><span class="p">),</span> <span class="p">])</span>
  110. <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>
  111. </pre></div>
  112. </div>
  113. <p>Will result to the following output:</p>
  114. <div class="highlight-default"><div class="highlight"><pre><span></span><span class="mi">2020</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">28</span> <span class="mi">21</span><span class="p">:</span><span class="mi">45</span><span class="p">:</span><span class="mi">39</span><span class="p">,</span><span class="mi">899</span><span class="p">:</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>
  115. <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>
  116. </pre></div>
  117. </div>
  118. </dd></dl>
  119. <dl class="function">
  120. <dt id="stringtools.hexlify">
  121. <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>
  122. <dd><p>Method to hexlify a string.</p>
  123. <table class="docutils field-list" frame="void" rules="none">
  124. <col class="field-name" />
  125. <col class="field-body" />
  126. <tbody valign="top">
  127. <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>
  128. </tr>
  129. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">The hexlified string</td>
  130. </tr>
  131. <tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body">str</td>
  132. </tr>
  133. </tbody>
  134. </table>
  135. <p><strong>Example:</strong></p>
  136. <div class="highlight-default"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">stringtools</span>
  137. <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>
  138. </pre></div>
  139. </div>
  140. <p>Will result to the following output:</p>
  141. <div class="highlight-default"><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>
  142. </pre></div>
  143. </div>
  144. </dd></dl>
  145. </div>
  146. <span class="target" id="module-stringtools.csp"></span><div class="section" id="csp-carriage-return-seperation-protocol">
  147. <h2>csp (Carriage-Return seperation protocol)<a class="headerlink" href="#csp-carriage-return-seperation-protocol" title="Permalink to this headline">¶</a></h2>
  148. <p><strong>Author:</strong></p>
  149. <ul class="simple">
  150. <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>
  151. </ul>
  152. <p><strong>Description:</strong></p>
  153. <blockquote>
  154. <div>This module is a submodule of <a class="reference internal" href="#module-stringtools" title="stringtools"><code class="xref py py-mod docutils literal"><span class="pre">stringtools</span></code></a> and creates an frame to transmit and receive messages via an serial interface.</div></blockquote>
  155. <p><strong>Submodules:</strong></p>
  156. <ul class="simple">
  157. <li><a class="reference internal" href="#stringtools.csp.csp" title="stringtools.csp.csp"><code class="xref py py-class docutils literal"><span class="pre">stringtools.csp.csp</span></code></a></li>
  158. <li><a class="reference internal" href="#stringtools.csp.build_frame" title="stringtools.csp.build_frame"><code class="xref py py-func docutils literal"><span class="pre">stringtools.csp.build_frame()</span></code></a></li>
  159. </ul>
  160. <dl class="function">
  161. <dt id="stringtools.csp.build_frame">
  162. <code class="descclassname">stringtools.csp.</code><code class="descname">build_frame</code><span class="sig-paren">(</span><em>msg</em>, <em>seperator='\n'</em><span class="sig-paren">)</span><a class="headerlink" href="#stringtools.csp.build_frame" title="Permalink to this definition">¶</a></dt>
  163. <dd><p>This Method builds an “csp-frame” to be transfered via a stream.</p>
  164. <table class="docutils field-list" frame="void" rules="none">
  165. <col class="field-name" />
  166. <col class="field-body" />
  167. <tbody valign="top">
  168. <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>
  169. </tr>
  170. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">The “csp-framed” message to be sent</td>
  171. </tr>
  172. <tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body">str</td>
  173. </tr>
  174. </tbody>
  175. </table>
  176. <p><strong>Example:</strong></p>
  177. <div class="highlight-default"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">stringtools</span>
  178. <span class="n">data</span> <span class="o">=</span> <span class="sa">b</span><span class="s1">&#39;message&#39;</span>
  179. <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>
  180. <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>
  181. </pre></div>
  182. </div>
  183. <p>Will result to the following output:</p>
  184. <div class="highlight-default"><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>
  185. <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>
  186. </pre></div>
  187. </div>
  188. </dd></dl>
  189. <dl class="class">
  190. <dt id="stringtools.csp.csp">
  191. <em class="property">class </em><code class="descclassname">stringtools.csp.</code><code class="descname">csp</code><span class="sig-paren">(</span><em>seperator='n'</em><span class="sig-paren">)</span><a class="headerlink" href="#stringtools.csp.csp" title="Permalink to this definition">¶</a></dt>
  192. <dd><p>This class extracts messages from an “csp-stream”.</p>
  193. <p><strong>Example:</strong></p>
  194. <div class="highlight-default"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">report</span>
  195. <span class="kn">import</span> <span class="nn">stringtools</span>
  196. <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="n">stringtools</span><span class="o">.</span><span class="n">logger_name</span><span class="p">,</span> <span class="s1">&#39;DEBUG&#39;</span><span class="p">),</span> <span class="p">])</span>
  197. <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>
  198. <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>
  199. <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>
  200. <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>
  201. <span class="nb">print</span><span class="p">(</span><span class="n">data</span><span class="p">)</span>
  202. </pre></div>
  203. </div>
  204. <p>Will result to the following output:</p>
  205. <div class="highlight-default"><div class="highlight"><pre><span></span><span class="mi">2020</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">28</span> <span class="mi">21</span><span class="p">:</span><span class="mi">31</span><span class="p">:</span><span class="mi">22</span><span class="p">,</span><span class="mi">093</span><span class="p">:</span> <span class="n">STRINGTOOLS</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">5</span><span class="n">b</span> <span class="mi">27</span> <span class="mi">6</span><span class="n">d</span> <span class="mi">27</span> <span class="mi">5</span><span class="n">d</span>
  206. <span class="mi">2020</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">28</span> <span class="mi">21</span><span class="p">:</span><span class="mi">31</span><span class="p">:</span><span class="mi">22</span><span class="p">,</span><span class="mi">094</span><span class="p">:</span> <span class="n">STRINGTOOLS</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">10</span><span class="p">):</span> <span class="mi">5</span><span class="n">b</span> <span class="mi">27</span> <span class="mi">6</span><span class="n">d</span> <span class="mi">27</span> <span class="mi">5</span><span class="n">d</span> <span class="mi">5</span><span class="n">b</span> <span class="mi">27</span> <span class="mi">65</span> <span class="mi">27</span> <span class="mi">5</span><span class="n">d</span>
  207. <span class="mi">2020</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">28</span> <span class="mi">21</span><span class="p">:</span><span class="mi">31</span><span class="p">:</span><span class="mi">22</span><span class="p">,</span><span class="mi">094</span><span class="p">:</span> <span class="n">STRINGTOOLS</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">15</span><span class="p">):</span> <span class="mi">5</span><span class="n">b</span> <span class="mi">27</span> <span class="mi">6</span><span class="n">d</span> <span class="mi">27</span> <span class="mi">5</span><span class="n">d</span> <span class="mi">5</span><span class="n">b</span> <span class="mi">27</span> <span class="mi">65</span> <span class="mi">27</span> <span class="mi">5</span><span class="n">d</span> <span class="mi">5</span><span class="n">b</span> <span class="mi">27</span> <span class="mi">73</span> <span class="mi">27</span> <span class="mi">5</span><span class="n">d</span>
  208. <span class="mi">2020</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">28</span> <span class="mi">21</span><span class="p">:</span><span class="mi">31</span><span class="p">:</span><span class="mi">22</span><span class="p">,</span><span class="mi">095</span><span class="p">:</span> <span class="n">STRINGTOOLS</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">20</span><span class="p">):</span> <span class="mi">5</span><span class="n">b</span> <span class="mi">27</span> <span class="mi">6</span><span class="n">d</span> <span class="mi">27</span> <span class="mi">5</span><span class="n">d</span> <span class="mi">5</span><span class="n">b</span> <span class="mi">27</span> <span class="mi">65</span> <span class="mi">27</span> <span class="mi">5</span><span class="n">d</span> <span class="mi">5</span><span class="n">b</span> <span class="mi">27</span> <span class="mi">73</span> <span class="mi">27</span> <span class="mi">5</span><span class="n">d</span> <span class="mi">5</span><span class="n">b</span> <span class="mi">27</span> <span class="mi">73</span> <span class="mi">27</span> <span class="mi">5</span><span class="n">d</span>
  209. <span class="mi">2020</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">28</span> <span class="mi">21</span><span class="p">:</span><span class="mi">31</span><span class="p">:</span><span class="mi">22</span><span class="p">,</span><span class="mi">095</span><span class="p">:</span> <span class="n">STRINGTOOLS</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">25</span><span class="p">):</span> <span class="mi">5</span><span class="n">b</span> <span class="mi">27</span> <span class="mi">6</span><span class="n">d</span> <span class="mi">27</span> <span class="mi">5</span><span class="n">d</span> <span class="mi">5</span><span class="n">b</span> <span class="mi">27</span> <span class="mi">65</span> <span class="mi">27</span> <span class="mi">5</span><span class="n">d</span> <span class="mi">5</span><span class="n">b</span> <span class="mi">27</span> <span class="mi">73</span> <span class="mi">27</span> <span class="mi">5</span><span class="n">d</span> <span class="mi">5</span><span class="n">b</span> <span class="mi">27</span> <span class="mi">73</span> <span class="mi">27</span> <span class="mi">5</span><span class="n">d</span> <span class="mi">5</span><span class="n">b</span> <span class="mi">27</span> <span class="mi">61</span> <span class="mi">27</span> <span class="mi">5</span><span class="n">d</span>
  210. <span class="mi">2020</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">28</span> <span class="mi">21</span><span class="p">:</span><span class="mi">31</span><span class="p">:</span><span class="mi">22</span><span class="p">,</span><span class="mi">095</span><span class="p">:</span> <span class="n">STRINGTOOLS</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">30</span><span class="p">):</span> <span class="mi">5</span><span class="n">b</span> <span class="mi">27</span> <span class="mi">6</span><span class="n">d</span> <span class="mi">27</span> <span class="mi">5</span><span class="n">d</span> <span class="mi">5</span><span class="n">b</span> <span class="mi">27</span> <span class="mi">65</span> <span class="mi">27</span> <span class="mi">5</span><span class="n">d</span> <span class="mi">5</span><span class="n">b</span> <span class="mi">27</span> <span class="mi">73</span> <span class="mi">27</span> <span class="mi">5</span><span class="n">d</span> <span class="mi">5</span><span class="n">b</span> <span class="mi">27</span> <span class="mi">73</span> <span class="mi">27</span> <span class="mi">5</span><span class="n">d</span> <span class="mi">5</span><span class="n">b</span> <span class="mi">27</span> <span class="mi">61</span> <span class="mi">27</span> <span class="mi">5</span><span class="n">d</span> <span class="mi">5</span><span class="n">b</span> <span class="mi">27</span> <span class="mi">67</span> <span class="mi">27</span> <span class="mi">5</span><span class="n">d</span>
  211. <span class="mi">2020</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">28</span> <span class="mi">21</span><span class="p">:</span><span class="mi">31</span><span class="p">:</span><span class="mi">22</span><span class="p">,</span><span class="mi">096</span><span class="p">:</span> <span class="n">STRINGTOOLS</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">35</span><span class="p">):</span> <span class="mi">5</span><span class="n">b</span> <span class="mi">27</span> <span class="mi">6</span><span class="n">d</span> <span class="mi">27</span> <span class="mi">5</span><span class="n">d</span> <span class="mi">5</span><span class="n">b</span> <span class="mi">27</span> <span class="mi">65</span> <span class="mi">27</span> <span class="mi">5</span><span class="n">d</span> <span class="mi">5</span><span class="n">b</span> <span class="mi">27</span> <span class="mi">73</span> <span class="mi">27</span> <span class="mi">5</span><span class="n">d</span> <span class="mi">5</span><span class="n">b</span> <span class="mi">27</span> <span class="mi">73</span> <span class="mi">27</span> <span class="mi">5</span><span class="n">d</span> <span class="mi">5</span><span class="n">b</span> <span class="mi">27</span> <span class="mi">61</span> <span class="mi">27</span> <span class="mi">5</span><span class="n">d</span> <span class="mi">5</span><span class="n">b</span> <span class="mi">27</span> <span class="mi">67</span> <span class="mi">27</span> <span class="mi">5</span><span class="n">d</span> <span class="mi">5</span><span class="n">b</span> <span class="mi">27</span> <span class="mi">65</span> <span class="mi">27</span> <span class="mi">5</span><span class="n">d</span>
  212. <span class="mi">2020</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">28</span> <span class="mi">21</span><span class="p">:</span><span class="mi">31</span><span class="p">:</span><span class="mi">22</span><span class="p">,</span><span class="mi">096</span><span class="p">:</span> <span class="n">STRINGTOOLS</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">41</span><span class="p">):</span> <span class="mi">5</span><span class="n">b</span> <span class="mi">27</span> <span class="mi">6</span><span class="n">d</span> <span class="mi">27</span> <span class="mi">5</span><span class="n">d</span> <span class="mi">5</span><span class="n">b</span> <span class="mi">27</span> <span class="mi">65</span> <span class="mi">27</span> <span class="mi">5</span><span class="n">d</span> <span class="mi">5</span><span class="n">b</span> <span class="mi">27</span> <span class="mi">73</span> <span class="mi">27</span> <span class="mi">5</span><span class="n">d</span> <span class="mi">5</span><span class="n">b</span> <span class="mi">27</span> <span class="mi">73</span> <span class="mi">27</span> <span class="mi">5</span><span class="n">d</span> <span class="mi">5</span><span class="n">b</span> <span class="mi">27</span> <span class="mi">61</span> <span class="mi">27</span> <span class="mi">5</span><span class="n">d</span> <span class="mi">5</span><span class="n">b</span> <span class="mi">27</span> <span class="mi">67</span> <span class="mi">27</span> <span class="mi">5</span><span class="n">d</span> <span class="mi">5</span><span class="n">b</span> <span class="mi">27</span> <span class="mi">65</span> <span class="mi">27</span> <span class="mi">5</span><span class="n">d</span> <span class="mi">5</span><span class="n">b</span> <span class="mi">27</span> <span class="mi">5</span><span class="n">c</span> <span class="mi">6</span><span class="n">e</span> <span class="mi">27</span> <span class="mi">5</span><span class="n">d</span>
  213. </pre></div>
  214. </div>
  215. <dl class="method">
  216. <dt id="stringtools.csp.csp.process">
  217. <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>
  218. <dd><p>This processes a byte out of a “stp-stream”.</p>
  219. <table class="docutils field-list" frame="void" rules="none">
  220. <col class="field-name" />
  221. <col class="field-body" />
  222. <tbody valign="top">
  223. <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>
  224. </tr>
  225. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">A list of the extracted message(s)</td>
  226. </tr>
  227. <tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body">list</td>
  228. </tr>
  229. </tbody>
  230. </table>
  231. </dd></dl>
  232. </dd></dl>
  233. </div>
  234. <span class="target" id="module-stringtools.stp"></span><div class="section" id="stp-serial-transfer-protocol">
  235. <h2>stp (Serial transfer protocol)<a class="headerlink" href="#stp-serial-transfer-protocol" title="Permalink to this headline">¶</a></h2>
  236. <p><strong>Author:</strong></p>
  237. <ul class="simple">
  238. <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>
  239. </ul>
  240. <p><strong>Description:</strong></p>
  241. <blockquote>
  242. <div>This module is a submodule of <a class="reference internal" href="#module-stringtools" title="stringtools"><code class="xref py py-mod docutils literal"><span class="pre">stringtools</span></code></a> and creates an serial frame to transmit and receive messages via an serial interface.</div></blockquote>
  243. <p><strong>Submodules:</strong></p>
  244. <ul class="simple">
  245. <li><a class="reference internal" href="#stringtools.stp.stp" title="stringtools.stp.stp"><code class="xref py py-class docutils literal"><span class="pre">stringtools.stp.stp</span></code></a></li>
  246. <li><a class="reference internal" href="#stringtools.stp.build_frame" title="stringtools.stp.build_frame"><code class="xref py py-func docutils literal"><span class="pre">stringtools.stp.build_frame()</span></code></a></li>
  247. </ul>
  248. <dl class="data">
  249. <dt id="stringtools.stp.DATA_CLEAR_BUFFER">
  250. <code class="descclassname">stringtools.stp.</code><code class="descname">DATA_CLEAR_BUFFER</code><em class="property"> = '&lt;'</em><a class="headerlink" href="#stringtools.stp.DATA_CLEAR_BUFFER" title="Permalink to this definition">¶</a></dt>
  251. <dd><p>The clear buffer byte (‘\x3a\x3c’ -&gt; start of message)</p>
  252. </dd></dl>
  253. <dl class="data">
  254. <dt id="stringtools.stp.DATA_STORE_SYNC_VALUE">
  255. <code class="descclassname">stringtools.stp.</code><code class="descname">DATA_STORE_SYNC_VALUE</code><em class="property"> = '='</em><a class="headerlink" href="#stringtools.stp.DATA_STORE_SYNC_VALUE" title="Permalink to this definition">¶</a></dt>
  256. <dd><p>The store sync value byte (‘\x3a\x3d’ -&gt; ‘\x3a’ inside a message)</p>
  257. </dd></dl>
  258. <dl class="data">
  259. <dt id="stringtools.stp.DATA_SYNC">
  260. <code class="descclassname">stringtools.stp.</code><code class="descname">DATA_SYNC</code><em class="property"> = ':'</em><a class="headerlink" href="#stringtools.stp.DATA_SYNC" title="Permalink to this definition">¶</a></dt>
  261. <dd><p>The data sync byte</p>
  262. </dd></dl>
  263. <dl class="data">
  264. <dt id="stringtools.stp.DATA_VALID_MSG">
  265. <code class="descclassname">stringtools.stp.</code><code class="descname">DATA_VALID_MSG</code><em class="property"> = '&gt;'</em><a class="headerlink" href="#stringtools.stp.DATA_VALID_MSG" title="Permalink to this definition">¶</a></dt>
  266. <dd><p>The valid message byte (‘\x3a\x3e’ -&gt; end of message)</p>
  267. </dd></dl>
  268. <dl class="data">
  269. <dt id="stringtools.stp.STP_STATE_ESCAPE_1">
  270. <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>
  271. <dd><p>Escape 1 state definition (‘\x3a\x3c’ found)</p>
  272. </dd></dl>
  273. <dl class="data">
  274. <dt id="stringtools.stp.STP_STATE_ESCAPE_2">
  275. <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>
  276. <dd><p>Escape 2 state definition (‘\x3a’ found inside a message)</p>
  277. </dd></dl>
  278. <dl class="data">
  279. <dt id="stringtools.stp.STP_STATE_IDLE">
  280. <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>
  281. <dd><p>Idle state definition (default)</p>
  282. </dd></dl>
  283. <dl class="data">
  284. <dt id="stringtools.stp.STP_STATE_STORE_DATA">
  285. <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>
  286. <dd><p>Store data state definition (start of message found; data will be stored)</p>
  287. </dd></dl>
  288. <dl class="function">
  289. <dt id="stringtools.stp.build_frame">
  290. <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>
  291. <dd><p>This Method builds an “stp-frame” to be transfered via a stream.</p>
  292. <table class="docutils field-list" frame="void" rules="none">
  293. <col class="field-name" />
  294. <col class="field-body" />
  295. <tbody valign="top">
  296. <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>
  297. </tr>
  298. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">The “stp-framed” message to be sent</td>
  299. </tr>
  300. <tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body">str</td>
  301. </tr>
  302. </tbody>
  303. </table>
  304. <p><strong>Example:</strong></p>
  305. <div class="highlight-default"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">stringtools</span>
  306. <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>
  307. </pre></div>
  308. </div>
  309. <p>Will result to the following output:</p>
  310. <div class="highlight-default"><div class="highlight"><pre><span></span><span class="sa">b</span><span class="s1">&#39;:&lt;:=message:=:&gt;&#39;</span>
  311. </pre></div>
  312. </div>
  313. </dd></dl>
  314. <dl class="class">
  315. <dt id="stringtools.stp.stp">
  316. <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>
  317. <dd><p>This class extracts messages from an “stp-stream”.</p>
  318. <p><strong>Example:</strong></p>
  319. <div class="highlight-default"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">report</span>
  320. <span class="kn">import</span> <span class="nn">stringtools</span>
  321. <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="n">stringtools</span><span class="o">.</span><span class="n">logger_name</span><span class="p">,</span> <span class="s1">&#39;DEBUG&#39;</span><span class="p">),</span> <span class="p">])</span>
  322. <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>
  323. <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>
  324. <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>
  325. <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>
  326. <span class="nb">print</span><span class="p">(</span><span class="n">data</span><span class="p">)</span>
  327. </pre></div>
  328. </div>
  329. <p>Will result to the following output:</p>
  330. <div class="highlight-default"><div class="highlight"><pre><span></span><span class="mi">2020</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">28</span> <span class="mi">21</span><span class="p">:</span><span class="mi">38</span><span class="p">:</span><span class="mi">27</span><span class="p">,</span><span class="mi">329</span><span class="p">:</span> <span class="n">STRINGTOOLS</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>
  331. <span class="mi">2020</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">28</span> <span class="mi">21</span><span class="p">:</span><span class="mi">38</span><span class="p">:</span><span class="mi">27</span><span class="p">,</span><span class="mi">329</span><span class="p">:</span> <span class="n">STRINGTOOLS</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>
  332. <span class="mi">2020</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">28</span> <span class="mi">21</span><span class="p">:</span><span class="mi">38</span><span class="p">:</span><span class="mi">27</span><span class="p">,</span><span class="mi">329</span><span class="p">:</span> <span class="n">STRINGTOOLS</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>
  333. <span class="mi">2020</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">28</span> <span class="mi">21</span><span class="p">:</span><span class="mi">38</span><span class="p">:</span><span class="mi">27</span><span class="p">,</span><span class="mi">329</span><span class="p">:</span> <span class="n">STRINGTOOLS</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>
  334. <span class="mi">2020</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">28</span> <span class="mi">21</span><span class="p">:</span><span class="mi">38</span><span class="p">:</span><span class="mi">27</span><span class="p">,</span><span class="mi">329</span><span class="p">:</span> <span class="n">STRINGTOOLS</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>
  335. <span class="mi">2020</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">28</span> <span class="mi">21</span><span class="p">:</span><span class="mi">38</span><span class="p">:</span><span class="mi">27</span><span class="p">,</span><span class="mi">329</span><span class="p">:</span> <span class="n">STRINGTOOLS</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>
  336. <span class="mi">2020</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">28</span> <span class="mi">21</span><span class="p">:</span><span class="mi">38</span><span class="p">:</span><span class="mi">27</span><span class="p">,</span><span class="mi">329</span><span class="p">:</span> <span class="n">STRINGTOOLS</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>
  337. <span class="mi">2020</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">28</span> <span class="mi">21</span><span class="p">:</span><span class="mi">38</span><span class="p">:</span><span class="mi">27</span><span class="p">,</span><span class="mi">329</span><span class="p">:</span> <span class="n">STRINGTOOLS</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>
  338. <span class="mi">2020</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">28</span> <span class="mi">21</span><span class="p">:</span><span class="mi">38</span><span class="p">:</span><span class="mi">27</span><span class="p">,</span><span class="mi">329</span><span class="p">:</span> <span class="n">STRINGTOOLS</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>
  339. <span class="p">[</span><span class="sa">b</span><span class="s1">&#39;:message:&#39;</span><span class="p">]</span>
  340. </pre></div>
  341. </div>
  342. <dl class="method">
  343. <dt id="stringtools.stp.stp.process">
  344. <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>
  345. <dd><p>This processes a byte out of a “stp-stream”.</p>
  346. <table class="docutils field-list" frame="void" rules="none">
  347. <col class="field-name" />
  348. <col class="field-body" />
  349. <tbody valign="top">
  350. <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>
  351. </tr>
  352. <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>
  353. </tr>
  354. <tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body">str</td>
  355. </tr>
  356. </tbody>
  357. </table>
  358. </dd></dl>
  359. </dd></dl>
  360. </div>
  361. <div class="toctree-wrapper compound">
  362. </div>
  363. </div>
  364. <div class="section" id="indices-and-tables">
  365. <h1>Indices and tables<a class="headerlink" href="#indices-and-tables" title="Permalink to this headline">¶</a></h1>
  366. <ul class="simple">
  367. <li><a class="reference internal" href="genindex.html"><span class="std std-ref">Index</span></a></li>
  368. <li><a class="reference internal" href="py-modindex.html"><span class="std std-ref">Module Index</span></a></li>
  369. <li><a class="reference internal" href="search.html"><span class="std std-ref">Search Page</span></a></li>
  370. </ul>
  371. </div>
  372. </div>
  373. </div>
  374. </div>
  375. <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
  376. <div class="sphinxsidebarwrapper"><div class="relations">
  377. <h3>Related Topics</h3>
  378. <ul>
  379. <li><a href="#">Documentation overview</a><ul>
  380. </ul></li>
  381. </ul>
  382. </div>
  383. <div id="searchbox" style="display: none" role="search">
  384. <h3>Quick search</h3>
  385. <form class="search" action="search.html" method="get">
  386. <div><input type="text" name="q" /></div>
  387. <div><input type="submit" value="Go" /></div>
  388. <input type="hidden" name="check_keywords" value="yes" />
  389. <input type="hidden" name="area" value="default" />
  390. </form>
  391. </div>
  392. <script type="text/javascript">$('#searchbox').show(0);</script>
  393. </div>
  394. </div>
  395. <div class="clearer"></div>
  396. </div>
  397. <div class="footer">
  398. &copy;2019, Dirk Alders.
  399. |
  400. Powered by <a href="http://sphinx-doc.org/">Sphinx 1.6.7</a>
  401. &amp; <a href="https://github.com/bitprophet/alabaster">Alabaster 0.7.8</a>
  402. |
  403. <a href="_sources/index.rst.txt"
  404. rel="nofollow">Page source</a>
  405. </div>
  406. </body>
  407. </html>