| team-4480 |
12-05-2016 21:42 |
Re: Python Network Tables Raspberry Pi 2
Quote:
Originally Posted by tomy
(Post 1586305)
I am looking for some in-site on the python network tables. I am using the example code found here. I try to run it and I get and error stating that I need to set my ipadress. I read up on the error here. Where would you put the IP adress and what would it be? It doesn't seem to be that well explain for newbies. Thanks for any help ahead of time.
|
In the Driver Station example you linked, the IP is set through sys.arg. For me, I just skip that and set the IP directly like this:
Code:
NetworkTable.setIPAddress("10.XX.XX.XX")#Your IP goes here
So the entire code would look like this if you were using the example(This is untested but is similar to what I used before):
Code:
import time
from networktables import NetworkTable
# To see messages from networktables, you must setup logging
import logging
logging.basicConfig(level=logging.DEBUG)
NetworkTable.setIPAddress("10.XX.XX.XX")#Change the address to your own
NetworkTable.setClientMode()
NetworkTable.initialize()
sd = NetworkTable.getTable("SmartDashboard")
i = 0
while True:
try:
print('robotTime:', sd.getNumber('robotTime'))
except KeyError:
print('robotTime: N/A')
sd.putNumber('dsTime', i)
time.sleep(1)
i += 1
Just makes sure to change IP address and that should be a working example. Let me know if it still doesn't work!
|