title: Python serial port listener
body: <p>I've begun writing some code using PySerial to send and receive data to a serial device.</p>
  
  <p>Up until now I've only been working on initiating a transaction from a terminal and receiving a response from the serial device.</p>
  
  <p>pseudo:</p>
  
  <pre><code>main:
      loop:
          message = get_message()
          send_to_serial(message)
          time_delay(1 second)
          read_response()
  </code></pre>
  
  <p>Now I'd like to implement a listener on that port in the case that the serial device is the one initiating the communication. Also to remove the <code>time_delay</code> which could end up way too long, or not long enough for the serial device to respond.</p>
  
  <pre><code>state = idle
  register_interrupt(serial_device, read_response())
  
  main:
      loop:
          message = get_message()
          state = sending
          send_to_serial(message)
  </code></pre>
  
  <p>So far I haven't found any PySerial code that uses an interrupt to communicate.</p>
  
  <p>I just have no idea how to set up an interrupt of any sort in python, how would </p>