Skip to content
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

Logfile NOT optional; Logging does not work #2

Open
andrewkim47 opened this issue Mar 9, 2016 · 5 comments
Open

Logfile NOT optional; Logging does not work #2

andrewkim47 opened this issue Mar 9, 2016 · 5 comments

Comments

@andrewkim47
Copy link

NodeForwarder requires all 5 arguments. Omission of a Logfile argument returns the Usage suggestion:

For example, the command:

node nf2.js 8001 /dev/tty.usbmodem1431 57600

leads to:

usage: node nodeforwader.js [HTTP PORT] [SERIAL PORT] [BAUD] [BUFFER LENGTH] [LOG FILENAME optional]

When a logfile is inputted, there is a different error:

dyld: lazy symbol binding failed: Symbol not found: _node_module_register
Referenced from: /Users/lab/nodeforwarder2/node_modules/socket.io/node_modules/engine.io/node_modules/ws/build/Release/bufferutil.node
Expected in: dynamic lookup

dyld: Symbol not found: _node_module_register
Referenced from: /Users/lab/nodeforwarder2/node_modules/socket.io/node_modules/engine.io/node_modules/ws/build/Release/bufferutil.node
Expected in: dynamic lookup

Trace/BPT trap: 5

@dansteingart
Copy link
Owner

@andrewkim47 try now, and do this:

node nf2.js 8001 /dev/tty.usbmodem1431 57600 logyes >> logyes.txt

@andrewkim47
Copy link
Author

That command creates the log file, and then writes the opening dialog to file before erroring out. The logfile contains:

  '/Users/akim/NodeForwarder2/nf.js',
  '8001',
  '/dev/tty.usbmodem1431',
  '57600',
  'logyes' ]
0
1
2

It then errors out with the message:

body-parser deprecated bodyParser: use individual json/urlencoded middlewares nf.js:88:9
body-parser deprecated undefined extended: provide extended option node_modules/body-parser/index.js:105:29
/Users/akim/NodeForwarder2/nf.js:75
   if (logfile) console.log(data);
       ^
ReferenceError: logfile is not defined
    at SerialPort.<anonymous> (/Users/akim/NodeForwarder2/nf.js:75:8)
    at SerialPort.emit (events.js:107:17)
    at Object.module.exports.raw [as parser] (/Users/akim/NodeForwarder2/node_modules/serialport/parsers.js:8:13)
    at Object.SerialPort.opts.dataCallback (/Users/akim/NodeForwarder2/node_modules/serialport/serialport.js:181:12)
    at SerialPortFactory.SerialPort._emitData (/Users/akim/NodeForwarder2/node_modules/serialport/serialport.js:396:20)
    at afterRead (/Users/akim/NodeForwarder2/node_modules/serialport/serialport.js:372:20)
    at /Users/akim/NodeForwarder2/node_modules/serialport/serialport.js:388:9
    at FSReqWrap.wrapper [as oncomplete] (fs.js:527:17)

A 4-argument [no log] command still returns the same "usage suggestion" error.
A 5-argument command with a nonsense log command
node nodeforwarder.js 8001 /dev/tty.usbmodem1431 57600 aoeu

returns the a similar error to the logyes

body-parser deprecated bodyParser: use individual json/urlencoded middlewares nf.js:88:9
body-parser deprecated undefined extended: provide extended option node_modules/body-parser/index.js:105:29
open
/Users/akim/NodeForwarder2/nf.js:75
   if (logfile) console.log(data);
       ^
ReferenceError: logfile is not defined
    at SerialPort.<anonymous> (/Users/akim/NodeForwarder2/nf.js:75:8)
    at SerialPort.emit (events.js:107:17)
    at Object.module.exports.raw [as parser] (/Users/akim/NodeForwarder2/node_modules/serialport/parsers.js:8:13)
    at Object.SerialPort.opts.dataCallback (/Users/akim/NodeForwarder2/node_modules/serialport/serialport.js:181:12)
    at SerialPortFactory.SerialPort._emitData (/Users/akim/NodeForwarder2/node_modules/serialport/serialport.js:396:20)
    at afterRead (/Users/akim/NodeForwarder2/node_modules/serialport/serialport.js:372:20)
    at /Users/akim/NodeForwarder2/node_modules/serialport/serialport.js:388:9
    at FSReqWrap.wrapper [as oncomplete] (fs.js:527:17)

it looks like logfile does not get defined as True on line37. is parts counted correctly?

@dansteingart
Copy link
Owner

You forgot to put a buffer in.  you still need a buffer

On March 8, 2016 at 9:21:08 PM, andrewkim47 ([email protected]) wrote:

That command creates the log file, and then writes the opening dialog to file before erroring out. The logfile contains:

'/Users/akim/NodeForwarder2/nf.js',
'8001',
'/dev/tty.usbmodem1431',
'57600',
'logyes' ]
0
1
2
It then errors out with the message:

body-parser deprecated bodyParser: use individual json/urlencoded middlewares nf.js:88:9
body-parser deprecated undefined extended: provide extended option node_modules/body-parser/index.js:105:29
/Users/akim/NodeForwarder2/nf.js:75
if (logfile) console.log(data);
^
ReferenceError: logfile is not defined
at SerialPort. (/Users/akim/NodeForwarder2/nf.js:75:8)
at SerialPort.emit (events.js:107:17)
at Object.module.exports.raw as parser
at Object.SerialPort.opts.dataCallback (/Users/akim/NodeForwarder2/node_modules/serialport/serialport.js:181:12)
at SerialPortFactory.SerialPort._emitData (/Users/akim/NodeForwarder2/node_modules/serialport/serialport.js:396:20)
at afterRead (/Users/akim/NodeForwarder2/node_modules/serialport/serialport.js:372:20)
at /Users/akim/NodeForwarder2/node_modules/serialport/serialport.js:388:9
at FSReqWrap.wrapper as oncomplete
A 4-argument [no log] command still returns the same "usage suggestion" error.
A 5-argument command with a nonsense log command
node nodeforwarder.js 8001 /dev/tty.usbmodem1431 57600 aoeu

returns the a similar error to the logyes

body-parser deprecated bodyParser: use individual json/urlencoded middlewares nf.js:88:9
body-parser deprecated undefined extended: provide extended option node_modules/body-parser/index.js:105:29
open
/Users/akim/NodeForwarder2/nf.js:75
if (logfile) console.log(data);
^
ReferenceError: logfile is not defined
at SerialPort. (/Users/akim/NodeForwarder2/nf.js:75:8)
at SerialPort.emit (events.js:107:17)
at Object.module.exports.raw as parser
at Object.SerialPort.opts.dataCallback (/Users/akim/NodeForwarder2/node_modules/serialport/serialport.js:181:12)
at SerialPortFactory.SerialPort._emitData (/Users/akim/NodeForwarder2/node_modules/serialport/serialport.js:396:20)
at afterRead (/Users/akim/NodeForwarder2/node_modules/serialport/serialport.js:372:20)
at /Users/akim/NodeForwarder2/node_modules/serialport/serialport.js:388:9
at FSReqWrap.wrapper as oncomplete
logfile does get defined as True on line37 so I don' t know why it's complaining


Reply to this email directly or view it on GitHub.

@dansteingart
Copy link
Owner

node nf2.js 8001 /dev/tty.usbmodem1431 57600 10000 logyes >> logyes.txt

@andrewkim47
Copy link
Author

Oops. Now that I put in a correct arguments, I still see 2 issues:

  1. The data being written to file (or displayed to terminal) is not writing integers, but memory addresses in angle brackets.

node nf2.js 8001 /dev/tty.usbmodem1411 57600 1000 logno >> log.txt

My arduino is simply writing millis() to Serial. But the log file's contents are:

[ 'node',
  '/Users/akim/NodeForwarder2/nodeforwarder.js',
  '8001',
  '/dev/tty.usbmodem1411',
  '57600',
  '1000',
  'logyes' ]
0
1
2
Buffer 30 0d 0a>  [OMITTING Leading angle brackets because Github can't post them]
Buffer 39 39 39 0d>
Buffer 0a>
Buffer 31 39 39 39 0d 0a>
Buffer 33 30 30 30 0d 0a>
Buffer 34 30 30 30 0d 0a>
Buffer 35 30 30 30 0d 0a>
Buffer 36 30 30 30 0d 0a>
Buffer 37 30 30 31>
Buffer 0d 0a>
Buffer 38 30 30 31 0d 0a>
Buffer 39 30 30 30 0d 0a>
Buffer 31 30 30 30 31 0d 0a>
Buffer 31 31 30 30 31 0d 0a>
Buffer 31 32 30 30 32 0d>
  1. Minor issue. The script requires an argument after the [BUFFER].

node nf2.js 8001 /dev/tty.usbmodem1411 57600 1000

Errors out with the same "logfile not defined"

   if (logfile) console.log(data);
       ^
ReferenceError: logfile is not defined
    at SerialPort.<anonymous> (/Users/akim/NodeForwarder2/nf2.js:75:8)
    at SerialPort.emit (events.js:107:17)
    at Object.module.exports.raw [as parser] (/Users/akim/NodeForwarder2/node_modules/serialport/parsers.js:8:13)
    at Object.SerialPort.opts.dataCallback (/Users/akim/NodeForwarder2/node_modules/serialport/serialport.js:181:12)
    at SerialPortFactory.SerialPort._emitData (/Users/akim/NodeForwarder2/node_modules/serialport/serialport.js:396:20)
    at afterRead (/Users/akim/NodeForwarder2/node_modules/serialport/serialport.js:372:20)
    at /Users/akim/NodeForwarder2/node_modules/serialport/serialport.js:388:9
    at FSReqWrap.wrapper [as oncomplete] (fs.js:527:17)

Omitting the pipe to a logfile is the only way to get the "old" behavior of terminal output. But you still need the logyes argument.

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