Redirecting all data from the serial monitor to a virtual COM port would be a great feature. Since it doesn’t exist in the software (2.3.10) I’ve done it on Windows through my custom High Level Analyzer, a helper C# application and the com0com software. If anyone else also needs this, here’s the summary of what I’ve done:
- Install pywin32 to the Python first. For this, I had an independent Python38 installed on my PC and installed it to my Python through pip. Copied two DLL files “pythoncom38.dll” and “pywintypes38.dll” under site-packages\pywin32_sys to the System32 folder.
Then, added this to the top of the HLA code:
PYWIN32PATH = 'C:\\Python38\\Lib\\site-packages\\win32'
if PYWIN32PATH not in sys.path:
import win32pipe, win32file
def pipe_stream(self, data):
pipe = win32file.CreateFile("\\\\.\\pipe\\PipeServer",
0, None,win32file.OPEN_EXISTING,0, None)
some_data = data.encode('ascii')
and under decode, added this:
Then I created a virtual COM port using com0com (COM24 and COM25 in my case). Verified the COM ports were working using PuTTY.
Then, created a pipe listener on C# based on this example: https://www.codeproject.com/Articles/1199046/A-Csharp-Named-Pipe-Library-That-Supports-Multiple
in the pipe listener, I get the data from the HLA:
private static SerialPort port = new SerialPort("COM24", 115200, Parity.None, 8, StopBits.One);
static void Server()
using (var server = new NamedPipeServerStream("PipeServer"))
var reader = new StreamReader(server);
var received = reader.ReadLine();
and voila, the data is visible on PuTTY.
The drawback of this method is, the pipe cannot handle the speed of the data if the frequency of your data is too high, so some data can be lost in between. You must find some custom way to verify the integrity of your data.