GithubHelp home page GithubHelp logo

hidapi-cffi's People

Contributors

jbaiter avatar niligulmohar avatar russdill avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

hidapi-cffi's Issues

Python3 type confusion with feature report IDs

send_feature_report and get_feature_report have report_id parameters whose type is documented to be int. send_feature_report defaults the parameter to 0x0, an int.

However, they both write the report ID to the first byte of a CFFI buffer, which fails on Python 3:

Suppose I have this code:

dev.send_feature_report(b"\x00", 0x20)

It fails:

Traceback (most recent call last):
  File "./test.py", line 23, in <module>
    dev.send_feature_report(b"\x00", 0x20)
  File "/home/rprichard/proj/logitech-g400-config/hidapi_cffi/hidapi.py", line 284, in send_feature_report
    buf[0] = report_id
TypeError: must assign a bytes of length 1, not int

To make it work, I must instead pass a 1-byte bytestring for the report ID:

dev.send_feature_report(b"\x00", b"\x20")

I'm using:

  • the very latest hidapi-cffi code
  • Xubuntu 16.04
  • distribution-provided Python3 and python3-cffi packages

I also tried replacing python3-cffi with one installed by pip3, but it made no difference.

Aside: is it actually useful to default the report_id for send_feature_report to 0x0? I think it'd might make sense if the default behavior instead omitted the report ID from the buffer passed to hidapi.hid_send_feature_report, but that's not what happens.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.