Skip to content

Version 0.1.0 not working #4

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

Closed
Duvel opened this issue May 12, 2013 · 7 comments
Closed

Version 0.1.0 not working #4

Duvel opened this issue May 12, 2013 · 7 comments

Comments

@Duvel
Copy link

Duvel commented May 12, 2013

If I use my code from #1 and change it to the new writeBytes nothing happens at all, no clue at what is wrong.

@Duvel
Copy link
Author

Duvel commented May 12, 2013

I'm now using this for the constructor:
var wire = new i2c(0x18, {debug:false, device:'/dev/i2c-1'});

@kelly
Copy link
Owner

kelly commented May 14, 2013

Can you post your code from #1 with all the changes for 0.1.0?

@Duvel
Copy link
Author

Duvel commented May 14, 2013

I'm now using this:

var i2c = require('i2c');
//using in 0.0.5 as well 0.1.0
//var wire = new i2c('/dev/i2c-1');
//using only in 0.1.0
var wire = new i2c(0x18, {debug:false, device:'/dev/i2c-1'}); // point to your i2c device, debug provides REPL interface

//using in 0.0.5
//wire.write(4, ["RSI".charCodeAt(0), "RSI".charCodeAt(1), "RSI".charCodeAt(2)], function(err) {});
//using in 0.1.0
wire.writeBytes(4, ["RSI".charCodeAt(0), "RSI".charCodeAt(1), "RSI".charCodeAt(2)], function(err) {});

@kelly
Copy link
Owner

kelly commented May 14, 2013

I think you need:

var wire = new i2c(4, {debug:false, device:'/dev/i2c-1'}) // 4 is the address for your arduino
wire.writeBytes(0x00, "RSI", function(err) {}); 

the first argument in writeBytes is a command byte which is required by the i2c-dev interface.

@Duvel
Copy link
Author

Duvel commented May 14, 2013

Yup, that works. I thought that was the address, that is assigned to the RPi.

The first argument is BTW also send to Arduino, so it seems that the i2c-dev doesn't do anything with it.

@kelly
Copy link
Owner

kelly commented May 14, 2013

Sweet!

Most i2c device communication is a command, followed by a series of bytes. So, it's a little awkward in your case. I may try to abstract that bit in the code. So you could just pass in two or three arguments. In the meantime, this should work:

wire.writeBytes("R", "SI", function(err) {});

in the next release, this will work:

wire.writeBytes("RSI", function(err) {});

@Duvel
Copy link
Author

Duvel commented May 14, 2013

Yup, I thought of that workaround already as well. And it isn't really strange to do it, as it is my current way of telling, what I want to do and then send the arguments.

Thx for the help!

@kelly kelly closed this as completed May 15, 2013
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