Serial Port (COM) Sniffer

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
userXeo1
Posts: 39
Joined: 26 Feb 2020, 09:12

Serial Port (COM) Sniffer

Post by userXeo1 » 04 May 2021, 23:15

Hello, I have AHK code that reads COM port, however, when port is in use by application the script is not able to read. After numerous hours of research one way to do it, to forward data from one port to another COM1--->COM2 and then read it with AHK. Is AHK cabaple of performing such task. I have found solution with python:
https://pyserial.readthedocs.io/en/latest/

Code: Select all

import serial

baud_rate = 4800 #whatever baudrate you are listening to
com_port1 = '/dev/tty1' #replace with your first com port path
com_port2 = '/dev/tty2' #replace with your second com port path

listener = serial.Serial(com_port1, baudrate)
forwarder = serial.Serial(com_port2, baudrate)

while 1:
    serial_out = listener.read(size=1)
    print serial_out #or write it to a file 
    forwarder.write(serial_out)
Any thoughts?

Thank you.
User avatar
iilabs
Posts: 296
Joined: 07 Jun 2020, 16:57

Re: Serial Port (COM) Sniffer

Post by iilabs » 05 Oct 2023, 09:34

I also having difficulty trying to read serial port and not much help out there. Did you ever figure it out?
Post Reply

Return to “Ask for Help (v1)”