Skip to content

Commit 3d3ad37

Browse files
committed
Upgrade to latest version of pynetworktables
1 parent 9d8eca6 commit 3d3ad37

File tree

3 files changed

+20
-20
lines changed

3 files changed

+20
-20
lines changed

pynetworktables2js/__main__.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,14 @@
1818
import tornado.web
1919
from tornado.ioloop import IOLoop
2020

21-
from networktables import NetworkTable
21+
from networktables import NetworkTables
2222
from . import get_handlers, NonCachingStaticFileHandler
2323

24+
try:
25+
from .version import __version__
26+
except ImportError:
27+
__version__ = '__master__'
28+
2429
import logging
2530
logger = logging.getLogger('dashboard')
2631

@@ -31,13 +36,14 @@ def init_networktables(options):
3136

3237
if options.dashboard:
3338
logger.info("Connecting to networktables in Dashboard mode")
34-
NetworkTable.setDashboardMode()
39+
NetworkTables.setDashboardMode()
3540
else:
3641
logger.info("Connecting to networktables at %s", options.robot)
37-
NetworkTable.setIPAddress(options.robot)
38-
NetworkTable.setClientMode()
42+
NetworkTables.setIPAddress(options.robot)
43+
NetworkTables.setClientMode()
3944

40-
NetworkTable.initialize()
45+
NetworkTables.setNetworkIdentity(options.identity)
46+
NetworkTables.initialize()
4147
logger.info("Networktables Initialized")
4248

4349

@@ -58,6 +64,9 @@ def main():
5864
parser.add_option('--dashboard', default=False, action='store_true',
5965
help='Use this instead of --robot to receive the IP from the driver station. WARNING: It will not work if you are not on the same host as the DS!')
6066

67+
parser.add_option('--identity', default='pynetworktables2js %s' % __version__,
68+
help='Identity to broadcast to remote NT clients')
69+
6170
options, args = parser.parse_args()
6271

6372
# Setup logging

pynetworktables2js/nt_serial.py

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,7 @@ def __init__(self, update_callback):
2020
self.update_callback = update_callback
2121
self.nt = NetworkTable.getGlobalTable()
2222
NetworkTable.addGlobalListener(self._nt_on_change, immediateNotify=True)
23-
24-
class Empty:
25-
pass
26-
self.conn_listener = Empty()
27-
self.conn_listener.connected = self._nt_connected
28-
self.conn_listener.disconnected = self._nt_disconnected
29-
30-
self.nt.addConnectionListener(self.conn_listener, immediateNotify=True)
23+
self.nt.addConnectionListener(self._nt_connected, immediateNotify=True)
3124

3225
def process_update(self, update):
3326
"""Process an incoming update from a remote NetworkTables"""
@@ -45,15 +38,13 @@ def _nt_on_change(self, key, value, isNew):
4538
self._send_update({'k': key, 'v': value, 'n': isNew})
4639

4740
# NetworkTables connection listener callbacks
48-
def _nt_connected(self, table):
49-
self._send_update({'r': True, 'a': self.nt.getRemoteAddress()})
41+
def _nt_connected(self, connected, info):
42+
self._send_update({'r': connected, 'a': self.nt.getRemoteAddress()})
5043

51-
def _nt_disconnected(self, table):
52-
self._send_update({'r': False, 'a': None})
5344

5445
def close(self):
5546
"""
5647
Clean up NetworkTables listeners
5748
"""
5849
NetworkTable.removeGlobalListener(self._nt_on_change)
59-
self.nt.removeConnectionListener(self.conn_listener)
50+
self.nt.removeConnectionListener(self.conn_listener)

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
setup(
4343
name='pynetworktables2js',
4444
version=__version__,
45-
description='RobotPy web-based low fidelity FRC robot simulation package',
45+
description='Forwards NetworkTables traffic to a web page via a Websocket',
4646
long_description=long_description,
4747
author='RobotPy Development Team',
4848
author_email='[email protected]',
@@ -53,7 +53,7 @@
5353
zip_safe=False,
5454
install_requires=[
5555
'tornado>=4.0',
56-
'pynetworktables>=2015.3.2'
56+
'pynetworktables>=2017.0.0a1'
5757
],
5858
entry_points={'console_scripts': [ 'pynetworktables2js = pynetworktables2js.__main__:main' ]},
5959
license="BSD License",

0 commit comments

Comments
 (0)