forked from LupusNobilis/java-org.hwo
ServiceLink: Fix Handling of Bytes with highest bit 1
parent
c57df94160
commit
e1d39b5a0c
|
@ -72,7 +72,13 @@ public class ServiceLink {
|
|||
bb.put(request);
|
||||
bb.put(achse);
|
||||
bb.put(knoten);
|
||||
bb.putShort((short)register);
|
||||
|
||||
if (register > 32767)
|
||||
bb.putShort((short)(register));
|
||||
else
|
||||
bb.putShort((short)register);
|
||||
|
||||
|
||||
if ((request & REQ_WRITE) == REQ_WRITE)
|
||||
bb.put(value);
|
||||
|
||||
|
@ -107,6 +113,8 @@ public class ServiceLink {
|
|||
achse = bb.get();
|
||||
knoten = bb.get();
|
||||
register = bb.getShort();
|
||||
if (register < 0)
|
||||
register = (register & 0x7FFF) | 0x8000;
|
||||
|
||||
if ((request & (REQ_READ | REQ_ACK)) == (REQ_READ | REQ_ACK))
|
||||
{
|
||||
|
@ -119,7 +127,7 @@ public class ServiceLink {
|
|||
if (chksum != ChkSum.chksum(rxbuffer, 0, bb.position() - 2))
|
||||
throw new ServiceLinkException();
|
||||
|
||||
System.err.println(String.format("recv(): %d.%d:%d = 0x%08x",achse,knoten,bb.getShort(3),bb.getInt(5)));
|
||||
System.err.println(String.format("recv(): %d.%d:%d = 0x%08x",achse,knoten,register,bb.getInt(5)));
|
||||
|
||||
} catch (IOException e) {
|
||||
getSerialPort().close();
|
||||
|
@ -237,12 +245,26 @@ public class ServiceLink {
|
|||
intValue = ServiceNode.this.readInt(register);
|
||||
} catch (ServiceLinkRequestFailedException slex)
|
||||
{
|
||||
floatValue = null;
|
||||
intValue = 0;
|
||||
if (floatType)
|
||||
{
|
||||
floatValue = 0.0f;
|
||||
intValue = null;
|
||||
} else
|
||||
{
|
||||
floatValue = null;
|
||||
intValue = 0;
|
||||
}
|
||||
throw slex;
|
||||
} catch (Exception e) {
|
||||
floatValue = null;
|
||||
intValue = 0;
|
||||
if (floatType)
|
||||
{
|
||||
floatValue = 0.0f;
|
||||
intValue = null;
|
||||
} else
|
||||
{
|
||||
floatValue = null;
|
||||
intValue = 0;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue