View Single Post
  #2   Spotlight this post!  
Unread 12-05-2016, 21:42
team-4480's Avatar
team-4480 team-4480 is offline
Debug? What's that?
FRC #4480
 
Join Date: Jan 2015
Rookie Year: 2013
Location: Minnesooota
Posts: 217
team-4480 will become famous soon enoughteam-4480 will become famous soon enough
Re: Python Network Tables Raspberry Pi 2

Quote:
Originally Posted by tomy View Post
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!
__________________
#Python4Life
Reply With Quote