Version1 /
serial Module(redirected from Version0.Serial) This module provides an interface to serial ports. FunctionsThe following functions are implemented by this module:
This implementation uses the event emitter pattern common in JavaScript. The events emitted by this object include:
UsageRequire the serial module: var serial = require('serial'); Running on CapeCodeRunning on node.jsThe SerialPort accessor can be invoked with the node host shell. Note: These instructions are for Linux. Change to the accessors web directory: cd /accessors/web Install serialport: npm install serialport Change to the node host directory: cd /accessors/web/hosts/node You may need to set a NODE_PATH environment variable: export NODE_PATH=/accessors/web/hosts/node/node_modules/@accessors-modules Connect a device to the desired USB port. Figure out the USB port name (TODO: how? Something we can call in node.js?) Start the node host shell. Use sudo for permissions to access the USB port. sudo -E node nodeHostShell.js Then, in the node host shell, instantiate the accessor: var a = instantiate('test', '/net/SerialPort'); Set the name of the port, using the name of your port: a.setParameter('port', '/dev/ttyUSB0'); Initialize the accessor: a.initialize(); Turn on your device to start sending data. Cape Code Serial modules
Back to Optional JavaScript Modules |