storborg/pyminicircuits

windows support

Closed this issue · 4 comments

Hi all,

First, thank you for putting this library out there!

From the install instructions I this looks intended for/developed in Linux. However, it works in windows too with some fairly trivial adjustments:

  1. Platform-specific adjustment to the _cmd method
    import platform

    def _cmd(self, *cmd):
        if len(cmd) > 64:
            raise ValueError('command data length is limited to 64')
        cmd = list(cmd) + (63-len(cmd))*[0]
            
        if platform.system().lower() == 'windows':
            self.h.write([0]+cmd[:-1])
        else:
            self.h.write(cmd)

        while True:
            d = self.h.read(64)
            if d:
                break
        if d[0] != cmd[0]:
            raise RuntimeError("Invalid response from device: %s" % d)
        return d
  1. Installation

All I needed to do to make this work on current 64-bit anaconda in windows was:

pip install hidapi

No USB configuration necessary

Cool! Thanks for the patch, I'll definitely get this included. If you don't mind, could you share what version of Windows and what device(s) you're using it with?

Works for me, windows 10