Giter Site home page Giter Site logo

pynetworktables's Introduction

RobotPy: Python for FRC cRIO Robot Controller

Author

Peter Johnson, FRC Team 294

Author

Dustin Spicuzza, FRC Team 2423/1418

Copyright

Copyright © 2010, Peter Johnson, Ross Light, Dustin Spicuzza

About RobotPy

RobotPy is a distribution of Python intended to be used for the FIRST Robotics Competition. Teams can use this to write their robot code in Python, a powerful dynamic programming language.

Features

  • Python is simple to learn and easy to maintain.
  • RobotPy lets you reload code without restarting.
  • RobotPy provides access to the WPILib class library.
  • You don't need to use WindRiver (unless you're rebuilding RobotPy itself).

Installation for most people

Download the binary releases from our FIRSTForge site, unpack them, and run install.py. Download from: http://firstforge.wpi.edu/sf/projects/robotpy

Installation from Source using our build VM

Using the provided build virtual machine is the easiest way to build RobotPy from source. See build-vm/README.txt for instructions.

Installation from Source (Advanced Users Only)

Step 1: Install Python

Python 2.7.5 is known to work. Ensure that you add your python installation directory to your PATH variable.

Note: This step is required for SIP installation

Step 2: Install SIP v4.15.3:

The cmake build process currently checks for exact versions of SIP, as the generated code changes from release to release.

http://www.riverbankcomputing.com/static/Docs/sip4/installation.html

Note: Installation of SIP on Windows requires Visual Studio or MinGW installed, see the SIP build instructions for more details.

Step 3: Build the source tree

TODO: Update these instructions for Windows too?

The RobotPy build process uses cmake to build the RobotPy distribution. frcmake is a wrapper around cmake that sets the build environment up to build for the cRio.

RobotPy currently uses the GCC 4.8 compiler distributed at the following URL to build the binary distribution. Wind River may be used, but we haven't built it with Wind River, so you may run into trouble using it with frcmake.

http://firstforge.wpi.edu/sf/projects/c--11_toochain

Create a directory (the 'binary directory') outside of the RobotPy source tree, and run this:

$ frcmake /path/to/robotpy

Once you've done this, you can build the code:

$ make

To copy the build output to the 'dist' directory, run this command from your binary directory:

$ make install

To build a binary release, just run the following command and a zip file will be created in your build directory.

$ make package

Step 4: Robot Installation

From the 'dist' directory inside of your binary directory, run install.py

Alternatively, you can FTP the contents of the 'robot' directory to your cRio directly. However, install.py is easier.

Development tools

See the utilities directory for useful development tools that may make your RobotPy development experience easier.

The pyfrc python package is a recommended development package that provides unit testing and other capabilities for your robot code.

https://github.com/robotpy/pyfrc

Technical Overview

RobotPy is a packaging of a patched Python 3.2 interpreter (found in the RobotPy/Python subdirectory of the source code). All access to the WPILib is generated by a SIP interface, which is found in Packages/wpilib/sip/. When the robot is started, it initializes the Python interpreter and runs the file py/boot.py. From there, all responsibility is given to the boot.py script, which is referred to as the bootloader.

If boot.py ever exits (due to an exception, for example), the C++ code exits. The default boot.py simply exits on any user exception. If this happens, you can reboot easily via NetConsole by simply typing "reboot" followed by hitting the enter key. This is how code reloads are performed. As boot.py is written in Python, this behavior can be customized as desired.

Major Differences from standard Python

  • Several Python modules with large and/or incompatible dependencies removed, namely: curses, dbm, gdbm, tkinter, nis, ossaudiodev, resource, spwd, syslog, termios, audioop, bz2, crypt, grp, ssl, pwd, and mmap.

Licensing

A brief overview of licensing terms:

If you redistribute RobotPy and add other libraries, please include their licensing information here.

RobotPy

Copyright © 2010 Peter Johnson

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

pynetworktables's People

Contributors

ariovistus avatar arthurallshire avatar auscompgeek avatar chauser avatar computer-whisperer avatar lethosor avatar peterjohnson avatar thadhouse avatar thetriplev avatar virtuald avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pynetworktables's Issues

pynetworktables initialize throws errors about utf-8 encoding

I tried this:

logging.basicConfig(level=logging.DEBUG)
NetworkTables.initialize(server="10.6.66.5")

And got this:

INFO:nt:NetworkTables initialized in client mode
DEBUG:nt.th:Started thread nt-dispatch-thread-0
DEBUG:nt.th:Started thread nt-client-thread-0
DEBUG:nt:client connected
DEBUG:nt.th:Started thread nt-net-write-0
DEBUG:nt.th:Started thread nt-net-read-0
ERROR:nt:Unhandled exception during handshake
Traceback (most recent call last):
  File "C:\Users\peter\Anaconda3\lib\site-packages\ntcore\network_connection.py", line 248, in _readThreadMain
    handshake_success = self.m_handshake(self, _getMessage, self._sendMessages)
  File "C:\Users\peter\Anaconda3\lib\site-packages\ntcore\dispatcher.py", line 571, in _clientHandshake
    msg = get_msg()
  File "C:\Users\peter\Anaconda3\lib\site-packages\ntcore\network_connection.py", line 236, in _getMessage
    return Message.read(self.m_stream, decoder, self.m_get_entry_type)
  File "C:\Users\peter\Anaconda3\lib\site-packages\ntcore\message.py", line 123, in read
    value = codec.read_value(value_type, rstream)
  File "C:\Users\peter\Anaconda3\lib\site-packages\ntcore\wire.py", line 114, in read_value
    return Value.makeString(self.read_string(rstream))
  File "C:\Users\peter\Anaconda3\lib\site-packages\ntcore\wire.py", line 199, in read_string_v3
    return rstream.read(slen).decode('utf-8')
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xea in position 9: invalid continuation byte
INFO:nt:DISCONNECTED 10.6.66.5 port 1735 (Robot)
DEBUG:nt.th:Thread nt-net-read-0 exited
DEBUG:nt.th:Thread nt-net-write-0 exited

Sometimes not connecting over FMS

In many matches, we've seen our vision system and other important variables drop out, and I now think I've figured out that this is due to pynetworktables (NT v3.0) not working. Indeed, during one match, I could see that isConnected() was continually reading false. The interesting thing is that in some matches it works and some matches it doesn't. When not connecting via FMS, it always works.

Since the LabVIEW dashboard was successfully showing network tables variables, I can conclude that this problem is one specific to pynetworktables.

Server connection thread probably hangs

It's very difficult to reproduce this bug, but we've seen it happen with multiple computers connected to the robot wireless. My suspicion is that the socket.settimeout that is commented out in SocketServerStreamProvider is the culprit. Unfortunately, that doesn't work in python 2.7, so I'm loathe to uncomment it. However, I suspect nobody runs NetworkTable servers using python 2.7...

The good news is that the robot code does not hang when this occurs -- it only disables networktables transmissions.

Unable to build pynetworktables under Linaro Ubuntu 12.04 ARM build

When running the setup command 'ROBOTPY="/home/linaro/robotpy" python setup.py', the build fails in networktables2/thread/DefaultThreadManager.h. The relevant terminal output is as follows:

/home/linaro/robotpy/Packages/wpilib/WPILib/networktables2/thread/DefaultThreadManager.h: In member function ‘virtual NTThread\* sipDefaultThreadManager::newBlockingPeriodicThread(PeriodicRunnable_, const char_)’: /home/linaro/robotpy/Packages/wpilib/WPILib/networktables2/thread/DefaultThreadManager.h:23:20: error: ‘virtual NTThread\* DefaultThreadManager::newBlockingPeriodicThread(PeriodicRunnable_, const char_)’ is private build/temp.linux-armv7l-2.7/sippynetworktablesDefaultThreadManager.cpp:68:69: error: within this context /home/linaro/robotpy/Packages/wpilib/WPILib/networktables2/thread/DefaultThreadManager.h: In function ‘PyObject\* meth_DefaultThreadManager_newBlockingPeriodicThread(PyObject_, PyObject_)’: /home/linaro/robotpy/Packages/wpilib/WPILib/networktables2/thread/DefaultThreadManager.h:23:20: error: ‘virtual NTThread\* DefaultThreadManager::newBlockingPeriodicThread(PeriodicRunnable_, const char_)’ is private build/temp.linux-armv7l-2.7/sippynetworktablesDefaultThreadManager.cpp:95:100: error: within this context /home/linaro/robotpy/Packages/wpilib/WPILib/networktables2/thread/DefaultThreadManager.h:23:20: error: ‘virtual NTThread\* DefaultThreadManager::newBlockingPeriodicThread(PeriodicRunnable_, const char_)’ is private build/temp.linux-armv7l-2.7/sippynetworktablesDefaultThreadManager.cpp:95:143: error: within this context error: command 'gcc' failed with exit status 1

Adding 'public' to line 48 of DefaultThreadManager.cpp and 'public:' to line 23 of DefaultThreadManager.h
resolves these errors but the build still fails:

/home/linaro/robotpy/Packages/wpilib/WPILib/networktables2/connection/../IncomingEntryReceiver.h:17:1: error: ‘class IncomingEntryReceiver IncomingEntryReceiver::IncomingEntryReceiver’ is inaccessible build/temp.linux-armv7l-2.7/sippynetworktablesServerConnectionAdapter.cpp:42:73: error: within this context /home/linaro/robotpy/Packages/wpilib/WPILib/networktables2/connection/../IncomingEntryReceiver.h: In constructor ‘sipServerConnectionAdapter::sipServerConnectionAdapter(IOStream*, ServerNetworkTableEntryStore&, IncomingEntryReceiver&, ServerAdapterManager&, NetworkTableEntryTypeManager&, NTThreadManager&)’: /home/linaro/robotpy/Packages/wpilib/WPILib/networktables2/connection/../IncomingEntryReceiver.h:17:1: error: ‘class IncomingEntryReceiver IncomingEntryReceiver::IncomingEntryReceiver’ is inaccessible build/temp.linux-armv7l-2.7/sippynetworktablesServerConnectionAdapter.cpp:71:205: error: within this context error: command 'gcc' failed with exit status 1

NetworkTables crashed

Exception in thread Server Connection Reader Thread:
Traceback (most recent call last):
  File "/usr/local/lib/python3.4/threading.py", line 921, in _bootstrap_inner
    self.run()
  File "/usr/local/lib/python3.4/site-packages/networktables2/connection.py", line 188, in run
    self.connection.read(self.adapter)
  File "/usr/local/lib/python3.4/site-packages/networktables2/connection.py", line 141, in read
    adapter.clientHello(protocolRevision)
  File "/usr/local/lib/python3.4/site-packages/networktables2/server.py", line 113, in clientHello
    self.entryStore.sendServerHello(self.connection)
  File "/usr/local/lib/python3.4/site-packages/networktables2/server.py", line 199, in sendServerHello
    connection.sendEntryAssignment(entry)
  File "/usr/local/lib/python3.4/site-packages/networktables2/connection.py", line 126, in sendEntryAssignment
    entry.getId(), entry.getSequenceNumber())
  File "/usr/local/lib/python3.4/site-packages/networktables2/connection.py", line 47, in send
    wstream.write(self.STRUCT.pack(*args))
struct.error: 'H' format requires 0 <= number <= 65535

UnicodeDecodeError trying to connect to Network Tables on roboRIO (Java) from raspberry pi with Microsoft Lifecam

UnicodeDecodeError trying to connect to Network Tables on roboRIO (Java) from Raspberry Pi with Microsoft Lifecam plugged into roboRIO.

>>> import logging
>>> logging.basicConfig(level=logging.DEBUG)
>>> from networktables import NetworkTables as NT
>>> NT.initialize('10.35.28.32')
INFO:nt:NetworkTables 2017.0.4 initialized in client mode
>>> DEBUG:nt:client connected
ERROR:nt:Unhandled exception during handshake
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/ntcore/network_connection.py", line 240, in _readThreadMain
    handshake_success = self.m_handshake(self, _getMessage, self._sendMessages)
  File "/usr/local/lib/python2.7/dist-packages/ntcore/dispatcher.py", line 488, in _clientHandshake
    msg = get_msg()
  File "/usr/local/lib/python2.7/dist-packages/ntcore/network_connection.py", line 228, in _getMessage
    return Message.read(self.m_stream, decoder, self.m_get_entry_type)
  File "/usr/local/lib/python2.7/dist-packages/ntcore/message.py", line 123, in read
    value = codec.read_value(value_type, rstream)
  File "/usr/local/lib/python2.7/dist-packages/ntcore/wire.py", line 126, in read_value
    return Value.makeStringArray([self.read_string(rstream) for _ in range(alen)])
  File "/usr/local/lib/python2.7/dist-packages/ntcore/wire.py", line 198, in read_string_v3
    return rstream.read(slen).decode('utf-8')
  File "/usr/lib/python2.7/encodings/utf_8.py", line 16, in decode
    return codecs.utf_8_decode(input, errors, True)
UnicodeDecodeError: 'utf8' codec can't decode byte 0xf0 in position 61: invalid continuation byte
INFO:nt:DISCONNECTED 10.35.28.32 port 1735 (Robot)

'ClientNetworkTableEntryStore' object has no attribute 'mutex'

ERROR:nt:Exception in valueChanged callback!
Traceback (most recent call last):
  File "/usr/lib/python3.4/site-packages/networktables2/networktablenode.py", line 159, in fireTableListeners
    listener.valueChanged(None, key, value, isNew)
  File "/usr/lib/python3.4/site-packages/networktables/__init__.py", line 86, in valueChanged
    value, isNew)
  File "/home/christian/PycharmProjects/RoboRIO-webdash/webdash/networktables_controller.py", line 50, in val_listener
    target_ref[key] = source.getValue(key)
  File "/usr/lib/python3.4/site-packages/networktables/__init__.py", line 619, in getValue
    return self.node.getValue(self.absoluteKeyCache.get(key))
  File "/usr/lib/python3.4/site-packages/networktables2/networktablenode.py", line 107, in getValue
    with self.entryStore.mutex:
AttributeError: 'ClientNetworkTableEntryStore' object has no attribute 'mutex'

It seems that neither ClientNetworkTableEntryStore object, nor any parent classes, ever initialize a mutex object. The AbstractNetworkTableEntryStore object does initialize an entry_lock object, but i'm not sure if that is supposed to be for a different function.

Add cache for getEntry

We left it out at some point, but the WPILib API uses it extensively so we should probably do this too.

Client not auto-connecting to server in an... unusual environment

I'm trying to use pynetworktables in a very strange threading environment (eventlet). Everything works fine, except that it doesn't connect to a NetworkTables server if the server is started after the client program.
It connects properly and works fine if the server process is started first.
I know this isn't a normal use-case, so I'm not sure whether or not to call it a bug. Is there a command I can call to force the library to check for a connection?

'EntryNotification' object has no attribute 'getEntry'

I've been continuously getting these errors in the DS console. Nothing appears to be failing, but it makes it really hard to debug other code since they fill up the console after a crash.

 09:33:51:575 WARNING : nt                  : Unhandled exception processing entry-notifier callback 
 Traceback (most recent call last): 
   File "/usr/local/lib/python3.6/site-packages/ntcore/callback_manager.py", line 116, in main 
     self.doCallback(listener.callback, item) 
   File "/usr/local/lib/python3.6/site-packages/ntcore/entry_notifier.py", line 79, in doCallback 
     callback(data) 
   File "/usr/local/lib/python3.6/site-packages/cscore/cameraserver.py", line 367, in _onTableChange 
     event.getEntry().setNumber(prop.get()) 
 AttributeError: 'EntryNotification' object has no attribute 'getEntry'

Connection Problem with Python 2.7 and 2016.0.0a2 Release

Started testing possibly using on our NVIDIA Jetson and am getting this error. Testing with other machines also throws this error with Python 2.7, but everything works with Python 3.5. Any ideas how I can fix this? I can add any additional information that may be useful.

root@tegra-ubuntu:/home/ubuntu/Desktop/Code/2016-Robot-Code/Vision/main# python networkTest.py
INFO:nt:Client 0xb601e918 entered connection state: CONNECTED_TO_SERVER
Exception in thread Client Connection Reader Thread:
Traceback (most recent call last):
  File "/usr/lib/python2.7/threading.py", line 810, in __bootstrap_inner
    self.run()
  File "/usr/lib/python2.7/threading.py", line 763, in run
    self.__target(*self.__args, **self.__kwargs)
  File "/usr/local/lib/python2.7/dist-packages/networktables2/connection.py", line 194, in run
    self.connection.read(self.adapter)
  File "/usr/local/lib/python2.7/dist-packages/networktables2/connection.py", line 102, in read
    serverName, (flags,) = SERVER_HELLO.read(self.rstream)
  File "/usr/local/lib/python2.7/dist-packages/networktables2/messages.py", line 71, in read
    nameLen = leb128.read_uleb128(rstream)
  File "/usr/local/lib/python2.7/dist-packages/networktables2/leb128.py", line 18, in read_uleb128
    result |= (b & 0x7f) << shift
TypeError: unsupported operand type(s) for &: 'str' and 'int'

Problem running pynetworktables in python 2.7 with unicode characters

We were using a raspberrypi running network tables for communication with the roborio, but when the roborio creates a table for microsoft camera which has a special character in its description the function NetworkTables.initialize(server=ip) cannot start connection because a UnicodeEncodeError during the handshake.

The debuging return the following errors:

DEBUG:nt:client connected
DEBUG:nt:NetworkConnection stopping (<ntcore.network_connection.NetworkConnection object at 0x74469330>)
ERROR:nt:Unhandled exception during handshake
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/ntcore/network_connection.py", line 240, in _readThreadMain
    handshake_success = self.m_handshake(self, _getMessage, self._sendMessages)
  File "/usr/local/lib/python2.7/dist-packages/ntcore/dispatcher.py", line 488, in _clientHandshake
    msg = get_msg()
  File "/usr/local/lib/python2.7/dist-packages/ntcore/network_connection.py", line 228, in _getMessage
    return Message.read(self.m_stream, decoder, self.m_get_entry_type)
  File "/usr/local/lib/python2.7/dist-packages/ntcore/message.py", line 123, in read
    value = codec.read_value(value_type, rstream)
  File "/usr/local/lib/python2.7/dist-packages/ntcore/wire.py", line 114, in read_value
    return Value.makeString(self.read_string(rstream))
  File "/usr/local/lib/python2.7/dist-packages/ntcore/value.py", line 51, in makeString
    return ValueType(NT_STRING, str(value))
UnicodeEncodeError: 'ascii' codec can't encode character u'\xae' in position 9: ordinal not in range(128)
INFO:nt:DISCONNECTED roboRIO-3478-FRC.local port 1735 (Robot)
DEBUG:nt:write thread died (<ntcore.network_connection.NetworkConnection object at 0x74ce7230>)

tableserror

Crash when enabling live window

16:17:15:412 ERROR : robotpy : ---> The startCompetition() method (or methods called by it) should have handled the exception.
Traceback (most recent call last):
File "/usr/local/lib/python3.4/site-packages/wpilib/robotbase.py", line 185, in main
robot.startCompetition()
File "/usr/local/lib/python3.4/site-packages/wpilib/samplerobot.py", line 135, in startCompetition
LiveWindow.setEnabled(True)
File "/usr/local/lib/python3.4/site-packages/wpilib/livewindow.py", line 81, in setEnabled
LiveWindow.initializeLiveWindowComponents()
File "/usr/local/lib/python3.4/site-packages/wpilib/livewindow.py", line 56, in initializeLiveWindowComponents
table = LiveWindow.livewindowTable.getSubTable(c.subsystem).getSubTable(c.name)
File "/usr/local/lib/python3.4/site-packages/networktables/init.py", line 449, in getSubTable
return self.provider.getTable(self.absoluteKeyCache.get(key))
File "/usr/local/lib/python3.4/site-packages/networktables/init.py", line 342, in get
cachedValue = self.path + NetworkTable.PATH_SEPARATOR + key
TypeError: Can't convert 'int' object to str implicitly

Locals at innermost frame:

Python Network Tables with GRIP

Our team is trying out GRIP, but I can't seem to get the data that is published over network tables by it. I have successfully printed the data in C++ with something like double x = grip->GetNumberArray("ball/x", llvm::ArrayRef<double>()) (where grip is the network table and ball is a subtable). However, it doesn't seem to work in Python:

getData(): no longer seems to exist, but still in docs
getDouble(): returns TypeError: Cannot get number for '/GRIP/ball/x', is a Array of [Double]
getNumber(): returns exact same thing as getDouble().

Is there anything else I should try? I confirmed that the data is in network tables with the TableViewer utility.

Add remove listener

For example, removeWsConnectionListener, removeRobotConnectionListener, to introduce full event features.

Separate NetworkTables singleton from NetworkTable implementation

Instead of:

NetworkTable.initialize()

Do

NetworkTables.initialize()
...etc

This will separate out the static initialization code from the main table code, and it's a clearer distinction between functionality.

For backwards compatibility purposes, in 2017 the static methods in NetworkTables will be copied to the NetworkTable class, but wrapped in a deprecated decorator.

NT 3.0 support

Need to update this for NT 3.0 compatibility. WPILib Java/C++ was basically a complete rewrite, so this could be done as either a translation of that rewrite into Python or by updating this code with the NT 3.0 protocol.

Drop Python < 3.5 support

I would like to propose we drop support for Python 3.3 in 2019.

Python 3.3 is already EOL (as of September 2017), and is not distributed by major, currently supported GNU/Linux distros, so I don't anticipate this being a problem for any team.

We've already announced on CD that pynetworktables will continue to support Python 3.3 for this year, so I guess we're keeping it this way. I wouldn't imagine we'd have many more changes this year, so this probably won't be much of a problem for us anyway.

issue running as server 'read error in handshake: end of file'

platform windows 10, python3.7.2 native build, pynetworktables version 2019.0.0

in one git-bash window, i start a pynetworktables server:

networktables.NetworkTables.initialize()

in another git-bash window, I start a pynetworktables client:

networktables.NetworkTables.initialize(server="localhost")

back in the server window, i see a stream like this:

read error in handshake: end of file
read error in handshake: end of file
read error in handshake: end of file
read error in handshake: end of file
read error in handshake: end of file

fwiw: connections to robot-based server appear solid, just trying to get work done without a robot.

Use Hypothesis in tests

It would be a good idea to use Hypothesis to verify round-trips work as intended.

It would also be a good idea to write some tests to verify that we can interact with ntcore correctly.

Drop invalid UTF-8 keys

I'm not sure I want to know how the high-level NetworkTables API deals with keys that don't start with /. But I suspect users wouldn't be able to use keys like that.

We should just drop any keys that aren't valid UTF-8 (but still log a warning).

SIP Not working with this...

When i attempt to install on both Linux (Ubuntu 12.04) and Mac OS, there appears to be an issue between SIP and PyNetworkTables. Both are running Python3, however I tested on Multiple versions of SIP.

The traceback is posted below (With my username removed)

Somebody's-MacBook-Air:pynetworktables USERNAME$ ROBOTPY="../robotpy" python3 setup.py build
running build
running build_ext
building 'pynetworktables' extension
/usr/local/Cellar/sip/4.13.3/bin/sip -g -e -I /Users/USERNAME/pynetworktables/sip -I /Users/USERNAME/robotpy/Packages/wpilib/sip -c build/temp.macosx-10.8-x86_64-3.3 -b build/temp.macosx-10.8-x86_64-3.3/module.sbf -I /usr/local/share/sip /Users/USERNAME/pynetworktables/sip/module.sip
Traceback (most recent call last):
File "setup.py", line 119, in
cmdclass = {'build_ext': custom_build_ext}
File "/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/distutils/core.py", line 148, in setup
dist.run_commands()
File "/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/distutils/dist.py", line 917, in run_commands
self.run_command(cmd)
File "/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/distutils/dist.py", line 936, in run_command
cmd_obj.run()
File "/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/distutils/command/build.py", line 126, in run
self.run_command(cmd_name)
File "/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/distutils/cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/distutils/dist.py", line 936, in run_command
cmd_obj.run()
File "/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/distutils/command/build_ext.py", line 347, in run
self.build_extensions()
File "setup.py", line 101, in build_extensions
sipdistutils.build_ext.build_extensions(self)
File "/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/distutils/command/build_ext.py", line 456, in build_extensions
self.build_extension(ext)
File "/usr/local/lib/python2.7/site-packages/sipdistutils.py", line 111, in build_extension
build_ext_base.build_extension(self, ext)
File "/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/distutils/command/build_ext.py", line 483, in build_extension
sources = self.swig_sources(sources, ext)
File "/usr/local/lib/python2.7/site-packages/sipdistutils.py", line 153, in swig_sources
out = self._get_sip_output_list(sbf)
File "/usr/local/lib/python2.7/site-packages/sipdistutils.py", line 58, in _get_sip_output_list
for L in file(sbf):
NameError: global name 'file' is not defined

Sync code with 2018 updates

This may be fairly involved, there are some updates to the way ntcore does synchronization. Additionally, they changed NT to have instances instead of lots of static globals -- but we do that anyways. Still, the code will need to be reviewed and updated.

Crash

14:27:49:888 INFO    : wpilib              : WPILib version 2015.0.10
14:27:49:888 INFO    : wpilib              : HAL base version 2015.0.10; sim platform version 2015.0.10
Team 1418's 2015 Code
14:27:50:283 INFO    : nt                  : Server 0x1039d1da0 entered connection state: GOT_CONNECTION_FROM_CLIENT
14:27:50:284 INFO    : nt                  : Server 0x1039d1da0 entered connection state: CONNECTED_TO_CLIENT
14:27:51:335 INFO    : autonomous          : Begin initializing autonomous mode switcher
14:27:51:349 INFO    : autonomous          : Loaded autonomous modes:
14:27:51:349 INFO    : autonomous          :  -> Drive Forward [Default]
14:27:51:350 INFO    : autonomous          : Autonomous switcher initialized
14:27:51:351 INFO    : robot               : Entering disabled mode
Exception in thread Write Manager Thread:
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/threading.py", line 921, in _bootstrap_inner
    self.run()
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/threading.py", line 869, in run
    self._target(*self._args, **self._kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/networktables2/common.py", line 249, in run
    transactions.append(entry.getUpdateBytes())
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/networktables2/entry.py", line 88, in getUpdateBytes
    self.type.writeBytes(b, self.value)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/networktables2/type.py", line 63, in writeBytes
    s = value.encode('utf-8')
AttributeError: 'float' object has no attribute 'encode'

Make client initialization less verbose

Leaving this as a note to myself. Instead of

NetworkTable.setIPAddress(ip)
NetworkTable.setClientMode()
NetworkTable.initialize()

How about this instead?

NetworkTables.initialize(server='roborio-xxx-frc.local')

If no server argument is given, then it initializes in server mode instead. Can leave the old functions (setIPAddress, setClientMode) for backwards compatibility too.

Install not working - missing files

It appears that installation isn't working correctly due to missing files in the archive

Using the "pip install networktables" method resulted in:

  • the neworktables.py file is missing from the neworktables package folder
  • the ntcore module is missing

I tested on a windows system and a raspberry pi with the same results.

networktables install output.txt

Does not print "Disconnected" when robot disconnects

Hi Dustin,

First of all, thanks for this! I have found it really useful.

Here's the issue:

The robot connects, prints CONNECTED, pynetworktables2js sends value ✅
The robot/network disconnects. Nothing happens ❌

Any idea why?

Thanks

Add type hints

Now that we're Python-3 only, it'd be useful for finding bugs I suspect.

Need better tests

Some of the tests in the java library are useful. I don't really want to do the comprehensive networktables2 interface test, as users probably shouldn't be using that interface, and we'll probably change it because it's too complex.

There should be at least one test that starts a socket and sends data back and forth.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.