title: Convert a string to an 8-bit signed integer in python
body: <p>I'm trying to patch together a motor control system using python and ctypes and one of the things I need to do is take an text input and convert it to an 8-bit signed integer.</p>
  
  <p>Below is the documentation for the function I'm trying to call. The text that should be input into the program is 'EPOS2'</p>
  
  <p><img src="https://i.stack.imgur.com/w1eQo.jpg" alt="enter image description here"></p>
  
  <p>The data type definition is as shown below (note that 'char*' equates to an 8-bit signed integer)</p>
  
  <p><img src="https://i.stack.imgur.com/eRXrs.jpg" alt="enter image description here"></p>
  
  <p>So How do I convert 'EPOS2' to a value between -128 and 127?</p>
  
  <p>Ultimately what I'm trying to do is something like this:</p>
  
  <pre><code>import ctypes #import the module
  
  lib=ctypes.WinDLL(example.dll) #load the dll
  
  VCS_OpenDevice=lib['VCS_OpenDevice'] #pull out the function
  
  #per the parameters below, each input is expecting (as i understand it) 
  #an 8-bit signed integer (or pointer to an array of 8 bit signed integers, 
  #not sure how to implement that)
  VCS_OpenDevice.argtypes=[ctypes.c_int8, ctypes.c_int8, ctypes.c_int8, ctypes.c_int8]
  
  #create parameters for my inputs
  DeviceName ='EPOS2'
  ProtocolStackName = 'MAXON SERIAL V2'
  InterfaceName = 'USB'
  PortName = 'USB0'
  
  
  #convert strings to signed 8-bit integers (or pointers to an array of signed 8-bit integers)
  #code goes here
  #code goes here
  #code goes here
  
  #print the function with my new converted input parameters
  
  
  print VCS_OpenDevice(DeviceName,ProtocolStackName,InterfaceName,PortName)
  </code></pre>