title: How can I convert a string sent over UART to integer in python?
body: <p>I'm having difficulty converting a string I'm receiving over UART to the decimal version of it. I read in one byte with <code>port.read(1)</code> then print it</p>
  
  <pre><code>print "%s: %s" % ( time.ctime(time.time()), str)
  </code></pre>
  
  <p>This prints out the expected character that matches with the decimal value for that <a href="http://www.asciitable.com/index/asciifull.gif" rel="nofollow">ascii character</a>. I'm sending known valued between 0 and 100. My issue is I can't convert this to the decimal value and print that instead of say '*' for 42. I'm pretty sure the default encoding/decoding is correct since the integer value in C is showing the correct character when received in python.</p>
  
  <p>It may also help to mention the sender is an AVR microcontroller programmed in avr-gcc. I've messed around with decode('utf8'), decode("ISO-8859-1"), and decode("ISO-8859-2") but again I'm pretty sure this is not what I want. I've also tried converting the read value to a decimal with the int() function with no luck. I get.</p>
  
  <pre><code>ValueError: invalid literal for int() with base 10: '\xe4'
  </code></pre>