Comments (8)
It couldn't initialize the SPI. Have you double checked your SPI wiring?
from sx127x-node-driver.
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
from sx127x-node-driver.
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;
this._spiDevice = (options.hasOwnProperty('spiDevice')) ? options.spiDevice : 0;
If this is a common issue, it may be effecting any other user-selected options in the same way.
from sx127x-node-driver.
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.
from sx127x-node-driver.
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.
`var sx127x = new SX127x({
spiDevice: 1,
frequency: 434e6,
dio0Pin: 6, // BCM numbering (rungpio readall
for info)
resetPin: 13, // BCM numbering (rungpio readall
for info)
syncWord: 0x12,
debug: true,
tempCompensationFactor: 10,
});
`
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;
this._spiDevice = (options.hasOwnProperty('spiDevice')) ? options.spiDevice : 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
from sx127x-node-driver.
Github gists or upload the whole repo to github. You can also paste the full modified example here.
from sx127x-node-driver.
const express = require('express');
const app = express();
const util = require('util');
const {
exec
} = require('child_process');
var SX127x = require('../lib/sx127x');
var sx127x = new SX127x({
spiDevice: 1,
frequency: 434e6,
dio0Pin: 6, // BCM numbering (run gpio readall
for info)
resetPin: 13, // BCM numbering (run gpio readall
for info)
syncWord: 0x12,
debug: true,
tempCompensationFactor: 10,
});
async function send() {
let count = 0;
try {
await sx127x.open();
} catch(err) {
console.log(err)
}
while(true) {
// send a message every second
try {
await sx127x.write(new Buffer('hello ' + count++));
console.log("successfully sent")
} catch (err) {
console.log(err);
}
await util.promisify(setTimeout)(1000);
}
}
send();
process.on('SIGINT', async function() {
// close the device
try {
await sx127x.close();
} catch (err) {
console.log('close failure: ' + err);
process.exit();
}
console.log("success");
process.exit();
});
from sx127x-node-driver.
That's the full example
from sx127x-node-driver.
Related Issues (11)
- Library not found HOT 4
- How does PC view GPIO?
- install error
- Is SX1280 supported? HOT 1
- setCodingRate logic incorrect HOT 1
- Bandwidth - supported value readme addition HOT 1
- Support for RX IQ inversion HOT 3
- Allowing DIO pin number 0 HOT 2
- Raspberry Pi + Dragino HAT GPS and LoRa
- ERR_INVALID_ARG_TYPE HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sx127x-node-driver.