Epson binding does not work gnu.io.NoSuchPortException

epsonprojector
openhab2
binding
Tags: #<Tag:0x00007f15d0d00538> #<Tag:0x00007f15d0d003f8> #<Tag:0x00007f15d0d002b8>

(Juergen Tolksdorf) #1

Hi,
I cannot get my Epson Projector connected to Openhab via RS232.
My local TTY device is /dev/ttyAMA0

root@projektor:/etc/openhab2/services# dmesg | grep tty
[    0.000000] Kernel command line: dma.dmachans=0x7f35 bcm2708_fb.fbwidth=656 bcm2708_fb.fbheight=416 bcm2708.boardrev=0xe bcm2708.serial=0x37801730 smsc95xx.macaddr=B8:27:EB:80:17:30 bcm2708_fb.fbswap=1 bcm2708.uart_clock=3000000 vc_mem.mem_base=0x1ec00000 vc_mem.mem_size=0x20000000  dwc_otg.lpm_enable=0 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait
[    0.001287] console [tty1] enabled
[    0.135498] 20201000.uart: ttyAMA0 at MMIO 0x20201000 (irq = 83, base_baud = 0) is a PL011 rev2

openhab is added to the dialout group:

root@projektor:/etc/openhab2/services# grep dialout /etc/group
dialout:x:20:pi,root,www-data,openhab

My configuration is as follows:
/etc/openhab2/services/epsonprojector.cfg

epsonprojector:projektor.serialPort=/dev/ttyAMA0

/etcopenhab2/items/epson.items

Switch Power { epsonprojector=“projektor:Power:60000” }
Switch Mute { epsonprojector=“projektor:Mute:ON,60000” }

I’ve added

EXTRA_JAVA_OPTS="-Dgnu.io.rxtx.SerialPorts=/dev/ttyAMA0"
to /etc/default/openhab2

The logfile throws the following error:

2016-12-28 14:46:23.763 [WARN ] [ector.internal.EpsonProjectorBinding] - Couldn't execute command 'Power', org.openhab.binding.epsonprojector.internal.EpsonProjectorException: gnu.io.NoSuchPortException
2016-12-28 14:46:24.781 [WARN ] [ector.internal.EpsonProjectorBinding] - Couldn't execute command 'Power', org.openhab.binding.epsonprojector.internal.EpsonProjectorException: gnu.io.NoSuchPortException
2016-12-28 14:46:24.787 [ERROR] [ector.internal.EpsonProjectorBinding] - No response received from command 'Power'

When I start minicom I can access the projector through RS232 / on /dev/ttyAMA0

Any ideas are highly appreciated.


(Stephan Fuchs) #2

Hi Juergen, I’m facing the same problem. Did you ever got this solved or went another way to use the RS232 interface of the projector?

Kind regards

Stephan


(Juergen Tolksdorf) #3

Hi Stephan,
unfortunately no. I’m just thinking to purchase something which allows me to send infrared requests to the projector.


(Pali) #4

Configuration should be without binding name

projektor.serialPort=/dev/ttyAMA0

I doubt that will fix the problem as binding should not go further if configuration is invalid or not even start if configuration is missing.


(Stephan Fuchs) #5

Hi Juergen,

I’ve build an IR transmitter with a RPi. Works OK, but the problem is that the IR diodes are not strong enough. The distance between the Pi & the beamer is almost 7m, so sometimes the IR signal is not received by the beamer. So my intention is now to build an WiFi2Serial gateway with a ESP8266 board. For this reason I need a serial port which can be used by Openhab.


(Pali) #6

I have added TCP/IP connection support to Epson binding while ago (forgotten to add information to binding documentation page). I use currently cheap Ethernet <-> serial port converter (USR-TCP232-24) with Epson projector. So you should be able to connect directly to ESP8266 board, which act a WiFi2Serial gateway.

/etc/openhab2/services/epsonprojector.cfg

projector.host=192.168.1.100
projector.port=10000

(Stephan Fuchs) #7

Hi Pali,

thanks for your feedback. That does not work & I’m facing the following error in the logs (using Openhab 2.3)´

2018-07-04 09:34:18.659 [ERROR] [b.core.service.AbstractActiveService] - Error while executing background thread Epson projector Refresh Service
java.lang.NullPointerException: null
        at org.openhab.binding.epsonprojector.connector.EpsonProjectorSerialConnector.disconnect(EpsonProjectorSerialConnector.java:99) [251:org.openhab.binding.epsonprojector:1.12.0]
        at org.openhab.binding.epsonprojector.internal.EpsonProjectorDevice.disconnect(EpsonProjectorDevice.java:480) [251:org.openhab.binding.epsonprojector:1.12.0]
        at org.openhab.binding.epsonprojector.internal.EpsonProjectorBinding.closeConnection(EpsonProjectorBinding.java:543) [251:org.openhab.binding.epsonprojector:1.12.0]
        at org.openhab.binding.epsonprojector.internal.EpsonProjectorBinding.queryDataFromDevice(EpsonProjectorBinding.java:351) [251:org.openhab.binding.epsonprojector:1.12.0]
        at org.openhab.binding.epsonprojector.internal.EpsonProjectorBinding.execute(EpsonProjectorBinding.java:163) [251:org.openhab.binding.epsonprojector:1.12.0]
        at org.openhab.core.binding.AbstractActiveBinding$BindingActiveService.execute(AbstractActiveBinding.java:144) [229:org.openhab.core.compat1x:2.3.0]
        at org.openhab.core.service.AbstractActiveService$RefreshThread.run(AbstractActiveService.java:166) [229:org.openhab.core.compat1x:2.3.0]

Do you have got an idea what is going wrong here? When I include my ESP8266 Serial Gateway through a virtual COM port with socat

socat pty,link=/tmp/virtualcom0,ignoreeof,user=openhab,group=dialout,mode=777,raw,echo=0 tcp:192.168.178.241:23

I’m able to send commands to the projector but also facing this error in the logs.

Regards

Stephan


(Pali) #8

That error is thrown as serial port open has failed. Disconnect method could be improved a little bit, but that doesn’t solve you problem. Did you tried to connect directly by using tcp?


(Stephan Fuchs) #9

I’ve tried that, but it doesn’t work.
I’m able to log what messages are delivered to the serial bridge.

When the cfg is changed tcp then nothing is getting send to my bridge & I’m getting the refresh errors?!

hometheater.host=192.168.178.241
hometheater.port=23

Actually I’ve got it working with a virtual com port, but I would prefer to use it directly over tcp because with the socat process there is another source for errors :wink:


(Pali) #10

If you get the same error, then binding still tries to use serial port connection rather than TCP. If both serial port and tcp setting are configured, then binding tries to use serial port. Most probably reason is that openHAB framework doesn’t remove the serial port configuration parameter after configuration refresh. So you might need to restart the openHAB.


(Stephan Fuchs) #11

Thx, your hint pointed me in the right direction. I’v restarted openhab but the error stayed.
So I rembered that the cfg files are cached under

/var/lib/openhab2/config/org/openhab

and checked the file there. It contained both settings (com port & TCP) although I had changed them under

/etc/openhab2/services/epsonprojector.cfg

So long story short: stopped openhab, removed the invalid config file from cache, restarted openhab & now the tcp connection through my gateway just works :hugs::hugs::hugs:


(Stephan Fuchs) #12

One more question, is it possible to change the luminance mode (Eco, Normal) through your binding?
Following the Epson documentation it is possible, through telnet I’ve been successful, too.

I’ve defined the following item:

string epsonLuminance           { epsonprojector="hometheater:Luminance:ON,60000" }

and the following map entry:

Selection item=epsonLuminance mappings=[00="Normal",01="Eco"]

I’m getting the following error:

2018-07-04 13:40:32.449 [WARN ] [org.apache.karaf.services.eventadmin] - EventAdmin: Exception during event dispatch [org.osgi.service.event.Event [topic=openhab/command/epsonLuminance] {item=epsonLuminance, bridgemarker=true, command=00, timestamp=1530704432449} | {org.osgi.service.event.EventHandler, org.osgi.service.cm.ManagedService}={service.id=451, service.bundleid=251, service.scope=bundle, event.topics=openhab/command/*, service.pid=org.openhab.epsonprojector, component.name=org.openhab.binding.epsonprojector.binding, component.id=268} | Bundle(org.openhab.binding.epsonprojector_1.12.0 [251])]
java.lang.IllegalArgumentException: No enum constant org.openhab.binding.epsonprojector.internal.EpsonProjectorDevice.Luminance.00
    at java.lang.Enum.valueOf(Enum.java:238) [?:?]
    at org.openhab.binding.epsonprojector.internal.EpsonProjectorDevice$Luminance.valueOf(EpsonProjectorDevice.java:1) [251:org.openhab.binding.epsonprojector:1.12.0]
    at org.openhab.binding.epsonprojector.internal.EpsonProjectorBinding.sendDataToDevice(EpsonProjectorBinding.java:475) [251:org.openhab.binding.epsonprojector:1.12.0]
    at org.openhab.binding.epsonprojector.internal.EpsonProjectorBinding.internalReceiveCommand(EpsonProjectorBinding.java:376) [251:org.openhab.binding.epsonprojector:1.12.0]
    at org.openhab.core.binding.AbstractBinding.receiveCommand(AbstractBinding.java:94) [229:org.openhab.core.compat1x:2.3.0]
    at org.openhab.core.events.AbstractEventSubscriber.handleEvent(AbstractEventSubscriber.java:45) [229:org.openhab.core.compat1x:2.3.0]
    at org.apache.felix.eventadmin.impl.handler.EventHandlerProxy.sendEvent(EventHandlerProxy.java:415) [3:org.apache.karaf.services.eventadmin:4.1.5]
    at org.apache.felix.eventadmin.impl.tasks.HandlerTask.runWithoutBlacklistTiming(HandlerTask.java:82) [3:org.apache.karaf.services.eventadmin:4.1.5]
    at org.apache.felix.eventadmin.impl.tasks.SyncDeliverTasks.execute(SyncDeliverTasks.java:104) [3:org.apache.karaf.services.eventadmin:4.1.5]
    at org.apache.felix.eventadmin.impl.tasks.AsyncDeliverTasks$TaskExecuter.run(AsyncDeliverTasks.java:166) [3:org.apache.karaf.services.eventadmin:4.1.5]
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:?]
    at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:?]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:?]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:?]
    at java.lang.Thread.run(Thread.java:748) [?:?]

(Juergen Tolksdorf) #13

Stephan,
did you finally get it to work to trigger on/off every time?


(Stephan Fuchs) #14

Juergen,

I’ve tested it serveral times today. It seems to be working fine with the host/port mode & my ESP8266 flashed with ESP-Link. Will give it a try during the next days.


(Pali) #15

Yes, Luminance should work fine. Luminance is string type, so you should set value to NORMAL or ECO (not numeric value).

So following should work (not tested):
Selection item=epsonLuminance mappings=[NORMAL=“Normal”, ECO=“Eco”]


(Stephan Fuchs) #16

I’ve tried your suggestion & it is working! :slight_smile:
There has to be an input to the beamer otherwise the beamer returns an error :wink:

Thank you!


(Stephan Fuchs) #17

So short update from my side:

After deleting the cached config files & setting up the host/port mode for the binding everything is running rock solid!

@pauli_anttila
Thx for your efforts and this binding!


(Christoph Wempe) #18

@pauli_anttila
I created a pull request to update the README to include the tcp option.