try:
    mcL.waitForAttach(10000)
    mcR.waitForAttach(10000)
except PhidgetException as e:
    print("Phidget Exception %i: %s" % (e.code, e.details))
    try:
        mcL.closePhidget()
        mcR.closePhidget()
    except PhidgetException as e:
        print("Phidget Exception %i: %s" % (e.code, e.details))
        print("Exiting....")
        exit(1)
    print("Exiting....")
    exit(1)

print("mcL attached to WebService: %s" % mcL.isAttachedToServer())
print("mcR attached to WebService: %s" % mcR.isAttachedToServer())

context = zmq.Context()
bat_socket = context.socket(zmq.PUB)
bat_socket.bind("ipc:///tmp/battery.ipc")

charging = 1

while True:
    bat1 = mcL.getSupplyVoltage()
    bat2 = mcR.getSupplyVoltage()

    if ((bat1 > 26.0) or (bat2 > 26.0)):
        chargeState = 'Charging'
        bat_time = 0
#    print("Exiting....")
#    exit(1)

print("Opening phidget object on Phidgets WebService 'odroid'...")

try:
    #motorControlL.openPhidget(serial=298857)
    #motorControlR.openPhidget(serial=298856)
    motorControlL.openRemote('odroid',serial=298857)
    motorControlR.openRemote('odroid',serial=298856)
except PhidgetException as e:
    print("Phidget Exception %i: %s" % (e.code, e.details))
    print("Exiting....")
    exit(1)

if not motorControlL.isAttachedToServer():
    sleep(2)

print('motorControlL attached to server status: %s' % motorControlL.isAttachedToServer() )
print('motorControlR attached to server status: %s' % motorControlR.isAttachedToServer() )

print("Waiting for attach....")

try:
    motorControlL.waitForAttach(10000)
    motorControlR.waitForAttach(10000)
except PhidgetException as e:
    print("Phidget Exception %i: %s" % (e.code, e.details))
    try:
        motorControlL.closePhidget()
        motorControlR.closePhidget()
示例#3
0
#    print("Exiting....")
#    exit(1)

print("Opening phidget object on Phidgets WebService 'odroid'...")

try:
    #motorControlL.openPhidget(serial=298857)
    #motorControlR.openPhidget(serial=298856)
    motorControlL.openRemote('odroid', serial=298857)
    motorControlR.openRemote('odroid', serial=298856)
except PhidgetException as e:
    print("Phidget Exception %i: %s" % (e.code, e.details))
    print("Exiting....")
    exit(1)

if not motorControlL.isAttachedToServer():
    sleep(2)

print('motorControlL attached to server status: %s' %
      motorControlL.isAttachedToServer())
print('motorControlR attached to server status: %s' %
      motorControlR.isAttachedToServer())

print("Waiting for attach....")

try:
    motorControlL.waitForAttach(10000)
    motorControlR.waitForAttach(10000)
except PhidgetException as e:
    print("Phidget Exception %i: %s" % (e.code, e.details))
    try: