Data Sniffer

This program is to sniff all the data from the MDB Bus using our API. This program saves the data on a text file that you can use later for analyses.

import serial
import sys
import datetime
import time




if len( sys.argv ) > 1 :

port_name = sys.argv[1]
#Open serial port
serialPort = serial.Serial(
port = port_name, baudrate=115200, bytesize=8, timeout=0.1, stopbits=serial.STOPBITS_ONE
);
last_time = 0
current_time = datetime.datetime.now() #get initial date for record file name

#create initial file
name_current_file = "REC "
if(current_time.day < 10):
name_current_file += "0"
name_current_file += str(current_time.day)
name_current_file += "-"
if(current_time.month < 10):
name_current_file += "0"
name_current_file += str(current_time.month)
name_current_file += "-"
name_current_file += str(current_time.year)

To execute the program, just copy the code above to a file "sniffer.py" or download it from here and run it like shown below.

sudo python3 sniffer.py <serial_port>


On This Page
Data Sniffer