Skip to content
This repository has been archived by the owner on Dec 20, 2019. It is now read-only.

Unhandled rejection TypeError: Cannot read property 'write' of null #101

Open
ghost opened this issue Apr 19, 2018 · 2 comments
Open

Unhandled rejection TypeError: Cannot read property 'write' of null #101

ghost opened this issue Apr 19, 2018 · 2 comments

Comments

@ghost
Copy link

ghost commented Apr 19, 2018

Ubuntu 17.10: Sphero 2 is connected on serialport rfcomm0. Getting the following error:

Unhandled rejection TypeError: Cannot read property 'write' of null
    at Adaptor.write (/home/moarli/Dokumente/sphero/node_modules/sphero/lib/adaptors/serialport.js:86:19)
    at Sphero._execCommand (/home/moarli/Dokumente/sphero/node_modules/sphero/lib/sphero.js:224:21)
    at /home/moarli/Dokumente/sphero/node_modules/sphero/lib/sphero.js:184:10
    at Promise._execute (/home/moarli/Dokumente/sphero/node_modules/bluebird/js/release/debuggability.js:303:9)
    at Promise._resolveFromExecutor (/home/moarli/Dokumente/sphero/node_modules/bluebird/js/release/promise.js:483:1
8)
    at new Promise (/home/moarli/Dokumente/sphero/node_modules/bluebird/js/release/promise.js:79:10)
    at Sphero.command (/home/moarli/Dokumente/sphero/node_modules/sphero/lib/sphero.js:180:10)
    at Sphero.device.roll (/home/moarli/Dokumente/sphero/node_modules/sphero/lib/devices/sphero.js:445:12)

    at /home/moarli/Dokumente/sphero/index.js:6:7
    at tryCatcher (/home/moarli/Dokumente/sphero/node_modules/bluebird/js/release/util.js:16:23)
    at Promise.errorAdapter (/home/moarli/Dokumente/sphero/node_modules/bluebird/js/release/nodeify.js:35:34)
    at Promise._settlePromise (/home/moarli/Dokumente/sphero/node_modules/bluebird/js/release/promise.js:566:21)
    at Promise._settlePromiseCtx (/home/moarli/Dokumente/sphero/node_modules/bluebird/js/release/promise.js:606:10)
    at Async._drainQueue (/home/moarli/Dokumente/sphero/node_modules/bluebird/js/release/async.js:138:12)
    at Async._drainQueues (/home/moarli/Dokumente/sphero/node_modules/bluebird/js/release/async.js:143:10)
    at Immediate.Async.drainQueues (/home/moarli/Dokumente/sphero/node_modules/bluebird/js/release/async.js:17:14)

/home/moarli/Dokumente/sphero/node_modules/sphero/lib/adaptors/serialport.js:86
  this.serialport.write(data, callback);
                  ^
TypeError: Cannot read property 'write' of null
    at Adaptor.write (/home/moarli/Dokumente/sphero/node_modules/sphero/lib/adaptors/serialport.js:86:19)
    at Sphero._execCommand (/home/moarli/Dokumente/sphero/node_modules/sphero/lib/sphero.js:224:21)
    at Sphero.handler (/home/moarli/Dokumente/sphero/node_modules/sphero/lib/sphero.js:257:10)
    at ontimeout (timers.js:475:11)
    at tryOnTimeout (timers.js:310:5)
    at Timer.listOnTimeout (timers.js:270:5)
@ghost ghost changed the title Unhandled rejection TypeError: serialport.SerialPort is not a constructor Unhandled rejection TypeError: Cannot read property 'write' of null Apr 19, 2018
@inear
Copy link

inear commented Apr 21, 2018

Looks like the call to node-serialport in the adaptor is wrong (in sphero/lib/adaptors/serialport.js). It says "new serialport.SerialPort(this.conn, {});" but should be "new serialport(this.conn, {});" Or preferable rename local var "serialport" to "SerialPort" like
var SerialPort = require("serialport");

Maybe it has to do with this commit: serialport/node-serialport@9a98ede#diff-4897cea01b861088accb90c155bb3db8L171. That change (back in 2016) hade a depreciation warning but that was probably removed later.

@inear
Copy link

inear commented Apr 21, 2018

And then I found #99

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant