eltoroit / eltoroit.github.io

Diary of a Salesforce developer on the magical world of electronics. Join me as I share my experiences. Let's learn together!
2 stars 0 forks source link

Synchronous or asynchronous I2C? #5

Closed fivdi closed 3 years ago

fivdi commented 3 years ago

To the best of my knowledge all of the rpio functions called in the readValue function are blocking synchronous functions. On the other hand, the readValue function is declared as an async function which implies that it runs asynchronous. If my assumption about rpio functions being synchronous is correct, readValue shouldn't be declared as an async function as it will mislead the reader into thinking that synchronous code is asynchronous.

eltoroit commented 3 years ago

@fivdi thanks for pointing this out. I have fixed the code and updated the repo (and the blog).

eltoroit commented 3 years ago

I decided to go with RPIO because your npm package did not include I2C. There is a note at the bottom of the documentation pointing out to another npm package i2c-bus.

My first impression was that PIGPIO did not bother to do I2C and I was disappointed, but then I realized that you are also the author of i2c-bus. I imagine you split the two packages in order to avoid bloating PIGPIO.

The more I read about your package(s), the more I like them!

I will be writing a second article that uses the ADC with your i2c-bus package.

Thanks for the awesome code!