sbstjn / noduino

JavaScript and Node.js Framework for controlling Arduino with HTML and WebSockets
http://sbstjn.github.io/noduino/
1.23k stars 232 forks source link

[Error: Unable to connect] Opening \\.\/dev/: Unknown error code 3 #16

Open jelmerdemaat opened 11 years ago

jelmerdemaat commented 11 years ago

Hi there,

I'm a beginner in Node and noduino, but it seems I have the whole thing set up correctly. I can succesfully do this:

$ > git clone git@github.com:semu/noduino.git $ > cd noduino/ $ > git submodule update --init $ > npm install $ > cd examples/

But when I do

$ > node test.walkLED.js

I get

[Error: Unable to connect] events.js:2725: Uncaught error: Opening \\.\/dev/: Unknown error code 3

I have looked around but I can't find any thing about this error. Do you have any idea about what the problem could be?

Cheers,

Jelmer

jelmerdemaat commented 11 years ago

Maybe this helps: http://d.pr/i/UWKd

This one occurs when I try to use the node srv.web.js example.

sarink commented 11 years ago

I'm having the exact same problem (on Windows). Any ideas?

jelmerdemaat commented 11 years ago

It appears to me that the library is not (yet) usable for Windows users. The \\.\/dev/ thing is some kind of Unix/OSX thing that Windows doesn't understand, as the ports on Windows are named like COM3 or COM12. Changing the file doesn't make any difference though. You can use Ardugate as an alternative, for me that did work on Windows.

SerialPort-zz commented 11 years ago

Hi.

I unknow how TAKE the error. I try with the logic of language JavaScript:

var MySERIAL= new MySERIAL('COM1',{baudrate:57600}).on('error',function(err){ERROR=true;});

//Then I try take conditional: console.log(ERROR);

But NEVER I can take var ERROR (undefined)...

Some Idea please?

sarink commented 11 years ago

This doesn't work on Windows. I also tried using Ardugate, which is great for some simple demos and getting started I suppose...

Eventually I moved to node-serialport (which does work on Windows), and manually send custom serial instructions to the arduino, then catch them in the board's loop() function to do stuff.

SerialPort-zz commented 11 years ago

Thanks Sarink.

Iis different:

--serialport

--node-serialport

--Ardugate

???

sbstjn commented 11 years ago

I'm sorry, but Noduino has never been tested on Windows. You could try running linux in a virtual machine or try updating (node-)serialport to a recent version ( npm install serialport@1.1.0 ) and replace linux' /dev/ paths with the ones on Windows…

You should have a look at https://github.com/semu/node-arduino-socket. It uses serialport as well, but is a way smaller project. If you can get this (https://github.com/semu/node-arduino-socket/blob/master/serial.js) working with an updated version of serialport you can get Noduino running as well.

SerialPort-zz commented 11 years ago

updating (node-)serialport to a recent version

Sorry but I have serialport, version:

npm serialport -v 1.2.21

I only like TAKE the error of connection, as I say:

ERROR='some value';
var MySERIAL= new MySERIAL('COM666 or some other port FALSE',{baudrate:57600})
.on('error',function(err){
    ERROR='NEW VALUE!!!';
    });
//Then I try take conditional:
console.log(ERROR);

But NEVER the var ERROR change.

Some idea about how I UPDATE the value of the var ERROR?

THANKS !

sbstjn commented 11 years ago

var MySERIAL= new MySERIAL('COM666 or some other port FALSE', {baudrate:57600}).on('error', function(err){
  // This function is called on error, so do your stuff here
  // Maybe this function is never called, or maybe 2 seconds after startup
  // You never know…
  console.log(err);

  // You can set variables here as well
  var xyz = 1;
});

// But this won't work
console.log(xzy);
SerialPort-zz commented 11 years ago
    xyz=0;
    var MySERIAL= require('serialport').SerialPort;
    var MySERIAL= new MySERIAL('COM666 or some other port FALSE', {baudrate:57600})
    .on('error', function(err){
      // This function is called on error, so do your stuff here
      // Maybe this function is never called, or maybe 2 seconds after startup
      // You never know…
      console.log(err);     
      // You can set variables here as well
      var xyz = 1;
    });
    // But this won't work
    console.log(xzy);

yes, is CORRECT! Just AFTER of this lines I need evaluate value of {xyz} and then:

if(xyz==1){
    }
else {
    }

Can you paste here how is possible ???

Thanks

SerialPort-zz commented 11 years ago

I am creazy with this NODEJS... Here other example where I broken my brain:

var fs = require('fs');
fs.writeFile('./FILE.txt', "Hey there!", function(err) {
    if(err) {
        VV=123;
    } else {
        VV=987;
    }
});
console.log(VV);//Return FATAL ERROR becouse VV never is declarated...   :-s

How Is possible this!!!... Any example, or text to dummys in spanish ? ( SPECIALLY ABOUT THIS POINT )