def create_hardware(): import antd.hw as hw try: id_vendor = int(_cfg.get("antd.hw", "id_vendor"), 0) id_product = int(_cfg.get("antd.hw", "id_product"), 0) bulk_endpoint = int(_cfg.get("antd.hw", "bulk_endpoint"), 0) return hw.UsbHardware(id_vendor, id_product, bulk_endpoint) except hw.NoUsbHardwareFound: _log.warning("Failed to find Garmin nRF24AP2 (newer) USB Stick.", exc_info=True) _log.warning("Looking for nRF24AP1 (older) Serial USB Stick.") tty = _cfg.get("antd.hw", "serial_device") return hw.SerialHardware(tty, 115200)
#!/usr/bin/python import sys import logging import antd.ant as ant import antd.hw as hw logging.basicConfig( level=logging.DEBUG, out=sys.stderr, format="[%(threadName)s]\t%(asctime)s\t%(levelname)s\t%(message)s") _LOG = logging.getLogger() dev = hw.UsbHardware() core = ant.Core(dev) session = ant.Session(core) try: channel = session.channels[0] network = session.networks[0] network.set_key("\x00" * 8) channel.assign(channel_type=0x00, network_number=0) channel.set_id(device_number=0, device_type_id=0, trans_type=0) channel.set_period(0x4000) channel.set_search_timeout(4) channel.set_rf_freq(40) channel.open() _LOG.info("BROADCAST: %s", channel.recv_broadcast(timeout=0)) channel.send_acknowledged("ack") channel.send_burst("burst")
def create_hardware(): id_vendor = int(_cfg.get("antd.hw", "id_vendor"), 0) id_product = int(_cfg.get("antd.hw", "id_product"), 0) bulk_endpoint = int(_cfg.get("antd.hw", "bulk_endpoint"), 0) import antd.hw as hw return hw.UsbHardware(id_vendor, id_product, bulk_endpoint)