-
Notifications
You must be signed in to change notification settings - Fork 611
Problems with more than one MCP3008 #823
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
dceejay
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couple of tiny questions to fix but yes basically good...
hardware/mcp3008/pimcp3008.js
Outdated
| module.exports = function(RED) { | ||
| "use strict"; | ||
| var fs = require('fs'); | ||
| var fs2 = require('fs'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure why we need this duplication ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a holdover from debugging.
The line can remain original
hardware/mcp3008/pimcp3008.js
Outdated
| // unlikely if not on a Pi | ||
| try { | ||
| var cpuinfo = fs.readFileSync("/proc/cpuinfo").toString(); | ||
| var cpuinfo = fs2.readFileSync("/proc/cpuinfo").toString(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Likewise - why won't the original be ok ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The line can remain also original.
hardware/mcp3008/pimcp3008.js
Outdated
| this.dnum = parseInt(n.dnum || 0); | ||
| this.bus = parseInt(n.bus || 0); | ||
| this.dev = n.dev || "3008"; | ||
| this.fs = require('fs'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indent ->
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here I was not shure if the definition from the global place caused any problems. So I createt a new one and renamed the orginal to fs2.
If you want to remove the line you have also edit line 42.
from:
this.fs.statSync("/dev/spidev"+node.bus+"."+node.dnum);
to:
fs.statSync("/dev/spidev"+node.bus+"."+node.dnum);
I testet this on my raspberry and it worked
implementation of the discussion
|
|
/easycla |
Proposed changes
It was only possible to communicate with one MCP3008 at once.
Now several MCPs can be used at the same time.
Checklist
gruntto verify the unit tests pass