Skip to content

Commit 9e4f4f4

Browse files
committed
Update CANopen binding code and related plc4x API calls.
Signed-off-by: Łukasz Dywicki <luke@code-house.org>
1 parent e283b18 commit 9e4f4f4

File tree

4 files changed

+7
-6
lines changed

4 files changed

+7
-6
lines changed

bundles/org.connectorio.addons.binding.amsads/src/main/java/org/connectorio/addons/binding/amsads/internal/handler/channel/AdsChannelHandlerBase.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ protected AdsChannelHandlerBase(Thing thing, ThingHandlerCallback callback, Chan
4949
this.thing = thing;
5050
this.callback = callback;
5151
this.channel = channel;
52-
this.refreshInterval = Optional.ofNullable(channel.getConfiguration())
52+
this.refreshInterval = Optional.ofNullable(channel)
53+
.map(Channel::getConfiguration)
5354
.map(cfg -> cfg.get("refreshInterval"))
5455
.map(val -> val instanceof Long ? (Long) val : Long.parseLong("" + val))
5556
.orElse(null);

bundles/org.connectorio.addons.binding.canopen.ta/src/main/java/org/connectorio/addons/binding/canopen/ta/internal/handler/protocol/TAOperations.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,8 +248,8 @@ public void accept(PlcSubscriptionEvent event) {
248248
IndexAddress address = IndexAddress.staticParse(buffer);
249249
final int subIndex = address.getSubindex();
250250
short rawValue = buffer.readShort(16);
251-
buffer.readUnsignedByte(8); // constant 0x41
252-
int unit = buffer.readUnsignedShort(8);
251+
buffer.readUnsignedShort(8); // constant 0x41
252+
int unit = buffer.readShort(8);
253253

254254
TAValue value = new TAValue(unit, rawValue);
255255
if (logger.isDebugEnabled()) {

bundles/org.connectorio.addons.binding.canopen.ta/src/main/java/org/connectorio/addons/binding/canopen/ta/tapi/dev/ConfigurationCallback.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ protected void accept(ReadBuffer buffer) throws ParseException {
4444
IndexAddress address = IndexAddress.staticParse(buffer);
4545
final int subIndex = address.getSubindex();
4646
short rawValue = buffer.readShort(16);
47-
buffer.readUnsignedByte(8); // constant 0x41
47+
short constant = buffer.readUnsignedShort(8); // constant 0x41
4848
int unit = buffer.readUnsignedShort(8);
4949

5050
if (logger.isDebugEnabled()) {

bundles/org.connectorio.addons.binding.canopen.ta/src/main/java/org/connectorio/addons/binding/canopen/ta/tapi/io/TAAnalogOutput.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ void update(byte[] data) {
7575
try {
7676
logger.trace("Encoded value for CAN Output {} is {}", this, Hex.encodeHexString(data));
7777
ReadBuffer buffer = new ReadBufferByteBased(data, ByteOrder.LITTLE_ENDIAN);
78-
this.type = buffer.readUnsignedByte(8); // type
79-
this.unit = buffer.readUnsignedByte(8); // unit
78+
this.type = buffer.readUnsignedShort(8); // type
79+
this.unit = buffer.readUnsignedShort(8); // unit
8080
int numericValue = parseNumber(buffer, data.length);
8181

8282
if (numericValue > Short.MIN_VALUE && numericValue < Short.MAX_VALUE) {

0 commit comments

Comments
 (0)