-
Notifications
You must be signed in to change notification settings - Fork 6
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
Error on sx127x.open() #7
Comments
It couldn't initialize the SPI. Have you double checked your SPI wiring? |
running ls /dev/spi* I only show /dev/spidev0.1 I'm not sure why it doesn't default to 0.0, but I tried to test 0.1. I created a new project to test the spi-device library, and using the example on fivdi's spi-device repo I was able to get it to initialize with spi.open(0,1, err ...); Switching the deviceNumber to 1 from 0 seemed to eliminate the error on open. When I add to the sender.js constructor the option for spiDevice : 1 I still get the same error as the default example sender.js. Based on this test, I assume that the wiring was correct and it should work when using device 1. Thanks |
I think the logic for the options object in the constructor for the class may not be working properly. Most of the values use the || (OR) logical operator to see if they are present in the options object. When I change the constructor to use the same options.hasOwnProperty function as the dio0 and reset Pin for the options.spiDevice and options.spiBus, it actually allows the code to compile. Lines 65 and 66 from sx127x.js would then be: this._spiBus = (options.hasOwnProperty('spiBus')) ? options.spiBus : 0; If this is a common issue, it may be effecting any other user-selected options in the same way. |
Can you share with me your example code with modified options? OR'ing on an integer is sure to work if the value passed is undefined, so I think the problem is elsewhere. |
I started with the sender.js example in the repo and just added the line spiDevice : 1 to the constructor, which resulted in the original error posted above.
everything else in the example remained the same. When I went to the lib/sx127x.js file I changed lines 65 and 66 to the following: this._spiBus = (options.hasOwnProperty('spiBus')) ? options.spiBus : 0; and the error was resolved. If you'd like the download of the repo I have, what is the best way of sharing the whole files? Thanks |
Github gists or upload the whole repo to github. You can also paste the full modified example here. |
const express = require('express'); async function send() {
} send(); process.on('SIGINT', async function() { console.log("success"); |
That's the full example |
I just installed the package on RasPi B v1.2
When testing the examples I get the following in sender.js I believe the first error is being thrown on _spiOpen and when _spi.transfer is being called, it throws the next error.
Any suggestions for troubleshooting this error?
{ [Error: ENOENT, No such file or directory] errno: 2, code: 'ENOENT', syscall: 'open' }
Debug sx127x: Sending: hello 0
Error: Spi not defined
at SX127x._readRegister (/home/pi/sx127x-node-driver/lib/sx127x.js:472:11)
at SX127x.write (/home/pi/sx127x-node-driver/lib/sx127x.js:427:36)
at send (/home/pi/sx127x-node-driver/examples/sender.js:29:17)
at process._tickCallback (internal/process/next_tick.js:68:7)
(node:6870) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
The text was updated successfully, but these errors were encountered: