Giter Club home page Giter Club logo

at-commander's Introduction

AT Commander

Please note that this is still a beta version

Promise based AT(tention) command handler for serial ports (typically for use with external modem components and the like).

This module is ment to serve only as a basis for your specific device implementations - it is rather device agnostic, so to speak.

For a sample (beta) implementation of a real device see telit-modem

Features:

  • Send simple commands and receive boolean success/failure responses
  • Catch complex responses and preprocess
  • Set up notifications / event handlers for unsolicited messages
  • Command queue

This module uses the npm https://www.npmjs.com/package/serialport for serial communication.

Todos

  • Complete documentation..
  • Add more serialport configuration options (modem options are passthrough anyway, so just note that in the documentation...)
  • Add tests
  • Generic refactoring
  • Rethink timeout principle - is it ok like this or should it be remodelled? (timeout not absolute to actual command start but relative to last incoming data) (-> process.nextTick ??)

Possible issues

In case something doesn't work as expected, please first look here.

  • After an inbuffer handling change (auto-discard of CR/NL prefixes) reading a specific number of bytes might have an unexpected behaviour. Well, changing this ment a simplification of usage but also a change in semantics as incoming data is being interpreted.

Overview

Usage

Example

var ATCommander = require('at-commander');
var Command = ATCommander.Command;

// all options are optional, these are the default options
var opts = {
    // the following options define the options used by serialport
    parser: serialport.parsers.raw,
    baudRate: 115200,
    dataBits: 8,
    stopBits: 1,

    // command termination string (is added to every normal string type command)
    EOL: "\r\n",

    // this regex is used by default to detect one-line responses
    lineRegex: /^\r\n(.+)\r\n/,

    // (default) command timeout
    timeout: 500
};

var modem = new ATCommander.Modem(opts);

var port = 'COM4'; // on Windows
var port = '/tty/serial/by-id/blabalbla'; // linux based machines

modem.open(port).catch((err) => {
    console.log("Failed to open serial", err);
}).then(function(){

    // check if a response is coming
    // NOTE: run(command) bypasses the command queue and is executed immediatly (unless another command is being executed already)
    modem.run('AT').then((success) => {

        modem.startProcessing();

    });

    // fill up command queue
    // queue is only processed it modem.startProcessing() is called.
    modem.addCommand('AT+CMG=1');

    // identical to previous command
    modem.addCommand('AT+CMG=1', undefined);

    // with expected result 'OK' and command specific timeout
    modem.addCommand('AT+FOOO', 'OK', {
        timeout: 10000
    }).then(function(){
        // command got expected response
    }).catch(function(command){
        // some error occurred
    });

    // consider the next incoming 6 bytes as the wanted response
    modem.addCommand('AT+FOOO', 6).then(function(buffer){
        // buffer contains the next 6 incoming bytes (please note, that beginning CR + NL characters are trimmed automatically, thus (at the moment) if you expect to be reading only these characters your logic will fail)
    }).catch(function(command){
        // most likely to fail only if there is a timeout
    });

    modem.addCommand('AT+CREG=?', /\+CREG=(.*),(.*)/).then((matches) => {
        // matches contains the response's string matches according to the given regex
    });

    modem.addCommand('AT+FOOO',  function(buffer){
        // complex response detectors are passed the updated response buffer contents whenever there is new data arriving
        var str = buffer.toString();
        if (str.matches(/^OK/r/n/){
            return 4; // return the byte count the response (these many bytes will be consumed from the buffer)
        }
        return 0; // return 0 if expected response not received yet
    }).then((buffer) => {
        // complex response detectors receive the whole (consumed) buffer as argument
    });


    // add a notification
    modem.addNotification('myEventName', /^+CMI=(.*),(.*)/, function(buffer, matches) {
        modem.addCommand("AT+CMR="+matches[1], parseInt(matches[2])).then((buf) => {
            // buf contains my wanted result
        });
    });


    modem.addNotification('shutdown', /SHUTDOWN/, function(){
        modem.close();
    });
});

Promise based commands

The Modem methods run, addCommand return a promise that will be resolved/rejected with variable parameters that depend on the (Command)[#command] options.

The following setup illustrates the differences

var CommandStates = require('at-commander').CommandStates;

// please note, it is also possible to call modem.run directly with the arguments as passed to the constructor of command
// modem.run thus is just a nice wrapper
var myCommand = new ATCommander.Command(cmd, expected);
modem.run(myCommand).then(function(result){
    if (typeof expected === 'undefined' || typeof expected === 'string'){
        // result is a boolean denoting wether the one-line response matched the expected value
        // in case expected was undefined, the default response (OK) is assumed
        // NOTE this will have to be refactored to make it configurable on the fly
    }
    if (typeof expected === 'number'){
        // result will be of type Buffer container the number of bytes as denoted by expected
    }
    if (expected instanceof RegExp){
        // result will be the return value of inBufferString.match(expected)
    }
    if (typeof expected === 'function'){
        // result will be the relevant inBuffer part that was detected using expected
    }



}).catch(function(command){
    // in case of an error, the given object is an instance of Command
    // command is the same object as myCommand

    // furthermore several fields will be set:

    switch (command.state){

        case CommandStates.Init:
            //this state should never occur in an error case
            break;

        case CommandStates.Rejected:
            // this state only occurs when passing a command using .run() (or write(), read())
            // and denotes the situation where the modem is already processing a command
            // (this is because .run() bypasses the command queue)
            break;

        case CommandStates.Running:
            // this state should never occur in an error/catch case
            // it denotes that the command is being processed by the modem
            break;

        case CommandStates.Finished:
            // this state should never occur in an error/catch case
            // it denotes that the command terminated as configured

            // command.result.buf -> read buffer that satisfied the expected result requirements

            break;

        case CommandStates.Failed:
            // this state occurs if the commands result processor function returns an undefined value
            // by default this will also be the case if the expected result is a string type and the read in line
            // did not match (thus causing a rejection)
            // note that if you provide result processor functions yourself, you might want to be aware of this (or
            // make use of it)

            // command.result.buf -> read line that did not match

            break;

        case CommandStates.Timeout:
            // this state denotes that there was no reply from the attached serial device in the given time constraint
            // also the contents of the inBuffer will be passed to the command (and consumed from the inBuffer)

            // command.result.buf -> will be a Buffer object

            break;

        case CommandStates.Aborted:
            // this state denotes that the command was user aborted
            break;
    }


});

Classes

Modem

Modem (options)

See setConfig(options).

getConfig ()

Returns config..

setConfig (options)

options (optional)

open (path)

path

Denotes path to serial port (on linux typically something like /tty/tty.serialXYZ, on windows COM4)

Returns a promise.

isOpen ()

Facade for https://www.npmjs.com/package/serialport#isopen

pause ()

Facade for https://www.npmjs.com/package/serialport#pause

close (callback)

Forces serial shutdown. Facade for https://www.npmjs.com/package/serialport#close-callback

closeGracefully (callback)

If tries to finish any pending commands before shutting down serial.

on (event, callback)

Please refer to Events

isProcessingCommands ()

If set to true, command queue will be automatically processed.

startProcessing ()

Start automatic processing of command queue.

stopProcessing (abortCurrent, callback)

Stop automatic processing of command queue.

boolean abortCurrent (optional)

function callback (optional)

Callback to run once abortion completes.

getPendingCommands ()

Returns array of pending (Commands)[#command]

clearPendingCommands ()

Cleats pending commands list.

getCurrentCommand ()

Returns false if no command is pending at the moment, (Command)[#command] otherwise.

abortCurrentCommand ()

run (command, expected, options)

If and only if no other command is currently being processed, runs the given command

string|buffer|Command command (required)

If it is a (Command)[#command], any other parameters are ignored, otherwise the string|buffer is used as command to write to the serial.

string|number|regex|function expected (optional, default: OK)

object options (optional)

  • timeout: command timeout in msec (if not defined, default of modem is used, see setConfig())
  • resultProcessor: result preprocessor, it's result will be considered the processed and final result as passed to promise

Returns a promise.

addCommand (command, expected, options)

Adds the given command to the pending commands list. The calling semantics are identical to run(command, expected, callback, processor)

Returns a promise.

read (n)

Shortcut helper to run a command that just reads n bytes. NOTE: after some refactoring initial CR|NL are automatically discarded and will thus never be read. This will likely have to change..

number n (required)

Number of bytes to read.

Returns a promise.

write (buffer)

Shortcut helper to run a command that just writes buffer to serial and does not wait for a response.

Buffer buffer (required)

Buffer to write to serial.

Returns a promise.

getInBuffer ()

Get contents of serial in buffer.

clearInBuffer ()

Clear contents of serial in buffer.

getNotifications ()

Get array of registered notifications.

clearNotifications ()

Clear deregister all notifications.

addNotification (notification, regex, handler)

Register a new notification.

string|Notification notification (required)

In case a Notification is passed the remaining parameters are ignored. Otherwise a string to uniquely identify the notification is expected. Will overwrite any previsouly notifications with the same value.

RegExp regex (optional)

Matching expression that will be looked out for in the buffer to detect any unsolicited incoming data.

function handler(Buffer buffer, Array matches) (optional)

Notification handler that will be called once regex matches incoming data. Will be passed the whole matches buffer and corresponding matches as arguments.

removeNotification (name)

Unregister notification with given name.

Command

var Command = require('at-commander').Command;

var myCommand = new Command(command, expected, options);

modem.run(myCommand); // or
modem.addCommand(myCommand);

The constructor semantics are very much identical to the options of run(command, expected, options) which serves as shortcut.

Notification

var Notification = require('at-commander').Notification;

var myNotification = new Notification(name, regex, handler);

modem.addNotification(myNotification);

Please note that addNotification(notification, regex, handler) is the friendly shortcut.

Events

Event handlers can be set using Modem.on(eventName, callback)

open

Please see https://www.npmjs.com/package/serialport#onopen-callback

close

https://www.npmjs.com/package/serialport#onclose-callback

data

Please see https://www.npmjs.com/package/serialport#ondata-callback

disconnect

Please see https://www.npmjs.com/package/serialport#ondisconnect-callback

error

Please see https://www.npmjs.com/package/serialport#onerror-callback

notification

Will be called if any registered notification matches incoming data. WARNING: currently disabled, will have to be refactored

command

The command event is triggered if a command successfully completes.

function callback(Command command, result)

The type/contents of result is according to the command operations (also see section Promise based commands). The most interesting thing about this callback is that it contains the used Command object which in particular also has the following interesting properties:

command.result.buf -> complete accepted response of type Buffer
command.result.matches -> if and only if an expected response using a matching mechanism is used: the resulting matches
command.result.processed -> if and only if a (default or custom) processor function is passed to the command (will be the same as result)

discarding

The discarding event is triggered if the inBuffer discards data due to a timeout.

function callback(Buffer buffer)

at-commander's People

Contributors

tschiemer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

at-commander's Issues

Package can not be installed on Darwin and Linux-armv6l ([email protected])

Full yarn output:

pi@raspberrypi:~/hekkie $ yarn
yarn install v1.12.3
warning package.json: No license field
warning No license field
[1/4] Resolving packages...
warning Lockfile has incorrect entry for "[email protected]". Ignoring it.
warning at-commander > serialport > node-pre-gyp > hawk > [email protected]: This version is no longer maintained. Please upgrade to the latest version.
warning at-commander > serialport > node-pre-gyp > hawk > [email protected]: This version is no longer maintained. Please upgrade to the latest version.
warning at-commander > serialport > node-pre-gyp > hawk > boom > [email protected]: This version is no longer maintained. Please upgrade to the latest version.
warning at-commander > serialport > node-pre-gyp > hawk > [email protected]: This version is no longer maintained. Please upgrade to the latest version.
warning at-commander > serialport > node-pre-gyp > hawk > cryptiles > [email protected]: This version is no longer maintained. Please upgrade to the latest version.
warning at-commander > serialport > node-pre-gyp > hawk > sntp > [email protected]: This version is no longer maintained. Please upgrade to the latest version.
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
error /home/pi/hekkie/node_modules/serialport: Command failed.
Exit code: 1
Command: node-pre-gyp install --fallback-to-build
Arguments: 
Directory: /home/pi/hekkie/node_modules/serialport
Output:
node-pre-gyp info it worked if it ends with ok
node-pre-gyp info using [email protected]
node-pre-gyp info using [email protected] | linux | arm
node-pre-gyp info check checked for "/home/pi/hekkie/node_modules/serialport/build/Release/serialport.node" (not found)
node-pre-gyp http GET https://github.com/EmergingTechnologyAdvisors/node-serialport/releases/download/5.0.0/serialport-v5.0.0-node-v67-linux-arm.tar.gz
node-pre-gyp http 404 https://github.com/EmergingTechnologyAdvisors/node-serialport/releases/download/5.0.0/serialport-v5.0.0-node-v67-linux-arm.tar.gz
node-pre-gyp ERR! Tried to download(404): https://github.com/EmergingTechnologyAdvisors/node-serialport/releases/download/5.0.0/serialport-v5.0.0-node-v67-linux-arm.tar.gz 
node-pre-gyp ERR! Pre-built binaries not found for [email protected] and [email protected] (node-v67 ABI, glibc) (falling back to source compile with node-gyp) 
node-pre-gyp http 404 status code downloading tarball https://github.com/EmergingTechnologyAdvisors/node-serialport/releases/download/5.0.0/serialport-v5.0.0-node-v67-linux-arm.tar.gz 
node-pre-gyp ERR! Tried to download(undefined): https://github.com/EmergingTechnologyAdvisors/node-serialport/releases/download/5.0.0/serialport-v5.0.0-node-v67-linux-arm.tar.gz 
node-pre-gyp ERR! Pre-built binaries not found for [email protected] and [email protected] (node-v67 ABI, glibc) (falling back to source compile with node-gyp) 
node-pre-gyp http Connection closed while downloading tarball file 
gypgyp  info infoit worked if it ends with ok
 it worked if it ends with ok
gypgyp info using  [email protected]
info using [email protected]
gyp info using [email protected] | linux | arm
gyp info using [email protected] | linux | arm
gypgyp info  infook  
ok 
gyp info it worked if it ends with ok
gyp info it worked if it ends with ok
gyp info using [email protected]
gyp info using [email protected] | linux | arm
gyp info using [email protected]
gyp info using [email protected] | linux | arm
gyp infogyp info  spawn /usr/bin/python2
spawn /usr/bin/python2
gypgyp  infoinfo  spawn argsspawn args [ '/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
 [ '/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
gypgyp info spawn args   'binding.gyp',
gyp info  info spawn args   'binding.gyp',
gyp spawn args   '-f',
gyp info spawn args   'make',
gyp info spawn args   '-I',
gyp info spawn args   '/home/pi/hekkie/node_modules/serialport/build/config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '-f',
gyp info spawn args   'make',
gyp info spawn args   '-I',
gyp infoinfo  spawn args   '/home/pi/hekkie/node_modules/serialport/build/config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/usr/local/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/usr/local/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/home/pi/.node-gyp/11.4.0/include/node/common.gypi',
gyp spawn argsinfo   '/home/pi/.node-gyp/11.4.0/include/node/common.gypi',
 gypspawn args   '-Dlibrary=shared_library',
gyp info  info spawn args   '-Dvisibility=default',
gypspawn args   '-Dlibrary=shared_library',
gyp  infoinfo  spawn argsspawn args   '-Dvisibility=default',
gyp info    '-Dnode_root_dir=/home/pi/.node-gyp/11.4.0',
gyp infospawn args    '-Dnode_root_dir=/home/pi/.node-gyp/11.4.0',
spawn argsgyp info spawn args   '-Dnode_gyp_dir=/usr/local/lib/node_modules/npm/node_modules/node-gyp',
gyp info spawn args   '-Dnode_gyp_dir=/usr/local/lib/node_modules/npm/node_modules/node-gyp',
gyp info spawn args   '-Dnode_lib_file=/home/pi/.node-gyp/11.4.0/<(target_arch)/node.lib',
gyp info spawn args   '-Dmodule_root_dir=/home/pi/hekkie/node_modules/serialport',
gyp info   '-Dnode_lib_file=/home/pi/.node-gyp/11.4.0/<(target_arch)/node.lib',
gyp info spawn args   '-Dmodule_root_dir=/home/pi/hekkie/node_modules/serialport',
gyp info  spawn argsspawn args   '-Dnode_engine=v8',
   '-Dnode_engine=v8',
gypgyp  infoinfo  spawn argsspawn args   '--depth=.',
   '--depth=.',
gyp info spawn args   '--no-parallel',
gyp info spawn args   '--generator-output',
gyp info spawn args   'build',
gyp info spawn args   '-Goutput_dir=.' ]
gyp info spawn args   '--no-parallel',
gyp info spawn args   '--generator-output',
gyp info spawn args   'build',
gyp info spawn args   '-Goutput_dir=.' ]
gyp info ok 
gyp info ok 
gyp info it worked if it ends with ok
gypgyp info using [email protected]
 gyp info infousing [email protected] | linux | arm
 it worked if it ends with ok
gyp info using [email protected]
gyp info using [email protected] | linux | arm
gyp info spawn make
gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
make: Entering directory '/home/pi/hekkie/node_modules/serialport/build'
  CXX(target) Release/obj.target/serialport/src/serialport.o
gyp info spawn make
gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
make: Entering directory '/home/pi/hekkie/node_modules/serialport/build'
  CXX(target) Release/obj.target/serialport/src/serialport.o
In file included from ../src/./serialport.h:6:0,
                 from ../src/serialport.cpp:1:
../../nan/nan.h: In constructor 'Nan::Utf8String::Utf8String(v8::Local<v8::Value>)':
../../nan/nan.h:1064:78: warning: 'v8::Local<v8::String> v8::Value::ToString(v8::Isolate*) const' is deprecated: Use maybe version [-Wdeprecated-declarations]
       v8::Local<v8::String> string = from->ToString(v8::Isolate::GetCurrent());
                                                                              ^
In file included from /home/pi/.node-gyp/11.4.0/include/node/v8.h:26:0,
                 from /home/pi/.node-gyp/11.4.0/include/node/node.h:63,
                 from ../../nan/nan.h:52,
                 from ../src/./serialport.h:6,
                 from ../src/serialport.cpp:1:
/home/pi/.node-gyp/11.4.0/include/node/v8.h:2538:31: note: declared here
                 Local<String> ToString(Isolate* isolate) const);
                               ^
/home/pi/.node-gyp/11.4.0/include/node/v8config.h:326:3: note: in definition of macro 'V8_DEPRECATED'
   declarator __attribute__((deprecated(message)))
   ^~~~~~~~~~
In file included from ../src/./serialport.h:6:0,
                 from ../src/serialport.cpp:1:
../../nan/nan.h: In constructor 'Nan::Utf8String::Utf8String(v8::Local<v8::Value>)':
../../nan/nan.h:1064:78: warning: 'v8::Local<v8::String> v8::Value::ToString(v8::Isolate*) const' is deprecated: Use maybe version [-Wdeprecated-declarations]
       v8::Local<v8::String> string = from->ToString(v8::Isolate::GetCurrent());
                                                                              ^
In file included from /home/pi/.node-gyp/11.4.0/include/node/v8.h:26:0,
                 from /home/pi/.node-gyp/11.4.0/include/node/node.h:63,
                 from ../../nan/nan.h:52,
                 from ../src/./serialport.h:6,
                 from ../src/serialport.cpp:1:
/home/pi/.node-gyp/11.4.0/include/node/v8.h:2538:31: note: declared here
                 Local<String> ToString(Isolate* isolate) const);
                               ^
/home/pi/.node-gyp/11.4.0/include/node/v8config.h:326:3: note: in definition of macro 'V8_DEPRECATED'
   declarator __attribute__((deprecated(message)))
   ^~~~~~~~~~
../src/serialport.cpp: In function 'Nan::NAN_METHOD_RETURN_TYPE Open(Nan::NAN_METHOD_ARGS_TYPE)':
../src/serialport.cpp:41:48: warning: 'v8::Local<v8::String> v8::Value::ToString() const' is deprecated: Use maybe version [-Wdeprecated-declarations]
   v8::String::Utf8Value path(info[0]->ToString());
                                                ^
In file included from /home/pi/.node-gyp/11.4.0/include/node/node.h:63:0,
                 from ../../nan/nan.h:52,
                 from ../src/./serialport.h:6,
                 from ../src/serialport.cpp:1:
/home/pi/.node-gyp/11.4.0/include/node/v8.h:10248:15: note: declared here
 Local<String> Value::ToString() const {
               ^~~~~
../src/serialport.cpp:41:49: warning: 'v8::String::Utf8Value::Utf8Value(v8::Local<v8::Value>)' is deprecated: Use Isolate version [-Wdeprecated-declarations]
   v8::String::Utf8Value path(info[0]->ToString());
                                                 ^
../src/serialport.cpp: In function 'Nan::NAN_METHOD_RETURN_TYPE Open(Nan::NAN_METHOD_ARGS_TYPE)':
../src/serialport.cpp:41:48: warning: 'v8::Local<v8::String> v8::Value::ToString() const' is deprecated: Use maybe version [-Wdeprecated-declarations]
   v8::String::Utf8Value path(info[0]->ToString());
                                                ^
In file included from /home/pi/.node-gyp/11.4.0/include/node/v8.h:26:0,
                 from /home/pi/.node-gyp/11.4.0/include/node/node.h:63,
                 from ../../nan/nan.h:52,
                 from ../src/./serialport.h:6,
                 from ../src/serialport.cpp:1:
/home/pi/.node-gyp/11.4.0/include/node/v8.h:2992:28: note: declared here
                   explicit Utf8Value(Local<v8::Value> obj));
                            ^
/home/pi/.node-gyp/11.4.0/include/node/v8config.h:326:3: note: in definition of macro 'V8_DEPRECATED'
   declarator __attribute__((deprecated(message)))
   ^~~~~~~~~~
../src/serialport.cpp:48:53: warning: 'v8::Local<v8::Object> v8::Value::ToObject() const' is deprecated: Use maybe version [-Wdeprecated-declarations]
   v8::Local<v8::Object> options = info[1]->ToObject();
                                                     ^
In file included from /home/pi/.node-gyp/11.4.0/include/node/node.h:63:0,
                 from ../../nan/nan.h:52,
                 from ../src/./serialport.h:6,
                 from ../src/serialport.cpp:1:
/home/pi/.node-gyp/11.4.0/include/node/v8.h:10254:15: note: declared here
 Local<Object> Value::ToObject() const {
               ^~~~~
In file included from /home/pi/.node-gyp/11.4.0/include/node/node.h:63:0,
                 from ../../nan/nan.h:52,
                 from ../src/./serialport.h:6,
                 from ../src/serialport.cpp:1:
/home/pi/.node-gyp/11.4.0/include/node/v8.h:10248:15: note: declared here
 Local<String> Value::ToString() const {
               ^~~~~
../src/serialport.cpp:41:49: warning: 'v8::String::Utf8Value::Utf8Value(v8::Local<v8::Value>)' is deprecated: Use Isolate version [-Wdeprecated-declarations]
   v8::String::Utf8Value path(info[0]->ToString());
                                                 ^
In file included from /home/pi/.node-gyp/11.4.0/include/node/v8.h:26:0,
                 from /home/pi/.node-gyp/11.4.0/include/node/node.h:63,
                 from ../../nan/nan.h:52,
                 from ../src/./serialport.h:6,
                 from ../src/serialport.cpp:1:
/home/pi/.node-gyp/11.4.0/include/node/v8.h:2992:28: note: declared here
                   explicit Utf8Value(Local<v8::Value> obj));
                            ^
/home/pi/.node-gyp/11.4.0/include/node/v8config.h:326:3: note: in definition of macro 'V8_DEPRECATED'
   declarator __attribute__((deprecated(message)))
   ^~~~~~~~~~
../src/serialport.cpp:48:53: warning: 'v8::Local<v8::Object> v8::Value::ToObject() const' is deprecated: Use maybe version [-Wdeprecated-declarations]
   v8::Local<v8::Object> options = info[1]->ToObject();
                                                     ^
In file included from /home/pi/.node-gyp/11.4.0/include/node/node.h:63:0,
                 from ../../nan/nan.h:52,
                 from ../src/./serialport.h:6,
                 from ../src/serialport.cpp:1:
/home/pi/.node-gyp/11.4.0/include/node/v8.h:10254:15: note: declared here
 Local<Object> Value::ToObject() const {
               ^~~~~
../src/serialport.cpp: In function 'void EIO_AfterOpen(uv_work_t*)':
../src/serialport.cpp:96:30: warning: 'v8::Local<v8::Value> Nan::Callback::Call(int, v8::Local<v8::Value>*) const' is deprecated [-Wdeprecated-declarations]
   data->callback.Call(2, argv);
                              ^
In file included from ../src/./serialport.h:6:0,
                 from ../src/serialport.cpp:1:
../../nan/nan.h:1655:3: note: declared here
   Call(int argc, v8::Local<v8::Value> argv[]) const {
   ^~~~
../src/serialport.cpp: In function 'void EIO_AfterOpen(uv_work_t*)':
../src/serialport.cpp:96:30: warning: 'v8::Local<v8::Value> Nan::Callback::Call(int, v8::Local<v8::Value>*) const' is deprecated [-Wdeprecated-declarations]
   data->callback.Call(2, argv);
                              ^
../src/serialport.cpp: In function 'Nan::NAN_METHOD_RETURN_TYPE Update(Nan::NAN_METHOD_ARGS_TYPE)':
../src/serialport.cpp:114:53: warning: 'v8::Local<v8::Object> v8::Value::ToObject() const' is deprecated: Use maybe version [-Wdeprecated-declarations]
   v8::Local<v8::Object> options = info[1]->ToObject();
                                                     ^
In file included from /home/pi/.node-gyp/11.4.0/include/node/node.h:63:0,
                 from ../../nan/nan.h:52,
                 from ../src/./serialport.h:6,
                 from ../src/serialport.cpp:1:
/home/pi/.node-gyp/11.4.0/include/node/v8.h:10254:15: note: declared here
 Local<Object> Value::ToObject() const {
               ^~~~~
In file included from ../src/./serialport.h:6:0,
                 from ../src/serialport.cpp:1:
../../nan/nan.h:1655:3: note: declared here
   Call(int argc, v8::Local<v8::Value> argv[]) const {
   ^~~~
../src/serialport.cpp: In function 'Nan::NAN_METHOD_RETURN_TYPE Update(Nan::NAN_METHOD_ARGS_TYPE)':
../src/serialport.cpp:114:53: warning: 'v8::Local<v8::Object> v8::Value::ToObject() const' is deprecated: Use maybe version [-Wdeprecated-declarations]
   v8::Local<v8::Object> options = info[1]->ToObject();
                                                     ^
In file included from /home/pi/.node-gyp/11.4.0/include/node/node.h:63:0,
                 from ../../nan/nan.h:52,
                 from ../src/./serialport.h:6,
                 from ../src/serialport.cpp:1:
/home/pi/.node-gyp/11.4.0/include/node/v8.h:10254:15: note: declared here
 Local<Object> Value::ToObject() const {
               ^~~~~
../src/serialport.cpp: In function 'void EIO_AfterUpdate(uv_work_t*)':
../src/serialport.cpp:152:30: warning: 'v8::Local<v8::Value> Nan::Callback::Call(int, v8::Local<v8::Value>*) const' is deprecated [-Wdeprecated-declarations]
   data->callback.Call(1, argv);
                              ^
In file included from ../src/./serialport.h:6:0,
                 from ../src/serialport.cpp:1:
../../nan/nan.h:1655:3: note: declared here
   Call(int argc, v8::Local<v8::Value> argv[]) const {
   ^~~~
../src/serialport.cpp: In function 'void EIO_AfterUpdate(uv_work_t*)':
../src/serialport.cpp:152:30: warning: 'v8::Local<v8::Value> Nan::Callback::Call(int, v8::Local<v8::Value>*) const' is deprecated [-Wdeprecated-declarations]
   data->callback.Call(1, argv);
                              ^
In file included from ../src/./serialport.h:6:0,
                 from ../src/serialport.cpp:1:
../../nan/nan.h:1655:3: note: declared here
   Call(int argc, v8::Local<v8::Value> argv[]) const {
   ^~~~
../src/serialport.cpp: In function 'void EIO_AfterClose(uv_work_t*)':
../src/serialport.cpp:191:30: warning: 'v8::Local<v8::Value> Nan::Callback::Call(int, v8::Local<v8::Value>*) const' is deprecated [-Wdeprecated-declarations]
   data->callback.Call(1, argv);
                              ^
In file included from ../src/./serialport.h:6:0,
                 from ../src/serialport.cpp:1:
../../nan/nan.h:1655:3: note: declared here
   Call(int argc, v8::Local<v8::Value> argv[]) const {
   ^~~~
../src/serialport.cpp: In function 'void EIO_AfterClose(uv_work_t*)':
../src/serialport.cpp:191:30: warning: 'v8::Local<v8::Value> Nan::Callback::Call(int, v8::Local<v8::Value>*) const' is deprecated [-Wdeprecated-declarations]
   data->callback.Call(1, argv);
                              ^
In file included from ../src/./serialport.h:6:0,
                 from ../src/serialport.cpp:1:
../../nan/nan.h:1655:3: note: declared here
   Call(int argc, v8::Local<v8::Value> argv[]) const {
   ^~~~
../src/serialport.cpp: In function 'void EIO_AfterFlush(uv_work_t*)':
../src/serialport.cpp:235:30: warning: 'v8::Local<v8::Value> Nan::Callback::Call(int, v8::Local<v8::Value>*) const' is deprecated [-Wdeprecated-declarations]
   data->callback.Call(1, argv);
                              ^
In file included from ../src/./serialport.h:6:0,
                 from ../src/serialport.cpp:1:
../../nan/nan.h:1655:3: note: declared here
   Call(int argc, v8::Local<v8::Value> argv[]) const {
   ^~~~
../src/serialport.cpp: In function 'void EIO_AfterFlush(uv_work_t*)':
../src/serialport.cpp:235:30: warning: 'v8::Local<v8::Value> Nan::Callback::Call(int, v8::Local<v8::Value>*) const' is deprecated [-Wdeprecated-declarations]
   data->callback.Call(1, argv);
                              ^
../src/serialport.cpp: In function 'Nan::NAN_METHOD_RETURN_TYPE Set(Nan::NAN_METHOD_ARGS_TYPE)':
../src/serialport.cpp:254:53: warning: 'v8::Local<v8::Object> v8::Value::ToObject() const' is deprecated: Use maybe version [-Wdeprecated-declarations]
   v8::Local<v8::Object> options = info[1]->ToObject();
                                                     ^
In file included from /home/pi/.node-gyp/11.4.0/include/node/node.h:63:0,
                 from ../../nan/nan.h:52,
                 from ../src/./serialport.h:6,
                 from ../src/serialport.cpp:1:
/home/pi/.node-gyp/11.4.0/include/node/v8.h:10254:15: note: declared here
 Local<Object> Value::ToObject() const {
               ^~~~~
In file included from ../src/./serialport.h:6:0,
                 from ../src/serialport.cpp:1:
../../nan/nan.h:1655:3: note: declared here
   Call(int argc, v8::Local<v8::Value> argv[]) const {
   ^~~~
../src/serialport.cpp: In function 'Nan::NAN_METHOD_RETURN_TYPE Set(Nan::NAN_METHOD_ARGS_TYPE)':
../src/serialport.cpp:254:53: warning: 'v8::Local<v8::Object> v8::Value::ToObject() const' is deprecated: Use maybe version [-Wdeprecated-declarations]
   v8::Local<v8::Object> options = info[1]->ToObject();
                                                     ^
In file included from /home/pi/.node-gyp/11.4.0/include/node/node.h:63:0,
                 from ../../nan/nan.h:52,
                 from ../src/./serialport.h:6,
                 from ../src/serialport.cpp:1:
/home/pi/.node-gyp/11.4.0/include/node/v8.h:10254:15: note: declared here
 Local<Object> Value::ToObject() const {
               ^~~~~
../src/serialport.cpp: In function 'void EIO_AfterSet(uv_work_t*)':
../src/serialport.cpp:290:30: warning: 'v8::Local<v8::Value> Nan::Callback::Call(int, v8::Local<v8::Value>*) const' is deprecated [-Wdeprecated-declarations]
   data->callback.Call(1, argv);
                              ^
In file included from ../src/./serialport.h:6:0,
                 from ../src/serialport.cpp:1:
../../nan/nan.h:1655:3: note: declared here
   Call(int argc, v8::Local<v8::Value> argv[]) const {
   ^~~~
../src/serialport.cpp: In function 'void EIO_AfterSet(uv_work_t*)':
../src/serialport.cpp:290:30: warning: 'v8::Local<v8::Value> Nan::Callback::Call(int, v8::Local<v8::Value>*) const' is deprecated [-Wdeprecated-declarations]
   data->callback.Call(1, argv);
                              ^
In file included from ../src/./serialport.h:6:0,
                 from ../src/serialport.cpp:1:
../../nan/nan.h:1655:3: note: declared here
   Call(int argc, v8::Local<v8::Value> argv[]) const {
   ^~~~
../src/serialport.cpp: In function 'void EIO_AfterGet(uv_work_t*)':
../src/serialport.cpp:342:30: warning: 'v8::Local<v8::Value> Nan::Callback::Call(int, v8::Local<v8::Value>*) const' is deprecated [-Wdeprecated-declarations]
   data->callback.Call(2, argv);
                              ^
In file included from ../src/./serialport.h:6:0,
                 from ../src/serialport.cpp:1:
../../nan/nan.h:1655:3: note: declared here
   Call(int argc, v8::Local<v8::Value> argv[]) const {
   ^~~~
../src/serialport.cpp: In function 'void EIO_AfterGet(uv_work_t*)':
../src/serialport.cpp:342:30: warning: 'v8::Local<v8::Value> Nan::Callback::Call(int, v8::Local<v8::Value>*) const' is deprecated [-Wdeprecated-declarations]
   data->callback.Call(2, argv);
                              ^
In file included from ../src/./serialport.h:6:0,
                 from ../src/serialport.cpp:1:
../../nan/nan.h:1655:3: note: declared here
   Call(int argc, v8::Local<v8::Value> argv[]) const {
   ^~~~
../src/serialport.cpp: In function 'void EIO_AfterDrain(uv_work_t*)':
../src/serialport.cpp:384:30: warning: 'v8::Local<v8::Value> Nan::Callback::Call(int, v8::Local<v8::Value>*) const' is deprecated [-Wdeprecated-declarations]
   data->callback.Call(1, argv);
                              ^
In file included from ../src/./serialport.h:6:0,
                 from ../src/serialport.cpp:1:
../../nan/nan.h:1655:3: note: declared here
   Call(int argc, v8::Local<v8::Value> argv[]) const {
   ^~~~
../src/serialport.cpp: In function 'void EIO_AfterDrain(uv_work_t*)':
../src/serialport.cpp:384:30: warning: 'v8::Local<v8::Value> Nan::Callback::Call(int, v8::Local<v8::Value>*) const' is deprecated [-Wdeprecated-declarations]
   data->callback.Call(1, argv);
                              ^
In file included from ../src/./serialport.h:6:0,
                 from ../src/serialport.cpp:1:
../../nan/nan.h:1655:3: note: declared here
   Call(int argc, v8::Local<v8::Value> argv[]) const {
   ^~~~
sed: can't read ./Release/.deps/Release/obj.target/serialport/src/serialport.o.d.raw: No such file or directory
  CXX(target) Release/obj.target/serialport/src/serialport_unix.o
rm: cannot remove './Release/.deps/Release/obj.target/serialport/src/serialport.o.d.raw': No such file or directory
serialport.target.mk:101: recipe for target 'Release/obj.target/serialport/src/serialport.o' failed
make: *** [Release/obj.target/serialport/src/serialport.o] Error 1
make: Leaving directory '/home/pi/hekkie/node_modules/serialport/build'
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:262:23)
gyp ERR! stack     at ChildProcess.emit (events.js:189:13)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:254:12)
gyp ERR! System Linux 4.14.79+
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "build" "--fallback-to-build" "--module=/home/pi/hekkie/node_modules/serialport/build/Release/serialport.node" "--module_name=serialport" "--module_path=/home/pi/hekkie/node_modules/serialport/build/Release"
gyp ERR! cwd /home/pi/hekkie/node_modules/serialport
gyp ERR! node -v v11.4.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok 
node-pre-gyp ERR! build error 
node-pre-gyp ERR! stack Error: Failed to execute '/usr/local/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/home/pi/hekkie/node_modules/serialport/build/Release/serialport.node --module_name=serialport --module_path=/home/pi/hekkie/node_modules/serialport/build/Release' (1)
node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (/home/pi/hekkie/node_modules/node-pre-gyp/lib/util/compile.js:83:29)
node-pre-gyp ERR! stack     at ChildProcess.emit (events.js:189:13)
node-pre-gyp ERR! stack     at maybeClose (internal/child_process.js:978:16)
node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:265:5)
node-pre-gyp ERR! System Linux 4.14.79+
node-pre-gyp ERR! command "/usr/local/bin/node" "/home/pi/hekkie/node_modules/serialport/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd /home/pi/hekkie/node_modules/serialport
node-pre-gyp ERR! node -v v11.4.0
node-pre-gyp ERR! node-pre-gyp -v v0.6.39
node-pre-gyp ERR! not ok 
Failed to execute '/usr/local/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/home/pi/hekkie/node_modules/serialport/build/Release/serialport.node --module_name=serialport --module_path=/home/pi/hekkie/node_modules/serialport/build/Release' (1)
In file included from ../src/./serialport.h:6:0,
                 from ../src/serialport_unix.cpp:2:
../../nan/nan.h: In constructor 'Nan::Utf8String::Utf8String(v8::Local<v8::Value>)':
../../nan/nan.h:1064:78: warning: 'v8::Local<v8::String> v8::Value::ToString(v8::Isolate*) const' is deprecated: Use maybe version [-Wdeprecated-declarations]
       v8::Local<v8::String> string = from->ToString(v8::Isolate::GetCurrent());
                                                                              ^
In file included from /home/pi/.node-gyp/11.4.0/include/node/v8.h:26:0,
                 from /home/pi/.node-gyp/11.4.0/include/node/node.h:63,
                 from ../../nan/nan.h:52,
                 from ../src/./serialport.h:6,
                 from ../src/serialport_unix.cpp:2:
/home/pi/.node-gyp/11.4.0/include/node/v8.h:2538:31: note: declared here
                 Local<String> ToString(Isolate* isolate) const);
                               ^
/home/pi/.node-gyp/11.4.0/include/node/v8config.h:326:3: note: in definition of macro 'V8_DEPRECATED'
   declarator __attribute__((deprecated(message)))
   ^~~~~~~~~~
  CXX(target) Release/obj.target/serialport/src/poller.o
In file included from ../src/poller.cpp:1:0:
../../nan/nan.h: In constructor 'Nan::Utf8String::Utf8String(v8::Local<v8::Value>)':
../../nan/nan.h:1064:78: warning: 'v8::Local<v8::String> v8::Value::ToString(v8::Isolate*) const' is deprecated: Use maybe version [-Wdeprecated-declarations]
       v8::Local<v8::String> string = from->ToString(v8::Isolate::GetCurrent());
                                                                              ^
In file included from /home/pi/.node-gyp/11.4.0/include/node/v8.h:26:0,
                 from /home/pi/.node-gyp/11.4.0/include/node/node.h:63,
                 from ../../nan/nan.h:52,
                 from ../src/poller.cpp:1:
/home/pi/.node-gyp/11.4.0/include/node/v8.h:2538:31: note: declared here
                 Local<String> ToString(Isolate* isolate) const);
                               ^
/home/pi/.node-gyp/11.4.0/include/node/v8config.h:326:3: note: in definition of macro 'V8_DEPRECATED'
   declarator __attribute__((deprecated(message)))
   ^~~~~~~~~~
../src/poller.cpp: In static member function 'static void Poller::onData(uv_poll_t*, int, int)':
../src/poller.cpp:69:29: warning: 'v8::Local<v8::Value> Nan::Callback::Call(int, v8::Local<v8::Value>*) const' is deprecated [-Wdeprecated-declarations]
   obj->callback.Call(2, argv);
                             ^
In file included from ../src/poller.cpp:1:0:
../../nan/nan.h:1655:3: note: declared here
   Call(int argc, v8::Local<v8::Value> argv[]) const {
   ^~~~
  SOLINK_MODULE(target) Release/obj.target/serialport.node
  COPY Release/serialport.node
make: Leaving directory '/home/pi/hekkie/node_modules/serialport/build'
gyp info ok
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.

Adding resolutions to the package.json file allows to install but does not seem to work properly (I'm looking in to that).

Not compatible with [email protected]

Happy to see such a well thought initiative :)
Yet, I'm using serialport v4 since weeks, and I only get
DEPRECATION: Please use 'require('serialport')' instead of 'require('serialport').SerialPort'
at start of my program using this lib and nothing else.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.