dangrie158 / opencushion

A c++ driver and a node binding for the HX711 Load Cell Amp
MIT License
14 stars 17 forks source link

multiple calls to wiringPiSetup causes crash #2

Closed Clotoo closed 7 years ago

Clotoo commented 7 years ago

It seems that wiringPiSetup cannot be called multiple times per program anymore. It crashes the program with the following message : wiringPiSetup*: You must only call this once per program run. This is a fatal error. Please fix your code.

It happens consistently in either case :

The hx711 cpp constructor seems to call wiringPiSetup every time. The johnny-five module also calls wiringPiSetup upon loading.

My suggestion for a simple fix is to add an optional boolean parameter in the hx711 constructor, to let the user decide if wiringPiSetup should be called or not. Will submit a pull request soon.

maxnowack commented 7 years ago

This was fixed in #3 but not published to npm yet. @dangrie158 please publish it :)

dangrie158 commented 7 years ago

Hi, I just bumped the minor version since the API changed. New release (and npm published version) is 0.3.0.

https://github.com/dangrie158/opencushion/commit/5c287e3c15a45425277804ecd7a919207d7a755a

maxnowack commented 7 years ago

Great, thank you!