title: How to make a serial port sniffer sniffing physical port using a python
body: <p>I have a PC Software (OS: Win 64bit) that communicates with a machine via physical serial port RS232 and I want to make a sniffer for that port using a python. Please note that I am beginner to serial ports. </p>
  
  <p>I've read multiple documents and questions posted online but most of them asks to just use 3rd-party software, but I cannot do this way because raw bytes have to be decoded into string message (I have my way own of decode/encode method).</p>
  
  <p>Currently I have setup like this:</p>
  
  <pre><code>///////////////////       Physical COM1        /////////////
  // (PC) Software // &lt;------------------------&gt; // Machine //
  ///////////////////                            /////////////
  </code></pre>
  
  <p>And I want a python to output any bytes that went through COM1.</p>
  
  <p>Desired Behavior diagram (Virtual serial port has a question mark because I'm not sure if that is the right approach):</p>
  
  <pre><code>///////////////////       Physical COM1        /////////////
  // (PC) Software // &lt;------------------------&gt; // Machine //
  ///////////////////            | Virtual       /////////////
                                 | serial port?
                                 v
                          //////////////////
                          // (PC) Sniffer // (Python)
                          //////////////////
                                 | 
                                 v
                           (output bytes)
  </code></pre>
  
  <p>Those of who knows Advanced Serial Port Monitor, its "spymode" functionality is exactly what I am trying to achieve using python.</p>
  
  <p>I've tried to use com0com and PortMon but I can't find a way to configure com0com to sniff physical port (as far as my observation goes, com0com only makes virtual ports) and PortMon does not support Windows 64-bit.</p>
  
  <p>I've been stuck at this for days... any comments/links/answers are appreciated.
  Thank you,</p>