title: Dealing with uint8_t in javascript
body: <p>G'day peoples, </p>
  
  <p>I'm using MavLink to obtain GPS information. One of the message types is GPS_STATUS which is described by MavLink using a series of uint8_t[20]. </p>
  
  <p>If I run the following code:</p>
  
  <pre><code>console.log(' sat prn: ' + message.satellite_prn);
  console.log(' sat prn: ' + JSON.stringify(message.satellite_prn));
  console.log(' sat prn: ' + JSON.stringify(new Uint8Array(message.satellite_prn)));
  </code></pre>
  
  <p>I get the following output:</p>
  
  <pre><code> sat prn: &lt;weird charcaters...&gt;
   sat prn: "\u0002\u0005\n\f\u000f\u0012\u0015\u0019\u001a\u001b\u001d\u001e\u001f\u0000\u0000\u0000\u0000"
   sat prn: {"BYTES_PER_ELEMENT":1,"buffer":{"byteLength":0},"length":0,"byteOffset":0,"byteLength":0}
  </code></pre>
  
  <p>So obviously it's not working. I need a means to get the int value of each element.</p>
  
  <p>I found this <a href="https://developer.mozilla.org/en-US/docs/JavaScript/Typed_arrays?redirectlocale=en-US&amp;redirectslug=JavaScript_typed_arrays" rel="nofollow">https://developer.mozilla.org/en-US/docs/JavaScript/Typed_arrays?redirectlocale=en-US&amp;redirectslug=JavaScript_typed_arrays</a></p>
  
  <p>Which made me think I would be able to do the following:</p>
  
  <pre><code>satellite_prn = Array.apply([], new Uint8Array(message.satellite_prn));
  satellite_prn.length === 20;
  satellite_prn.constructor === Array;
  </code></pre>
  
  <p>But when I stringify it via JSON it reports [], I presume this is an empty array.</p>
  
  <p>Anyone know how I can do this? I know that the data is an array of 20 unsigned 8 bit integers. I just need to know how to access or parse them.</p>
  
  <p>Note: I'm using node.js, but that shouldn't affect what I'm doing. This is why I'm using console.log, as it's avail in node.js.</p>