def enable_device_io(device, io_mask, enable_mask=0xFF): # The second device bank 1 in the "chain" controls all the IO neoradio2.write_sensor(device, 1, 1, io_mask, enable_mask) if __name__ == "__main__": # Find all devices devices = neoradio2.find() if not len(devices): print("Failed to find any neoRAD-IO2 Devices!") exit(1) # Open first device print("Opening {} {}...".format(devices[0].name, devices[0].serial_str)) device = neoradio2.open(devices[0]) print("Opened {} {}...".format(devices[0].name, devices[0].serial_str)) # Make sure we are in application firmware and chain is identified. neoradio2.app_start(device, 0, 0xFF) neoradio2.chain_identify(device) # Read all the AIN values neoradio2.request_sensor_data(device, 0x00, 0xFF, True) names = ["AIN1", "AIN2", "AIN3", "AIN4", "AIN5", "AIN6", "TEMP", "POT "] ain_values = [] for x in range(8): voltage = neoradio2.read_sensor_float(device, 0x00, x) ain_values.append(voltage) print("{}: {:.2f}V".format(names[x], voltage)) neoradio2.close(device)
print("Found {} Device(s)".format(len(devices))) for device in devices: print("\t1.) {} {}".format(device.name, device.serial_str)) print() # Connect and identify all the chains for device in devices: print_status(device, "Connecting") h = neoradio2.open(device) print_status(device, "Connected") print_status(device, "Identifying Chain") neoradio2.chain_identify(h) print_status(device, "Starting App") neoradio2.app_start(h, 0xFF, 0xFF) print_status(device, "Identifying Chain") neoradio2.chain_identify(h) count = neoradio2.get_chain_count(h, False) print_status(device, "Found {} device(s) in the chain".format(count)) for d in range(count): dev_type = neoradio2.get_device_type(h, d, 0) serial_number = neoradio2.get_serial_number(h, d, 0) print("\tChain {} {} {}".format(d + 1, device_type_string(dev_type), base36encode(serial_number)))