YACWC
This commit is contained in:
55
run_serial_monitor.py
Normal file
55
run_serial_monitor.py
Normal file
@@ -0,0 +1,55 @@
|
||||
import sigrok.core as sr
|
||||
import numpy as np
|
||||
import socket
|
||||
import uart_monitor_config as c
|
||||
|
||||
|
||||
MCAST_GRP = c.udp_grp
|
||||
MCAST_PORT = c.udp_raw_port
|
||||
MULTICAST_TTL = c.MULTICAST_TTL
|
||||
|
||||
|
||||
driver='fx2lafw'
|
||||
|
||||
context = sr.Context.create()
|
||||
devices = context.drivers[driver].scan()
|
||||
device = devices[0]
|
||||
device.open()
|
||||
|
||||
|
||||
session = context.create_session()
|
||||
session.add_device(device)
|
||||
|
||||
output_format = 'bits'
|
||||
output = context.output_formats[output_format].create_output(device)
|
||||
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDP)
|
||||
sock.setsockopt(socket.IPPROTO_IP, socket.IP_MULTICAST_TTL, MULTICAST_TTL)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def data_callback(device, packet):
|
||||
if packet.type != sr.PacketType.LOGIC:
|
||||
return
|
||||
|
||||
text = output.receive(packet)
|
||||
data = packet._payload_logic().data
|
||||
sock.sendto(data, (MCAST_GRP,MCAST_PORT))
|
||||
|
||||
|
||||
|
||||
device.config_set(sr.ConfigKey.SAMPLERATE,c.samplerate)
|
||||
session.start()
|
||||
|
||||
session.add_datafeed_callback(data_callback)
|
||||
|
||||
|
||||
|
||||
#~/sr/bin/sigrok-cli --config samplerate=500000 --driver=fx2lafw --samples 1M -P uart:baudrate=57600:tx=D0 -P uart:baudrate=9600:tx=D0 -A uart=tx-data:tx-warning
|
||||
|
||||
session.run()
|
||||
session.stop()
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user