uMinded
uMinded

Reputation: 595

SerialPort has no method 'list'

I have a very simple script to just the available serial ports and then connect to one, write a char and put the response on the console. CODE HERE

In my scripts directory I did:

#npm install serialport
#npm list
 /home/uminded/Programming/nodeJS/test
 └─┬ [email protected]
   ├── [email protected]
     etc...
#node test.js
   spits out entire serialport.js to command line then...
 has no method 'list'
 at Object.<anonymous> (/home/uminded/Programming/nodeJS/test/test.js:4:12)
 at Module._compile (module.js:449:26)
 at Object.Module._extensions..js (module.js:467:10)
 at Module.load (module.js:356:32)
 at Function.Module._load (module.js:312:12)
 at Module.runMain (module.js:492:10)
 at process.startup.processNextTick.process._tickCallback (node.js:244:9)

The serialport.js script does have an export for SerialPort.list why can it not find it?

Also what program do you guys use for writing and debugging node related js?

Upvotes: 4

Views: 7845

Answers (1)

phihag
phihag

Reputation: 288090

list is a property of the serialport module, and not of serialport.SerialPort. Replace the first lines like this:

var serialport = require("serialport");
var SerialPort = serialport.SerialPort;
var util = require("util"), repl = require("repl");

serialport.list(function (err, ports) {
  ports.forEach(function(port) {
    console.log(port.comName);
    console.log(port.pnpId);
    console.log(port.manufacturer);
  });
});

Upvotes: 16

Related Questions