Skip to content
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

Cannot open pin for read #53

Open
javirs85 opened this issue Mar 12, 2017 · 8 comments
Open

Cannot open pin for read #53

javirs85 opened this issue Mar 12, 2017 · 8 comments

Comments

@javirs85
Copy link

Im running raspi Model B Rev 2 512MB, I installed the module and succesfully opened a pin for writing on it. Succesfully made a LED blink.
Then I try to open a port for reading and I get and error

{ Error: EINVAL: invalid argument, write errno: -22, code: 'EINVAL', syscall: 'write' }

This the relevant part of the code.

var gpio = require('rpi-gpio');
server.listen(8080, function() {
	console.log('Servidor corriendo en http://localhost:8080');
	
	gpio.setup(7, gpio.DIR_OUT, control);
	gpio.setup(6, gpio.DIR_IN, control);
});

function control(err)
{
	if(err)
		console.log("Control function: " + err);
	else
		console.log('ok');
}

Any clue ??

@javirs85
Copy link
Author

Ok, error was that pin 6 i GND. GPIO6 is actually mapped to pin 22. Setting 22 solved the isue.

Is there a way to name pins in a form other than the physical pin? I´m using a custom expansion board and this is hell :(

@thecodershome
Copy link
Contributor

There is a fork of this repo that has MODE_RAW. https://github.com/timelapseplus/node-linux-gpio

@javirs85
Copy link
Author

sorry, I'm new to github, how can I choose to install the forked version?

and.. what's the mode RAW ? in the link u sent me there is nothing about it.. :(

@thecodershome
Copy link
Contributor

To install the forked repo run npm install timelapseplus/node-linux-gpio or npm install timelapseplus/node-linux-gpio --save to add the repo to your dependencies.
Since the package name was changed you will need to use var gpio = require('linux-gpio') instead of var gpio = require('rpi-gpio').

If you use gpio.setMode(gpio.MODE_RAW) you can "attempt" to use any channel.

function getPinRaw(channel) {
        return channel + '';
    };

@javirs85
Copy link
Author

can you gimme an example of "channel" ?

@thecodershome
Copy link
Contributor

gpio.setup(7, gpio.DIR_OUT)

Take a look at this, https://pinout.xyz/pinout/pin3_gpio2
It should help with picking channels.

@thecodershome
Copy link
Contributor

By default this library uses the physical pin values, MODE_RPI.

@javirs85
Copy link
Author

My pi is 1 rev 2, I only have 26 pins so the graph is not fitting my setup. Anyhow, what's the raw name I have to enter to access GPIO6 ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants