title: Converting hex values in buffer to integer
body: <p><strong>Background:</strong> I'm using node.js to get the volume setting from a device via serial connection. I need to obtain this data as an integer value.</p>
  
  <p>I have the data in a buffer ('buf'), and am using readInt16BE() to convert to an int, as follows:</p>
  
  <pre><code>console.log( buf )
  console.log( buf.readInt16BE(0) )
  </code></pre>
  
  <p>Which gives me the following output as I adjust the external device:</p>
  
  <pre><code>&lt;Buffer 00 7e&gt;
  126
  &lt;Buffer 00 7f&gt;
  127
  &lt;Buffer 01 00&gt;
  256
  &lt;Buffer 01 01&gt;
  257
  &lt;Buffer 01 02&gt;
  258
  </code></pre>
  
  <p><strong>Problem:</strong> All looks well until we reach 127, then we take a jump to 256. Maybe it's something to do with signed and unsigned integers - I don't know!</p>
  
  <p>Unfortunately I have very limited documentation about the external device, I'm having to reverse engineer it! Is it possible it only sends a 7-bit value? Hopefully there is a way around this?</p>
  
  <p>Regarding a solution - I must also be able to convert back from int to this format!</p>
  
  <p><strong>Question:</strong> How can I create a sequential range of integers when 7F seems to be the largest value my device sends, which causes a big jump in my integer scale?</p>
  
  <p>Thanks :)</p>