from iowp.factory import IowFactory
import sys
import os

# Add parent directory to sys.path to find iowkit and sister modules if run directly
if __name__ == "__main__":
    _root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
    if _root not in sys.path:
        sys.path.insert(0, _root)

def main():
    factory = IowFactory.get_instance()
    devices = factory.get_devices()
    print(f"Number of plugged IO-Warrior device(s): {len(devices)}")
    for i, dev in enumerate(devices):
        # Short format as requested
        print(f"Device {i}: {dev.name} (Serial: {dev.serial}, Rev: {hex(dev.rev)})")

if __name__ == "__main__":
    main()