Permalink
Fetching contributors…
Cannot retrieve contributors at this time
executable file 37 lines (26 sloc) 910 Bytes
#!/usr/bin/env python3
#
# This is a NetworkTables client (eg, the DriverStation/coprocessor side).
# You need to tell it the IP address of the NetworkTables server (the
# robot or simulator).
#
# This shows how to use a listener to listen for all changes in NetworkTables
# values, which prints out all changes. Note that the keys are full paths, and
# not just individual key values.
#
import sys
import time
from networktables import NetworkTables
# To see messages from networktables, you must setup logging
import logging
logging.basicConfig(level=logging.DEBUG)
if len(sys.argv) != 2:
print("Error: specify an IP to connect to!")
exit(0)
ip = sys.argv[1]
NetworkTables.initialize(server=ip)
def valueChanged(key, value, isNew):
print("valueChanged: key: '%s'; value: %s; isNew: %s" % (key, value, isNew))
NetworkTables.addGlobalListener(valueChanged)
while True:
time.sleep(1)