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

Add support for ZWave TTL-serial addon boards #8

Open
dhylands opened this issue Feb 9, 2018 · 16 comments
Open

Add support for ZWave TTL-serial addon boards #8

dhylands opened this issue Feb 9, 2018 · 16 comments

Comments

@dhylands
Copy link
Contributor

@dhylands dhylands commented Feb 9, 2018

This was originally posted here: WebThingsIO/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
Copy link
Contributor Author

@dhylands dhylands commented Feb 9, 2018

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

@Swaagie
Copy link

@Swaagie 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
Copy link

@Swaagie 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
Copy link

@wresuolc 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
Copy link

@Swaagie 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
Copy link
Contributor Author

@dhylands 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
Copy link

@Swaagie 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
Copy link

@guymcswain guymcswain commented Mar 9, 2018

@vijayg78
Copy link

@vijayg78 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 ?

@pastukhov
Copy link

@pastukhov pastukhov commented Mar 23, 2019

Any news?
udevadm info - does'nt working in case if gateway is running inside docker

@dhylands
Copy link
Contributor Author

@dhylands dhylands commented Mar 23, 2019

Do you have a link to the docker image you're using?
Is the docker image running on a Raspberry Pi?

@pastukhov
Copy link

@pastukhov pastukhov commented Mar 23, 2019

mozillaiot/gateway:arm
Not exactly Raspberry. I'm using Banana Pi with armbian distro

@pastukhov
Copy link

@pastukhov pastukhov commented Mar 23, 2019

docker-compose.yaml, i'm using

version: "3"
services:
  mozilla-iot:
    image: mozillaiot/gateway:arm
    ports:
      - "8080:8080"
      - "4443:4443"
    devices:
      - "/dev/ttyS1:/dev/ttyS1"
    volumes:
      - /opt/moz-iot:/home/node/.mozilla-iot
      - /var/run/dbus/system_bus_socket:/var/run/dbus/system_bus_socket
    network_mode: "host"
@mrstegeman mrstegeman added this to Inbox in WebThings Add-ons Mar 26, 2019
@th0mpy
Copy link

@th0mpy th0mpy commented May 26, 2020

Has there been an update on this front? If you could at least mention where you coded \dev\ttyAMA0 it would be helpful.

@inteldon
Copy link

@inteldon inteldon commented May 31, 2020

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.

Where can I find this file on the raspberry pi? I searched the entire gateway folder and I can find this nowhere. Please help. Thank you.

@denics
Copy link

@denics denics commented Jun 3, 2020

Any news? Any magic command line? In raspberry, with a razberry hat, can we use .mozilla-iot/config/local.json to specify the /dev/ttyAMA0 serial?

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

Successfully merging a pull request may close this issue.

None yet
9 participants
You can’t perform that action at this time.