How to get udp binding to work for incoming?

Background: openhab 1.83 running in Ubuntu 16.04 LTS installed from package, talking/listening UDP to an AMX NI-700 running a test program that receives the BDEVxxSLTyyPTzzVw where xx=device, yy=slot, zz=point and w=relay command state, also sends the same format to openhab when a digital input changes state.

Netcat and wireshark show the protocol as working. Sending relay commands works from openhab. the relays change state as expected. however, getting status back from the input points does not. When openhab receives BDEV01SLT04PT01V1 it indicates the input switched on, BDEV01SLT04PT01V0 indicating the input has switched off.

Working relay binding:

Switch AMX_Relay_1 “” {udp=">[ON:172.28.85.50:8000:‘MAP(AMX_Relay_1.map)’], >[OFF:172.28.85.50:8000:‘MAP(AMX_Relay_1.map)’]"}

Non-working input binding:

Switch AMX_Input_1 “” {udp="<[ON:172.28.85.50::‘MAP(AMX_Input_1.map)’], [OFF:172.28.85.50::‘MAP(AMX_Input_1.map)’]"}

AMX_Input_1.map file
contents:

ON=BDEV01SLT04PT01V1
OFF=BDEV01SLT04PT01V0
undefined=ON
-=ON

log file from switching states of the input:

2016-08-26 19:39:34.734 [WARN ] [t.i.s.MapTransformationService] - Could not find a mapping for ‘BDEV01SLT04PT01V1’ in the file ‘AMX_Input_1.map’.
2016-08-26 19:39:34.735 [WARN ] [t.protocol.internal.UDPBinding] - Can not parse input BDEV01SLT04PT01V1 to match command ON on item AMX_Input_1

2016-08-26 19:39:34.735 [WARN ] [t.i.s.MapTransformationService] - Could not find a mapping for ‘BDEV01SLT04PT01V1’ in the file ‘AMX_Input_1.map’.

2016-08-26 19:39:34.736 [WARN ] [t.protocol.internal.UDPBinding] - Can not parse input BDEV01SLT04PT01V1 to match command OFF on item AMX_Input_1

I have tried reversing the key/value pairs in the map file. no change.

Changing the binding from Switch to Contact gives additional errors.

Contact AMX_Input_1 “AMX Input 1” {udp="<[CLOSED:172.28.85.50::‘MAP(AMX_Input_1.map)’], [OPEN:172.28.85.50::‘MAP(AMX_Input_1.map)’]"}

map file:
BDEV01SLT04PT01V1=CLOSED
BDEV01SLT04PT01V0=OPEN
undefined=OPEN
-=OPEN

`2016-08-26 20:09:14.644 [ERROR] [.service.AbstractActiveService] - Error while executing background thread UDP Refresh Service java.lang.NullPointerException: null
at org.openhab.binding.tcp.protocol.internal.UDPBinding.parseBuffer(UDPBinding.java:148) ~[na:na]
at org.openhab.binding.tcp.AbstractDatagramChannelBinding.parseChanneledBuffer(AbstractDatagramChannelBinding.java:998) ~[na:na]
at org.openhab.binding.tcp.AbstractDatagramChannelBinding.execute(AbstractDatagramChannelBinding.java:1505) ~[na:na]
at org.openhab.core.binding.AbstractActiveBinding$BindingActiveService.execute(AbstractActiveBinding.java:156) ~[na:na]
at org.openhab.core.service.AbstractActiveService$RefreshThread.run(AbstractActiveService.java:173) ~[na:na]

`

changed map file to:

CLOSED=BDEV01SLT04PT01V1
OPEN=BDEV01SLT04PT01V0
undefined=OPEN
-=OPEN

gives same error

At this point I am at a loss since I have not seen any similar examples that work to extrapolate from.

What am I missing? the documentation could be better showing how the map file interacts with the binding and which parts of the binding data are passed to the map file and how the return gets used.

Thanks for any help.

For inbound, you don’t have to define a command at all, so please try

Switch AMX_Input_1 "" {udp="<[172.28.85.50:'MAP(AMX_Input_1.map)']"}

instead.
In question of the map-file: left side is input, right side is output, so for inbound item it should be like

BDEV01SLT04PT01V1=ON
BDEV01SLT04PT01V0=OFF
-=-

If this does not work as expected, try out a string item instead to get the real input (with/without mapping).

Thanks for the quick response.

I changed it to

Switch AMX_Input_1 "" {udp="<[172.28.85.50:'MAP(AMX_Input_1.map)']"}

and still got similar errors about the map file. fixed the map file to match your post, still not working.

I switched to a string and can successfully receive the string. So I guess I need to write something to parse the string and update the appropriate items. Seems like more steps than should be necessary, but if that is what it takes, then that is what will be done. Now on to figuring that out.

For others that may be interested, the string item that works is:
String AMX_Input_1 "AMX Input 1" { udp="<[172.28.85.50:*:'REGEX((.*))']" }

the sitemap entry to display this is:
Text item=AMX_Input_1 label="In1 [%s]"

Hi @Grumpy_Oldman,

Can you please tell me what’s in the udp config file? What did you configure there?

Thx!!!

Here’s my entire udp.cfg file:

# Port to listen for incoming connections
port=4000

# Cron-like string to reconnect remote ends, e.g for unstable connection or remote ends
#reconnectcron=0 0 0 * * ?

# Interval between reconnection attempts when recovering from a communication error,
# in seconds
#retryinterval=5

# Queue data whilst recovering from a connection problem (TCP only)
#queue=true

# Maximum buffer size whilst reading incoming data
buffersize=1024

# Share connections within the Item binding configurations
itemsharedconnections=true

# Share connections between Item binding configurations
bindingsharedconnections=true

# Share connections between inbound and outbound connections
directionssharedconnections=false

# Allow masks in ip:port addressing, e.g. 192.168.0.1:* etc
addressmask=true

# Pre-amble that will be put in front of data being sent
#preamble=

# Post-amble that will be appended to data being sent
#postamble=\r\n

# Perform all write/read (send/receive) operations in a blocking mode, e.g. the binding
# will wait for a reply from the remote end after data has been sent
#blocking=false

# timeout, in milliseconds, to wait for a reply when initiating a blocking write/read
#  operation
#timeout=3000

# Update the status of Items using the response received from the remote end (if the
# remote end sends replies to commands)
#updatewithresponse=true

# Timeout - or 'refresh interval', in milliseconds, of the worker thread
refreshinterval=250

# Timeout, in milliseconds, to wait when "Selecting" IO channels ready for communication
#selecttimeout=1000

# Used character set
charset=ASCII
1 Like