title: linux writing string value to hex, difference between x86 and i368?
body: <p>relating to my post <a href="https://stackoverflow.com/questions/18654024/linux-writing-string-value-as-hex-to-serial">linux writing string value as hex to serial</a> (which was solved on a x86 System)
  I have a problem on an i368 system.
  The code works on an intel atom ubuntu system.
  But on an intel xeon with ubuntu this doesnt work anymore.</p>
  
  <p>Could that be a problem o little/big endian?</p>
  
  <p>I used the code of the mentioned post from Erik.</p>
  
  <p>I am using this method to convert  </p>
  
  <pre><code>int convert(std::string str, unsigned char*&amp; charArr)
  {
  
  
  // count the number of character pairs (i.e. bytes) in the string
  // and dynamically allocate an array of the required size
  const int numBytes = str.size() / 2;
  charArr = new unsigned char[numBytes];
  
  for (int i = 0; i &lt; numBytes; ++i)
  {
    // grab two characters from the string...
    std::string twoChars = str.substr(2 * i, 2);
  
    // ...and convert them to an integer using a stringstream
    int byte;
    std::stringstream ss(twoChars);
    ss &gt;&gt; std::hex &gt;&gt; byte;
  
    // store the result in our char array
    charArr[i] = byte;
  }
  }
  </code></pre>
  
  <p>Calling the method by  </p>
  
  <pre><code>const std::string str ="8C000002008E";
  unsigned char* toSend;
  convert(str, toSend);
  </code></pre>
  
  <p>And writing to the serial Port with:</p>
  
  <pre><code>int kWrite = write(mFd, toSend , sizeof(toSend));
  </code></pre>
  
  <p>The serial device react on the atom system, but not on the xeon.</p>
  
  <p>The response i get says: undefined format or checksum error</p>