camera_url = i.getItemReferences(barcode)["camera_url"] if camera_url == '': raise KeyError except KeyError: failed( "Could not get camera url from invent. Try setting the serial and MAC" ) # Set the camera's name p = subprocess.Popen([ "rosrun", "wge100_camera", "set_name", camera_url + "@" + progip, cameraname, cameraip ], stdout=subprocess.PIPE, stderr=subprocess.PIPE) setnameout = p.communicate() passed("Output from setname tool...\n<b>Standard output:</b>\n" + setnameout[0] + "\n\n<b>Standard error:</b>\n" + setnameout[1]) if retval == 0: i.setKV(barcode, "Configured name", cameraname) i.setKV(barcode, "Configured ip", cameraip) passed("passed") # FIXME else: i.setKV(barcode, "Configured name", "<configure failed>") i.setKV(barcode, "Configured ip", "<configure failed>") failed("failed") # FIXME except: failed('<b>Exception:</b>\n%s' % traceback.format_exc())
else: print "camera_url already in invent" # Get MAC address from invent. i.generateWGMacaddr(barcode, "lan0") refs = i.getItemReferences(barcode) macstr = refs["lan0"] print "Camera MAC is:", macstr mac = [] if len(macstr.rstrip("1234567890abcdefABCDEF")) != 0 or len(macstr) != 12: print "The MAC should be 12 hex digits." exit(-1) for j in range(0, 6): mac.append(int(macstr[2*j:2*j+2], 16)) if i.getKV(barcode, 'board_configured') == 'yes': print "This board has already been configured." exit(0) i.setKV(barcode, 'board_configured', 'unknown') # Wait for service, and call it. print "Waiting for board_config service." rospy.wait_for_service('board_config', 10) board_config = rospy.ServiceProxy('board_config', BoardConfig) rslt = board_config(serial, "".join([chr(x) for x in mac]) ); print "Result is", rslt.success if rslt.success == 1: i.setKV(barcode, 'board_configured', 'yes') exit(rslt == 1) # Returns 0 on success