from ctypes import * AIOUSB = cdll.LoadLibrary("aiousb") def displayBoardInfo(index): PID = c_int() len = c_int(20) name = create_string_buffer(len.value) AIOUSB.QueryDeviceInfo(index, byref(PID), byref(len), byref(name), 0, 0) sn = c_longlong(0) AIOUSB.GetDeviceSerialNumber(index, byref(sn)) print("Board found at index", index, "has deviceID", hex(PID.value), "=", name.value.strip().decode(), "SN=", hex(sn.value)) # main code section print("AIOUSB Python introductory sample using ctypes\n") boardsMask = AIOUSB.GetDevices() if boardsMask == 0: print("No valid AIOUSB devices were detected.\nPlease confirm your USB device is connected, powered,\nand the drivers are installed correctly (check Device Manager).") exit() boardsFound = 0 for di in range(0, 31): if 0 != boardsMask & (1 << di): boardsFound = boardsFound + 1 displayBoardInfo(di) print("\nAIOUSB Boards found:", boardsFound) print("Done.") input("Press to Exit.")