This page last changed on Sep 21, 2014 by gesatecnico.
Hi everyone, I'm italian and i'm beginner on OR. Sorry for my english.
I would like to integrate OR with a new system of building automation, that communicates with UDP protocol.
The system is composed a number of CPU, connected with a bus, who communicate with a PC supervisor .
At every Cpu are connected with a secondary bus the power module 0/1, every power module have 8 switch addressed. Every CPU have max 40 switch
For command on/off, i send UDP command in HEX, i tested in OR and it works.
When i send UDP command in HEX, the system we reply me with changing the first character.
But if i swicht in manual the light, the system not send the UDP, and i dont have the state in OR.
the only mode is to interrogate the system with a new string in UDP and it reply me with a new UDP string,but it is cumulative, i describe it:
in the end of the string it reply with a 8 byte in HEX,
1 byte = 1 to 8 module switch
2 byte = 9 to 16 module switch
3 byte = 17 to 24 module switch
4 byte = 25 to 32 module switch
5 byte = 33 to 40 module switch
6-7-8 byte = 0 null
In every byte it reply with sum of switch in HEX.
The switch is counted with this configuration in decimal.
1 switch = 1 decimal
2 switch = 2 decimal
3 switch = 4 decimal
4 switch = 8 decimal
5 switch = 16 decimal
6 switch = 32 decimal
7 switch = 64 decimal
8 switch = 128 decimal
Example: the only 1° switch are on, it reply "01 00 00 00 00 00 00 00"
only 1° 2° 3° switch are on, it reply " 07 00 00 00 00 00 00 00"
only 1° 2° 3° 4° switch are on, it reply " 0F 00 00 00 00 00 00 00" - OF HEX = 15 dec
only 2° 3° 4° 9° 10° switch are on, it reply " 0E 03 00 00 00 00 00 00" - 0E HEX = 14 dec
Do you help me to indicate the way to integrate this system on OR ?
It's possible to create a rule to decript this udp protocol?
Thank's everyone for attention.
I think the best way would be to create a protocol for the system and not use the UDP protocol.
Posted by mredeker at Sep 22, 2014 09:18
Thanks Marcus, but if i create a rule that it request the state every 10 second, when it reply i change the state for every one. The problem is to translate the reply from the sum to the every state.
Posted by gesatecnico at Sep 22, 2014 16:29
That would involve java programming which is possible within rules.
Posted by mredeker at Sep 22, 2014 16:37
What do you suggest me to integrate in OR?
If I created a xml file that constantly updates, and I read the state in OR?
Posted by gesatecnico at Oct 05, 2014 19:53
Posted by mredeker at Oct 05, 2014 20:02
This is what I do with my Arduinos.
I have a python program wish talks with the arduinos every 0.1s to read all port status and it opens a TCP port from where the OR talks with this python program.
I decided to use a simple protocol, something like
A: Arduino number (I have 3 mega but the python program is ready for n)
B: Arduino "command" 1: Write, 2: Read, 4 port Status, 5: Digital port toggle etc...) So I can read or write in the port (pin)
C: Digital / Analog (1: The port will be Analog, 2: The port will be Digital)
D: Arduino port (pin) number
E: Port Value (0 or 1 if digital OR 1 to 255 if analog)
With this protocol I can do whatever I need.
Read an analog/digital value form port X,
Write analog/digital value to port X,
I have also some "special" commands like: with one command coming from OR i can turn the Arduino port X "on" for 0.5s then return it to "off"
Posted by rberg at Oct 06, 2014 04:13
you can use the HTTP protocol
It is a pity that we still have to rely on http polling. I would like to see that the REST API would not only allow for commands to be passed on, but that status values could be pushed too along this route as well.
Posted by pz1 at Oct 06, 2014 14:26