def start(self): # todo USB device configuration input if self.usb_product_id == 'fake': print("Faking HR device with randomness") return try: print("Opening USB...") self.usb_device = driver.USB2Driver(debug=True, idProduct=0x1009) print("Got USB: {0}".format(self.usb_device)) except DriverError as e: print("Unable to open USB device.") return except Exception as e: print("Unexpected exception: {0}".format(e)) return try: print("Creating node...") self.node = node.Node(self.usb_device) print("Starting node {0}".format(self.node)) self.node.start() print("Node started.") except NodeError as e: self.node = None print("Unable to start node: {0}".format(e)) except ChannelError as e: self.node = None print("Unable to open channel: {0}".format(e)) except Exception as e: self.node = None print("Unexpected exception...: {0}".format(e))
def start(): global antnode global speed_sensor global power_meter from vpower.config import DEBUG, LOG, NETKEY, POWER_CALCULATOR, POWER_SENSOR_ID, SENSOR_TYPE, SPEED_SENSOR_ID xbmc.log("Using " + POWER_CALCULATOR.__class__.__name__, level=xbmc.LOGDEBUG) stick = driver.USB2Driver(None, log=LOG, debug=DEBUG) antnode = node.Node(stick) xbmc.log("Starting ANT node", level=xbmc.LOGDEBUG) antnode.start() key = node.NetworkKey('N:ANT+', NETKEY) antnode.setNetworkKey(0, key) xbmc.log("Starting speed sensor", level=xbmc.LOGDEBUG) # Create the speed sensor object and open it speed_sensor = SpeedCadenceSensorRx( antnode, SENSOR_TYPE, SPEED_SENSOR_ID) speed_sensor.open() # Notify the power calculator every time we get a speed event speed_sensor.notify_change(POWER_CALCULATOR) xbmc.log("Starting power meter with ANT+ ID " + repr(POWER_SENSOR_ID), level=xbmc.LOGDEBUG) # Create the power meter object and open it power_meter = PowerMeterTx(antnode, POWER_SENSOR_ID) power_meter.open() # Notify the power meter every time we get a calculated power value POWER_CALCULATOR.notify_change(power_meter)
def _start_antnode(self): stick = driver.USB2Driver(self.serial) self.antnode = node.Node(stick) print('node running:{}'.format(self.antnode.running)) #if self.antnode.running == False: self.antnode.start() print('Antnode capabilities-Channels: {}, Networks: {}').format(self.antnode.getCapabilities()[0], self.antnode.getCapabilities()[1])
def _start_antnode(self): print(">> TRACEIN HRM:_start_antnode") stick = driver.USB2Driver(self.serial) print("driver assigned to " + self.serial) self.antnode = node.Node(stick) print("antnode created from stick") self.antnode.start() print("antnode started") print("<< TRACEOUT HRM:_start_antnode")
def _initialize(self): if self.driver is None: # actually doesn't matter what parameter we put since USB2 # doesn't use /dev self.driver = driver.USB2Driver(DEFAULT_ADDR) if self.node is None: self.node = node.Node(self.driver) self.node.start() self.key = node.NetworkKey(self.DEFAULT_NET_NAME, self.netkey) self.node.setNetworkKey(0, self.key)
from ant.core import message from ant.core.constants import * from config import * NETKEY = '\xB9\xA5\x21\xFB\xBD\x72\xC3\x45' # A run-the-mill event listener class HRMListener(event.EventCallback): def process(self, msg, _channel): if isinstance(msg, message.ChannelBroadcastDataMessage): print 'Heart Rate:', ord(msg.payload[-1]) # Initialize stick = driver.USB1Driver(SERIAL, log=LOG, debug=DEBUG) antnode = node.Node(stick) antnode.start() # Setup channel net = node.Network(name='N:ANT+', key=NETKEY) antnode.setNetworkKey(0, net) channel = antnode.getFreeChannel() channel.name = 'C:HRM' channel.assign(net, CHANNEL_TYPE_TWOWAY_RECEIVE) channel.setID(120, 0, 0) channel.searchTimeout = TIMEOUT_NEVER channel.period = 8070 channel.frequency = 57 channel.open() # Setup callback
def _start_antnode(self): stick = driver.USB2Driver(self.serial) self.antnode = node.Node(stick) self.antnode.start()
def _start_antnode(self): stick = driver.USB1Driver(self.serial, log=None, debug=False) self.antnode = node.Node(stick) self.antnode.start()
def start(self): print 'Initializing' # Initialize stick = driver.USB1Driver(SERIAL, debug=DEBUG) self.antnode = node.Node(stick) self.antnode.start()
def __init__(self, serial, network_key_type="ant+"): self.node = node.Node(driver.USB2Driver(serial)) self.network_key_type = network_key_type self.channel = None
def _start_antnode(self): stick = driver.USB2Driver(SERIAL, log=LOG, debug=DEBUG) self.antnode = node.Node(stick) self.antnode.start()