I'm testing mbus4J 1.0.0 using a program written using an mbus4J slave against the Mango Automation MBus data source and finding that the Primary address search doesn't work. I am seeing the Decoder log the output:
expectedLengt reached: data discarted!
What I have found is that the Decoder decodes the ShortFrame that is sent from the MBusMaster incorrectly. It seems to think the message should be 1 byte less than it actually is.
When I run the program the Slave Log output is:
FINEST 2019-04-05T11:04:06,100 (net.sf.mbus4j.slaves.Slaves$StreamListener.run:261) - Data received 0x10
FINEST 2019-04-05T11:04:06,102 (net.sf.mbus4j.decoder.Decoder.setState:668) - EXPECT_START => C_FIELD
FINEST 2019-04-05T11:04:06,102 (net.sf.mbus4j.slaves.Slaves$StreamListener.run:261) - Data received 0x7b
FINEST 2019-04-05T11:04:06,102 (net.sf.mbus4j.decoder.Decoder.setState:668) - C_FIELD => A_FIELD
FINEST 2019-04-05T11:04:06,105 (net.sf.mbus4j.slaves.Slaves$StreamListener.run:261) - Data received 0x01
FINEST 2019-04-05T11:04:06,105 (net.sf.mbus4j.decoder.Decoder.setState:668) - A_FIELD => CHECKSUM
FINEST 2019-04-05T11:04:06,105 (net.sf.mbus4j.slaves.Slaves$StreamListener.run:261) - Data received 0x7c
FINEST 2019-04-05T11:04:06,105 (net.sf.mbus4j.decoder.Decoder.setState:668) - CHECKSUM => END_SIGN
FINEST 2019-04-05T11:04:06,106 (net.sf.mbus4j.slaves.Slaves$StreamListener.run:261) - Data received 0x16
DEBUG 2019-04-05T11:04:06,106 (net.sf.mbus4j.decoder.Decoder.addByte:125) - expectedLengt reached: data discarted!
I'm testing mbus4J 1.0.0 using a program written using an mbus4J slave against the Mango Automation MBus data source and finding that the Primary address search doesn't work. I am seeing the Decoder log the output:
expectedLengt reached: data discarted!
What I have found is that the Decoder decodes the ShortFrame that is sent from the MBusMaster incorrectly. It seems to think the message should be 1 byte less than it actually is.
When I run the program the Slave Log output is:
It appears to me that the dataPos should be set back one more than it is on line 144 (of the version of the code I'm using) here is the link to the latest code: https://github.com/aploese/mbus4j/blob/e574bd74210e47af42e7dc1c4b154d04dfe473b1/mbus4j-core/src/main/java/net/sf/mbus4j/decoder/Decoder.java#L160
After I change the value from -1 to -2 the Decoder works and the Log output is:
Can you confirm this is the proper solution or is something wrong with the Encoder as I am not testing against a real world device.
Thanks!