fivdi / i2c-bus

I2C serial bus access with Node.js
MIT License
348 stars 57 forks source link

Device ID direct access function #48

Closed johntalton closed 6 years ago

johntalton commented 6 years ago

first pass addition of i2c_smbus_deviceid (tested on rpi with fujitsu mb85 fram (http://www.fujitsu.com/global/documents/products/devices/semiconductor/fram/lineup/MB85RC256V-DS501-00017-5v1-E.pdf) on address 0x50, outputting 0xA510 [aka correct value for device])

top level issues / request for comment:

fivdi commented 6 years ago

@johntalton very nice :smile:

top level issues / request for comment:

Additional Stuff:

johntalton commented 6 years ago

for the parseId method of deviceId*, i am not sure if the return type of an object is "right" for this lib. maybe the callback should take (err, man, prod, name) or just (err, man, prod) and externalize the "enum" list?

also used (ret > 0) in C-code for ioctl return checking (Zero is a valid return). This is slightly different from the other implicit if(ioctl..) call which casts the int to boolean.

I have NOT included the other I2C method (SoftwareReset and ReloadAddress) as they both can be implemented on-top of the existing api. thus at best they should live in the JS code (or just not included at all an left for the higher level implementor). Your call.

Please feel free to rewrite the README - it likely would "sound" better in your "voice" (you would be surprised how far consistency in docs goes :) )

fivdi commented 6 years ago

for the parseId method of deviceId*, i am not sure if the return type of an object is "right" for this lib. maybe the callback should take (err, man, prod, name) or just (err, man, prod) and externalize the "enum" list?

I prefer return type object. deviceId is a bit like i2cFuncs.

Please feel free to rewrite the README - it likely would "sound" better in your "voice" (you would be surprised how far consistency in docs goes :) )

Ok :)