Hello,
I can send a command through the TCP Bindings and I can get the expected data correctly (verified with Wireshark:
).
Here is my setup:
-> my .cfg:
tcp:port=22222
tcp:postamble=\n
tcp:updatewithresponse=true
tcp:charset=ASCII
-> my .items:
String JavaMeteo "Jav Met [%s]" (gRDC) {tcp=">[172.16.128.112:22222:'REGEX((.*))']"}
String JavaMeteo_receive "Jav Met recev [%s]" (gRDC) {tcp="<[172.16.128.112:*:'REGEX((.*))']"}
-> my .rules:
rule "TEST Davis"
when
Item TESTDavis received command
then if (receivedCommand==ON){
JavaMeteo.sendCommand("LOOP 1")
Thread::sleep(1000)
logInfo("TestJS","JS : " + transform("JS", "MeteoVantage.js", JavaMeteo.state.toString))
}else{
JavaMeteo.sendCommand("LAMPS 0")
Thread::sleep(1000)
logInfo("TestJS","JS : " + transform("JS", "MeteoVantage.js", JavaMeteo.state.toString))
}
end
-> MeteoVantage.js
// Wrap everything in a function
(function(i) {
return (i)+2;
})(input)
// input variable contains data passed by openhab
-> my result:
Launching the openHAB runtime...
osgi> 2016-06-02 11:39:57.574 [INFO ] [.o.core.internal.CoreActivator] - openHAB runtime has been started (v1.8.2).
2016-06-02 11:39:58.207 [INFO ] [o.o.i.s.i.DiscoveryServiceImpl] - mDNS service has been started
2016-06-02 11:39:58.445 [INFO ] [o.o.i.s.i.DiscoveryServiceImpl] - Service Disco very initialization completed.
2016-06-02 11:39:59.767 [INFO ] [penhab.io.rest.RESTApplication] - Started REST API at /rest
2016-06-02 11:40:08.030 [INFO ] [c.internal.ModelRepositoryImpl] - Loading model 'Maison.sitemap'
2016-06-02 11:40:08.133 [INFO ] [c.internal.ModelRepositoryImpl] - Loading model 'myopenhab.persist'
2016-06-02 11:40:08.177 [INFO ] [c.internal.ModelRepositoryImpl] - Loading model 'Maison.script'
2016-06-02 11:40:08.232 [INFO ] [c.internal.ModelRepositoryImpl] - Loading model 'Maison.items'
2016-06-02 11:40:08.724 [INFO ] [.o.u.w.i.servlet.WebAppServlet] - Started Classic UI at /classicui/openhab.app
2016-06-02 11:40:12.826 [INFO ] [t.AbstractSocketChannelBinding] - The maximum buffer will be set to the default value of 1024
2016-06-02 11:40:12.826 [INFO ] [t.AbstractSocketChannelBinding] - The interval to retry connection setups will be set to the default value of 5
2016-06-02 11:40:12.827 [INFO ] [t.AbstractSocketChannelBinding] - The cron job to reset connections will be set to the default value of 0 0 0 * * ?
2016-06-02 11:40:12.828 [INFO ] [t.AbstractSocketChannelBinding] - The setting to queue write operation until a channel gets connected will be set to the default value of true
2016-06-02 11:40:12.829 [INFO ] [t.AbstractSocketChannelBinding] - The setting to share channels within an Item will be set to the default value of true
2016-06-02 11:40:12.829 [INFO ] [t.AbstractSocketChannelBinding] - The setting to share channels between the items with the same direction will be set to the default value of true
2016-06-02 11:40:12.830 [INFO ] [t.AbstractSocketChannelBinding] - The setting to share channels between directions will be set to the default value of true
2016-06-02 11:40:12.831 [INFO ] [t.AbstractSocketChannelBinding] - The setting to use address masks for incoming connections will be set to the default value of true
2016-06-02 11:40:12.832 [INFO ] [t.AbstractSocketChannelBinding] - The refresh interval of the worker thread will be set to the default value of 250
2016-06-02 11:40:12.833 [INFO ] [t.AbstractSocketChannelBinding] - Listening for incoming connections on /0:0:0:0:0:0:0:0:22222
2016-06-02 11:40:12.836 [INFO ] [.service.AbstractActiveService] - TCP Refresh Service has been started
2016-06-02 11:40:12.836 [INFO ] [t.protocol.internal.TCPBinding] - The maximum time out for blocking write operations will be set to the default vaulue of 3000
2016-06-02 11:40:12.837 [INFO ] [t.protocol.internal.TCPBinding] - The blocking nature of read/write operations will be set to the default vaulue of false
2016-06-02 11:40:12.839 [INFO ] [t.protocol.internal.TCPBinding] - The preamble for all write operations will be set to the default vaulue of ""
2016-06-02 11:40:12.840 [INFO ] [t.AbstractSocketChannelBinding] - Connecting the channel Channel [item=JavaMeteo, command=0, direction=OUT, remote=/172.16.128.112:22222, buffer=, isBlocking=false, isReconnecting=false, channel=, host=172.16.128.112, port=22222]
2016-06-02 11:40:12.841 [WARN ] [t.AbstractSocketChannelBinding] - When using address masks we will not verify if we are already listening to similar incoming connections
2016-06-02 11:40:12.842 [INFO ] [t.AbstractSocketChannelBinding] - We will accept data coming from the remote end 172.16.128.112:*
2016-06-02 11:40:12.860 [INFO ] [.p.rrd4j.internal.RRD4jService] - Removing invalid defintion component = null heartbeat = 0 min/max = 0.0/0.0 step = 0 0 archives(s) = [] 0 items(s) = []
2016-06-02 11:40:13.093 [INFO ] [t.AbstractSocketChannelBinding] - The channel for /172.16.128.112:22222 is now connected
2016-06-02 11:40:18.300 [INFO ] [c.internal.ModelRepositoryImpl] - Loading model 'Maison.rules'
2016-06-02 11:40:27.269 [INFO ] [.myopenhab.internal.MyOHClient] - Connected to my.openHAB service (UUID = 6fe97abb-****-****-****-64b868d097b9, local base URL= http://localhost:8080)
2016-06-02 11:40:42.713 [INFO ] [runtime.busevents ] - TESTDavis received command ON
2016-06-02 11:40:42.988 [INFO ] [runtime.busevents ] - JavaMeteo received command LOOP 1
2016-06-02 11:40:42.995 [INFO ] [runtime.busevents ] - JavaMeteo state updated to LOOP 1
2016-06-02 11:40:43.611 [INFO ] [runtime.busevents ] - JavaMeteo state updated to LOO
2016-06-02 11:40:44.776 [INFO ] [rg.openhab.model.script.TestJS] - JS : LOO2
2016-06-02 11:40:52.998 [INFO ] [runtime.busevents ] - TESTDavis received command OFF
2016-06-02 11:40:53.016 [INFO ] [runtime.busevents ] - JavaMeteo received command LAMPS 0
2016-06-02 11:40:53.017 [INFO ] [runtime.busevents ] - JavaMeteo state updated to LAMPS 0
2016-06-02 11:40:53.862 [INFO ] [runtime.busevents ] - JavaMeteo state updated to OK
2016-06-02 11:40:54.070 [INFO ] [rg.openhab.model.script.TestJS] - JS : OK2
However, the return string is displayed instead of the string sent. Furthermore, no element is displayed in the return chain. Why?
Also, how can I extract and then parse the hexadecimal string that comes from my weather station please? Indeed, I wish to extract each element as indicated in the document on page 22: http://www.davisnet.com/support/weather/download/VantageSerialProtocolDocs_v261.pdf
Thank you in advance for your help.
Flavien