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

Add support for ZWave TTL-serial addon boards #8

Open
dhylands opened this Issue Feb 9, 2018 · 9 comments

Comments

Projects
None yet
5 participants
@dhylands
Contributor

dhylands commented Feb 9, 2018

This was originally posted here: mozilla-iot/gateway#647

Basically, we need a way of specifying the name of a TTL serial port to use for the ZWave adapter. This also requires a way to disable the serial console.

The name of the ttl-serial port belongs in the adapter config and ideally we need a way in the UI to enter this.

@dhylands

This comment has been minimized.

Contributor

dhylands commented Feb 9, 2018

And this issue was created to have a mechanism for the UI to enable/disable the console:
mozilla-iot/gateway#650

@Swaagie

This comment has been minimized.

Swaagie commented Mar 7, 2018

I was able to brute force this to work by having the adapter port check (https://github.com/mozilla-iot/zwave-adapter/blob/master/zwave-adapter.js#L376) just return true on ttyAMA0. I wonder what specifying a name through the UI would look like though? Can't expect users to just know what serial port they should use. Isn't this more an issue where the serialport module is reporting incorrectly?

How ports are being reported by the serialport module:

2018-03-07 02:19:21.157 zwave: serial ports are [ { manufacturer: undefined,
2018-03-07 02:19:21.158 zwave:     serialNumber: undefined,
2018-03-07 02:19:21.158 zwave:     pnpId: undefined,
2018-03-07 02:19:21.159 zwave:     locationId: undefined,
2018-03-07 02:19:21.160 zwave:     vendorId: undefined,
2018-03-07 02:19:21.160 zwave:     productId: undefined,
2018-03-07 02:19:21.161 zwave:     comName: '/dev/ttyAMA0' },
2018-03-07 02:19:21.161 zwave:   { manufacturer: undefined,
2018-03-07 02:19:21.161 zwave:     serialNumber: undefined,
2018-03-07 02:19:21.162 zwave:     pnpId: undefined,
2018-03-07 02:19:21.162 zwave:     locationId: undefined,
2018-03-07 02:19:21.162 zwave:     vendorId: undefined,
2018-03-07 02:19:21.163 zwave:     productId: undefined,
2018-03-07 02:19:21.163 zwave:     comName: '/dev/ttyS0' } ]

Worked like expected when brute forcing it to connect over /dev/ttyAMA0. Haven't got any zwave devices up and running yet but was allowed to do a scan and saw the controller being reported in the UI as zwave-d1147f62

2018-03-07 02:19:21.165 zwave: Found ZWave port @ /dev/ttyAMA0
2018-03-07 02:19:21.166 zwave: Initialising OpenZWave 1.4.2951 binary addon for Node.JS.
2018-03-07 02:19:21.166 zwave: 	OpenZWave Security API is ENABLED
2018-03-07 02:19:21.167 zwave: 	ZWave device db    : /usr/local/etc/openzwave
2018-03-07 02:19:21.168 zwave: 	User settings path : .
2018-03-07 02:19:21.169 zwave: 	Option Overrides : --SaveConfiguration true --ConsoleOutput false
2018-03-07 02:19:21.302 zwave: Driver Ready: HomeId: d1147f62
2018-03-07 02:19:21.366 zwave: Scan complete
2018-03-07 02:19:21.367 zwave: Controller: zwave-d1147f62 Path: /dev/ttyAMA0
2018-03-07 02:19:21.368 zwave: Node LastStat Basic Type       Type                     Product Name                                       Name                           Location
2018-03-07 02:19:21.369 zwave: ---- -------- ---------------- ------------------------ -------------------------------------------------- ------------------------------ ------------------------------
2018-03-07 02:19:21.372 zwave:   1: ready    StaticController
2018-03-07 02:19:21.373 zwave: ----
2018-03-07 02:21:03.497 Opened a new things socket
2018-03-07 02:21:03.645 About to call startPairing on ZWaveAdapter
2018-03-07 02:21:03.656 zwave: ===============================================
2018-03-07 02:21:03.656 zwave: Press the Inclusion button on the device to add
2018-03-07 02:21:03.657 zwave: ===============================================
2018-03-07 02:21:03.658 zwave: Controller Command feedback: ControllerCommand - Starting node0 retVal:1 state:0
2018-03-07 02:21:03.662 zwave: Controller Command feedback: ControllerCommand - Waiting node0 retVal:4 state:0
2018-03-07 02:21:25.594 Thing was not added
2018-03-07 02:21:25.595 addNewThing cancelled
2018-03-07 02:21:25.618 zwave: Cancelling pairing mode
2018-03-07 02:21:25.618 zwave: Controller Command feedback: ControllerCommand - Canceled node0 retVal:2 state:0
2018-03-07 02:21:25.666 zwave: Controller Command feedback: ControllerCommand - Completed node0 retVal:7 state:0
@Swaagie

This comment has been minimized.

Swaagie commented Mar 7, 2018

So under the covers serialport is using udevadm info -e to query the udev database, this reports the following for ttyAMA0 (at least for me)

P: /devices/platform/soc/3f201000.serial/tty/ttyAMA0
N: ttyAMA0
S: serial0
E: DEVLINKS=/dev/serial0
E: DEVNAME=/dev/ttyAMA0
E: DEVPATH=/devices/platform/soc/3f201000.serial/tty/ttyAMA0
E: MAJOR=204
E: MINOR=64
E: SUBSYSTEM=tty
E: TAGS=:systemd:
E: USEC_INITIALIZED=59544

e.g. a lot of vital data is missing for it to actually report the razberry vendorId and productId

Reference https://github.com/node-serialport/node-serialport/blob/master/lib/bindings/linux-list.js#L45

edit: e-mailed the manufacturer to get to know what is exactly expected to be listed in the udev database

@wresuolc

This comment has been minimized.

wresuolc commented Mar 7, 2018

Mine is similar, although a couple of differences:

P: /devices/platform/soc/20201000.serial/tty/ttyAMA0
N: ttyAMA0
E: DEVNAME=/dev/ttyAMA0
E: DEVPATH=/devices/platform/soc/20201000.serial/tty/ttyAMA0
E: ID_MM_CANDIDATE=1
E: MAJOR=204
E: MINOR=64
E: SUBSYSTEM=tty
E: TAGS=:systemd:
E: USEC_INITIALIZED=9009450
@Swaagie

This comment has been minimized.

Swaagie commented Mar 8, 2018

Good to know I'm not the only one missing the ID_VENDOR_ID and ID_MODEL_ID https://github.com/node-serialport/node-serialport/blob/master/lib/bindings/linux-list.js#L16-L17. I assume the device itself is expected to report/store this data in the udev database.

@dhylands

This comment has been minimized.

Contributor

dhylands commented Mar 8, 2018

Vendor Id and product id are only available for USB serial devices. /dev/ttyAMA0 isn't a USB serial device. Just before I went on vacation I wrote some code for the serial-mcu adapter which allows more complex filters to be setup.
https://github.com/mozilla-iot/serial-adapter/blob/master/README.md

Once I get back (still another week) I was going to look at adding similar support to the ZigBee and Zwave adapters.

@Swaagie

This comment has been minimized.

Swaagie commented Mar 9, 2018

Spot on, exactly what I was told in the email, haha. Aside from explicit configuration wouldn't it be possible to check the current platform with something like os.arch() / os.platform() / os.release(). While in addition checking if a certain instruction can be send/validate the response to verify the device is a razberry or zigbee board? Abstraction would be preferred over explicit configuration imho.

@guymcswain

This comment has been minimized.

guymcswain commented Mar 9, 2018

@vijayg78

This comment has been minimized.

vijayg78 commented Jun 14, 2018

Will this support come in near future? Me too uses razberry zwave. I tried creating a link to ttyUSB0 but that too did not work. Any hack that I can do to get it working on the short term ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment