Hardware


Controller to sniffer packets from RS232 cable

Characteristic:

● Sniff both RS232 TXD/RXD signals
● Split into packets according to specific timeout setting
● USB Type-C socket

Connection:

● Connect upward/downward cable with two DB9 connectors
● Connect USB to PC

Software

Serial Communication FAQ
C Programming FAQ

Serial command:

Sniffer control command:
=>sniff --help
usage: sniff [-C] [-b ] [-i ]
options:
 -C/--ascii      ascii mode
 -b/--baudrate   default 9600
 -i/--interval   default 1(tick)
=> 

Example:

Modify baudrate to 115200bps (default 9600) and sniff:
=>sniff -b 115200
0:02:43.216>2A49444E3F0A
0:02:43.224<4B4F524144204B4133303035502056352E3520534E3A31363037323637300A
0:02:43.268>5354415455533F0A
0:02:43.280<020A
0:02:43.296>56534554313A352E30300A49534554313A352E30300A4F5554310A56534554313F0A
0:02:43.336<30352E30300A
0:02:43.348>49534554313F0A
0:02:43.356<352E3030300A
0:02:43.368>564F5554313F0A
0:02:43.380<30322E38380A
0:02:43.392>494F5554313F0A
0:02:43.404<302E3035360A
0:02:43.416>564F5554313F0A
0:02:43.428<30322E38380A
0:02:43.440>494F5554313F0A
0:02:43.448<302E3035360A
0:02:43.460>564F5554313F0A
0:02:43.472<30352E30300A
0:02:43.484>494F5554313F0A
...
RXD/TXD packets are cut into packets by default timeout setting and printed out in HEX format,
timestamp and data are split with arrow which indicates direction.
Use ShellLab Testbench App to parse and virtualize data in real-time.

Shell Lab Testbench Application


USB VCP Driver(Windows)


Application

Sniff and log to file in Shell Lab Testbench Applicationdownload
# runs in ShellLab Testbench Application
# rs232 sniff and log to file
ts = time.strftime('%y%m%d_%H%M')
LOGFILE = 'sniffer_%s.log'% ts
LOGFLUSH_PERIOD = 5  # sec
s = ShellLab(PORT)
log = None
log = open(LOGFILE,'w+')
getLogPanel(clear=True, switch=True)
s.writeLine('sniff -b 9600')
s.readLine()  # read feedback command
t0 = time.time()
while True:
    line = s.readLine()
    if line:
        logAdd(line, 'raw')
        if log:
            log.write(line)
            log.write('\n')
            if time.time() > t0:
                log.flush()
                t0 = time.time()
    else:
        time.sleep(0.1)