Streaming data with Taps API
Taps are ports used to read from or write data to any node in a signal chain. Taps are created by default for non-application nodes (Broadband Node, Spectral Filter, etc.), and taps can be created at any point within a Synapse App. Taps can also be used to read data from nodes to a local client(e.g., a computer running synapse-python). To see a list of taps available on a device, run:
synapsectl -u $DEVICE_IP taps list
To receive data from a tap in the command line, run:
synapsectl -u $DEVICE_IP taps stream "your_tap_name"
Data from taps can also be read into a python script running on your client. The example snippet below receive data from a device with ip “device_ip” using a tap called "tap_name":
tap = Tap(device_ip, verbose=True)
taps = tap.list_taps()
if tap_name not in [tap.name for tap in taps]:
print(f"Tap {args.tap_name} not found")
return
tap.connect(tap_name)
for message in tap.stream():
message_size = len(str(message))
print(message, expand_all=False)