[phc] Fix OH3 bug and add support for multible commands (#11554)
* Remove advanced option in group-type Signed-off-by: Jonas Hohaus <jh@gnlpf.net> * Add support for multiple commands in one message Signed-off-by: Jonas Hohaus <jh@gnlpf.net>
This commit is contained in:
parent
2c7acbcc21
commit
688f1af8f3
@ -210,7 +210,9 @@ public class PHCBridgeHandler extends BaseBridgeHandler implements SerialPortEve
|
|||||||
byte sizeToggle = buffer.get();
|
byte sizeToggle = buffer.get();
|
||||||
|
|
||||||
// read length of command and check if makes sense
|
// read length of command and check if makes sense
|
||||||
if ((sizeToggle < 1 || sizeToggle > 3) && ((sizeToggle & 0xFF) < 0x81 || (sizeToggle & 0xFF) > 0x83)) {
|
int size = (sizeToggle & 0x7F);
|
||||||
|
|
||||||
|
if (!isSizeToggleValid(sizeToggle, module)) {
|
||||||
if (logger.isDebugEnabled()) {
|
if (logger.isDebugEnabled()) {
|
||||||
logger.debug("get invalid sizeToggle: {}", new String(HexUtils.byteToHex(sizeToggle)));
|
logger.debug("get invalid sizeToggle: {}", new String(HexUtils.byteToHex(sizeToggle)));
|
||||||
}
|
}
|
||||||
@ -220,7 +222,6 @@ public class PHCBridgeHandler extends BaseBridgeHandler implements SerialPortEve
|
|||||||
}
|
}
|
||||||
|
|
||||||
// read toggle, size and command
|
// read toggle, size and command
|
||||||
int size = (sizeToggle & 0x7F);
|
|
||||||
boolean toggle = (sizeToggle & 0x80) == 0x80;
|
boolean toggle = (sizeToggle & 0x80) == 0x80;
|
||||||
|
|
||||||
logger.debug("get toggle: {}", toggle);
|
logger.debug("get toggle: {}", toggle);
|
||||||
@ -270,6 +271,24 @@ public class PHCBridgeHandler extends BaseBridgeHandler implements SerialPortEve
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean isSizeToggleValid(byte sizeToggle, byte module) {
|
||||||
|
int unsigned = sizeToggle & 0xFF;
|
||||||
|
|
||||||
|
if (unsigned > 0 && unsigned < 4) {
|
||||||
|
return true;
|
||||||
|
} else if (unsigned > 0x80 && unsigned < 0x84) {
|
||||||
|
return true;
|
||||||
|
} else if ((module & 0xE0) == 0x00) {
|
||||||
|
if (unsigned > 0 && unsigned < 16) {
|
||||||
|
return true;
|
||||||
|
} else if (unsigned > 0x80 && unsigned < 0x90) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
private int handleCrcFault(int faultCounter) throws InterruptedException {
|
private int handleCrcFault(int faultCounter) throws InterruptedException {
|
||||||
if (faultCounter > 0) {
|
if (faultCounter > 0) {
|
||||||
// Normally in this case we read the message repeatedly offset to the real -> skip one to 6 bytes
|
// Normally in this case we read the message repeatedly offset to the real -> skip one to 6 bytes
|
||||||
@ -320,23 +339,31 @@ public class PHCBridgeHandler extends BaseBridgeHandler implements SerialPortEve
|
|||||||
|
|
||||||
// EM command / update
|
// EM command / update
|
||||||
} else {
|
} else {
|
||||||
if (((module & 0xE0) == 0x00)) {
|
if ((module & 0xE0) == 0x00) {
|
||||||
sendEmAcknowledge(module, toggle);
|
sendEmAcknowledge(module, toggle);
|
||||||
logger.debug("send acknowledge (modul, toggle) {} {}", module, toggle);
|
logger.debug("send acknowledge (modul, toggle) {} {}", module, toggle);
|
||||||
|
|
||||||
byte channel = (byte) ((command[0] >>> 4) & 0x0F);
|
for (byte cmdByte : command) {
|
||||||
|
byte channel = (byte) ((cmdByte >>> 4) & 0x0F);
|
||||||
|
|
||||||
OnOffType onOff = OnOffType.OFF;
|
OnOffType onOff = OnOffType.OFF;
|
||||||
|
|
||||||
if ((command[0] & 0x0F) == 2) {
|
byte cmd = (byte) (cmdByte & 0x0F);
|
||||||
onOff = OnOffType.ON;
|
if (cmd % 2 == 0) {
|
||||||
}
|
if (cmd == 2) {
|
||||||
|
onOff = OnOffType.ON;
|
||||||
|
} else {
|
||||||
|
logger.debug("Command {} isn't implemented for EM", cmd);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
QueueObject qo = new QueueObject(PHCBindingConstants.CHANNELS_EM, module, channel, onOff);
|
QueueObject qo = new QueueObject(PHCBindingConstants.CHANNELS_EM, module, channel, onOff);
|
||||||
|
|
||||||
// put recognized message into queue
|
// put recognized message into queue
|
||||||
if (!receiveQueue.contains(qo)) {
|
if (!receiveQueue.contains(qo)) {
|
||||||
receiveQueue.offer(qo);
|
receiveQueue.offer(qo);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ignore if message not from EM module
|
// ignore if message not from EM module
|
||||||
|
|||||||
@ -53,7 +53,7 @@
|
|||||||
</channels>
|
</channels>
|
||||||
</channel-group-type>
|
</channel-group-type>
|
||||||
|
|
||||||
<channel-group-type id="jrmTimeChannels" advanced="true">
|
<channel-group-type id="jrmTimeChannels">
|
||||||
<label>JRM time Channels</label>
|
<label>JRM time Channels</label>
|
||||||
<description>Time for shutter channels in seconds with an accuracy of 1/10 seconds.</description>
|
<description>Time for shutter channels in seconds with an accuracy of 1/10 seconds.</description>
|
||||||
<channels>
|
<channels>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user