How to use the hidapi.hid_write function in hidapi

To help you get started, we’ve selected a few hidapi examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ampledata / roip / roip / classes.py View on Github external
def ptt_stop(self) -> int:
        """[TX] Stops Transmit on the Radio."""
        stop = roip.PTT_STOP
        wrote = hidapi.hid_write(self.hid_device, stop)
        self._logger.debug('stop="%s" wrote="%s"', stop, wrote)
        assert len(stop) == wrote
        return wrote
github sde1000 / python-dali / dali / driver / hasseb.py View on Github external
def enableSniffing(self):
        self.sn = self.sn + 1
        if self.sn > 255:
            self.sn = 1
        data = struct.pack('BBBBBBBBBB', 0xAA, HASSEB_CONFIGURE_DEVICE,
                            self.sn, 0x01, 0, 0, 0, 0, 0, 0)
        hidapi.hid_write(self.device, data)
github sde1000 / python-dali / dali / driver / hasseb.py View on Github external
def send(self, command):
        time.sleep(0.02)    # a delay between sent messages need to be at lest 22*417 µs
        self._response_message = None
        data = self.construct(command)
        self.send_message = struct.pack('BB', data[7], data[8])
        if command.response is not None:
            self._pending = command
            self._response_message = None
            hidapi.hid_write(self.device, data)
            self.wait_for_response()
            return command.response(self.extract(self._response_message))
        else:
            self._pending = None
            hidapi.hid_write(self.device, data)
            return
github hansfbaier / open-maschine / proof-of-concept / talk-with-maschine.py View on Github external
def clear_display(no):
    for i in range(0, 8):
        hidapi.hid_write(device, (bytearray((("e00000%02x00200008" % (8 * i) + ((265 - 8) * "00")).replace("e0", "e%d" %no)).decode("hex"))))
github sde1000 / python-dali / dali / driver / hasseb.py View on Github external
def disableSniffing(self):
        self.sn = self.sn + 1
        if self.sn > 255:
            self.sn = 1
        data = struct.pack('BBBBBBBBBB', 0xAA, HASSEB_CONFIGURE_DEVICE,
                            self.sn, 0, 0, 0, 0, 0, 0, 0)
        hidapi.hid_write(self.device, data)
github hansfbaier / open-maschine / proof-of-concept / talk-with-maschine.py View on Github external
write_display = lambda display: [hidapi.hid_write(device, line) for line in to_bytearray(display)]
github hansfbaier / open-maschine / proof-of-concept / talk-with-maschine.py View on Github external
clear_display(0)
time.sleep(1)
clear_display(1)
time.sleep(1)
write_display(tux)
time.sleep(1)
write_display(machineicon)

count = 0

import random
while True:
    count += 1
    if count == 100:
        led_state = bytearray(("82" + ''.join(format(random.randint(0,255), '02x') for _ in range(31))).decode("hex"))
        hidapi.hid_write(device, led_state)

        # 16 rgb buttons
        pad_state = bytearray(("80" + ''.join(format(random.randint(0,255), '02x') for _ in range(16 * 3))).decode("hex"))
        hidapi.hid_write(device, pad_state)

        # 8 group rgb_1 + 8 group rgb_2 + 8 transport buttons
        group_other_btn_state = bytearray(("81" + ''.join(format(random.randint(0,255), '02x') for _ in range(((8 + 8) * 3) + 8))).decode("hex"))
        hidapi.hid_write(device, group_other_btn_state)

        count = 0

    result = hidapi.hid_read(device, 256)
    state = binascii.hexlify(result)
    if state != quiet_state:
        print "#%d: %s"  % (len(result), state)
github ampledata / roip / roip / classes.py View on Github external
def ptt_start(self) -> int:
        """[TX] Triggers Transmit on the Radio."""
        start = roip.PTT_START
        wrote = hidapi.hid_write(self.hid_device, start)
        self._logger.debug('start="%s" wrote="%s"', start, wrote)
        assert len(start) == wrote
        return wrote