Giter Site home page Giter Site logo

Comments (13)

Youw avatar Youw commented on August 27, 2024 1

0.13 already includes a lot of good improvements, so I guess making a release (before Christmas) would be a good thing regardless if it is going to include the multithreaded documentation/fixes or not

from hidapi.

mcuee avatar mcuee commented on August 27, 2024 1

@Youw

It is great that you have released hidapi 0.13. Thanks.

from hidapi.

k1-801 avatar k1-801 commented on August 27, 2024 1

Oh yes, HIDAPI on macOS has an additional issue regarding thread-safety. I did encountered it in my project(s) but didn't have enough time to gather info/find a root cause. Looks like on macOS hid_init/hid_exit needs to be called in the same thread, which is an additional restriction compared to other platforms.

I have a potential solution, described fully in #666

from hidapi.

Youw avatar Youw commented on August 27, 2024

NOTE for everyone: hidapi not thread-safe in general, with a few platform-specific/usage-spacific exceptions.

Damn, I need to get my hands to describe everything in details.

from hidapi.

mcuee avatar mcuee commented on August 27, 2024

Reference: Windows: unable to interrupt blocking hid_read call #133

from hidapi.

mcuee avatar mcuee commented on August 27, 2024

I see this and #133 are tied to 0.13.0 milestone. Supposedly this one will "help" #133, right?

Any activities on this one?

#146 is supposed to fix #133, but I see no activities there.

from hidapi.

mcuee avatar mcuee commented on August 27, 2024

@Youw
Just wondering what is the plan for 0.13.0 release, say as a Christmas gift. :-)

from hidapi.

mcuee avatar mcuee commented on August 27, 2024

0.13 already includes a lot of good improvements, so I guess making a release (before Christmas) would be a good thing regardless if it is going to include the multithreaded documentation/fixes or not

I agree. Thanks.

from hidapi.

mcuee avatar mcuee commented on August 27, 2024

Reference by Youw.

As for multithreaded usage of hidapi - many projects successfully using a separate thread for hid_read/_timeout, and another thread for read/everything else.

from hidapi.

mcuee avatar mcuee commented on August 27, 2024

Another reference by Youw.

client code should first stop any read/write attempts before trying to close the device as hid_close cannot not be thread-safe by design, even it it is sometime, for some implementations.

from hidapi.

mcuee avatar mcuee commented on August 27, 2024

Add a stub FAQ entry here.
https://github.com/libusb/hidapi/wiki#faq

from hidapi.

mcuee avatar mcuee commented on August 27, 2024

Comments by Youw here.

Oh yes, HIDAPI on macOS has an additional issue regarding thread-safety. I did encountered it in my project(s) but didn't have enough time to gather info/find a root cause. Looks like on macOS hid_init/hid_exit needs to be called in the same thread, which is an additional restriction compared to other platforms.

from hidapi.

mcuee avatar mcuee commented on August 27, 2024

Reference from node-hid.
https://github.com/node-hid/node-hid#thread-safety-worker-threads-context-aware-modules

Thread safety, Worker threads, Context-aware modules
In general node-hid is not thread-safe because the underlying C-library it wraps (hidapi) is not thread-safe. However, node-hid is now reporting as minimally Context Aware to allow use in Electron v9+. Until node-hid (or hidapi) is rewritten to be thread-safe, please constrain all accesses to it via a single thread.

from hidapi.

Related Issues (20)

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.