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

Unified support for hardware vs virtual (e. g. over IP) serial #1912

Open
Sonic-Amiga opened this issue Dec 10, 2020 · 4 comments
Open

Unified support for hardware vs virtual (e. g. over IP) serial #1912

Sonic-Amiga opened this issue Dec 10, 2020 · 4 comments

Comments

@Sonic-Amiga
Copy link
Contributor

I am currently writing two bindings for different hardware pieces, both using serial line. I am looking at SonyProjector as a reference, and i see it implements multiple types of Bridge: serial, serial over TCP, serial over UDP, etc. But this applies not only to Sony projectors, but also to any other serial devices. It's possible to order IP-to-serial bridge as a discrete component and use it with any device you want. Very useful in many practical situations. Currently bindings have to code such a support themselves, and it's not good. What if openhab's core could provide some abstract service for handling both physical and virtual serial ports ?

@lolodomo
Copy link
Contributor

Your example with the Sony Projector binding is not the best choice as the protocol is different for serial and IP.
The core framework already provide an abstraction for serial and serial over IP but in practice it does not work well with certain bindings when you use serial over IP with the serial stuff. That is the reason why developers create a special case for serial over IP.

@Sonic-Amiga
Copy link
Contributor Author

Sony is in fact even more complex. Some projectors feature a native Ethernet port, and for them communication protocol is different from those which have RS232 connector. But you could also route that RS232 via a 3rd party TCP bridge, and in this case the protocol would be the same, the binding supports such a configuration too. Well, offtopic :)
Could you tell me about the abstraction API we already have ? Perhaps i'll find them convenient to use.

@lolodomo
Copy link
Contributor

I am the author of the Sony Projector binding so yes I know it well lol

The serial abstraction is just the serial stuff from the core framework we use in bindings. If you want to use serial over IP, you just have to use a special serial port name starting with RFCxxxx. Sorry I don't remember the number. That is the theory. In practice, I was not able to make it work when developing one binding. But I did not try again recently.

@wborn
Copy link
Member

wborn commented Dec 11, 2020

What if openhab's core could provide some abstract service for handling both physical and virtual serial ports ?

The core already supports serial over IP using RFC2217. To use such a port you configure the hostname/port of the server using a URL like rfc2217://192.168.1.1:1234 instead of the serial port name (/dev/ttyUSB0 or COM1) in your Thing configuration.

You can for instance run a cheap RFC2217 server using a Raspberry Pi and ser2net. See for instance this community topic on how to configure ser2net.

Sometimes a binding needs to be slightly adapted before it supports RFC2217 connections, see:

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

3 participants