title: Calculate checksum for Laboratory Information System (LIS) frames
body: <p>I'm developing an instrument driver for a <a href="https://www.limswiki.org/index.php/Laboratory_information_system" rel="nofollow noreferrer">Laboratory Information System</a>. I want to know how to calculate the checksum of a frame.</p>
  <p>Explanation of the checksum algorithm:</p>
  <blockquote>
  <ol>
  <li><p>Expressed by characters [0-9] and [A-F].</p>
  </li>
  <li><p>Characters beginning from the character after [STX] and until [ETB] or    [ETX] (including [ETB] or [ETX]) are added in binary.</p>
  </li>
  <li><p>The 2-digit numbers, which represent the least significant 8 bits in    hexadecimal code, are converted to ASCII characters [0-9] and
  [A-F].</p>
  </li>
  <li><p>The most significant digit is stored in CHK1 and the least significant    digit in CHK2.</p>
  </li>
  </ol>
  </blockquote>
  <p>I am not getting the 3rd and 4th points above.</p>
  <p>This is a sample frame:</p>
  <pre class="lang-none prettyprint-override"><code>&lt;STX&gt;2Q|1|2^1||||20011001153000&lt;CR&gt;&lt;ETX&gt;&lt;CHK1&gt;&lt;CHK2&gt;&lt;CR&gt;&lt;LF&gt;
  </code></pre>
  <p>What is the value of <code>CHK1</code> and <code>CHK2</code>? How do I implement the given algorithm in C#?</p>