I’ve recently managed to set up socat in such a way that I can use OpenRemote’s UDPListener as a ‘serial port listener’ of sorts.
Works decently, however for some reason UDPListener receives a string of single-character packets instead of ‘whole’ responses.
I’m using OpenRemote 2.6.0b1
What I have set up for command is:
command name: Status
protocol: UDP Listener
port: 4001
filter: (.*)
with the following sensor;
sensor name: OnkyoStatus
command: Status
type: custom
Using this test rule to output whatever is seen on UDPListener;
rule “UDPListener”
when
$evt : Event(source==“OnkyoStatus”, $v:value)
then
System.out.println(“UDP”+$v.toString());
end
gives:
UDP!
UDP1
UDPP
UDPW
UDPR
UDP0
UDP1
UDP ()
What would be the best approach to buffering/concatenating that into whole strings before acting on them? (in this example, ‘full’ string would be “!1PWR01”) Using in-memory virtual commands, java string functions or other options?
Unfortunately the A/V receiver I’m setting this up for doesn’t have a network connection, so I can’t use eISCP.
This usually happens when the transmitter has too small buffer to hold the whole message. Maybe you can change this in settings? Many RS232 <-> TCP/IP boxes allow this, for example NPort 5110 from moxa. This would be the simples solution. However, if you cannot do this then the only way would be to concatenate messages on the receiver side. This is how I did it for restoring of AIS messages. You can adopt his code for your needs.
declare UDPchunks
@role(event)
part: String
end
rule “New UDPchunks”
salience 100
when
not UDPchunks()
then
insert(new UDPchunks(""));
end
rule “New TBSais”
no-loop true
when
// Delimiter is in regex *XX
// Create a regx which matches your Onkyo message. For the AIS message the last three characters is a star followed by two digits hex number
Thanks I’ll give that a try! I was starting to read up on use of global variables in drools to use as a buffer. Unfortunately I don’t actually use a RS232-TCP/IP box, it’s all linux socat magic on the OpenRemote Controller itself linking the RS232 port to one UDP port on input and another UDP port on output.