Issue #262 has been updated by Philipp  Buluschek.

The code I'm talking about is in 
@ByteArrayOutputStreamSerializer.appendZigBeeType(Object, ZigBeeType)@ which is 
used for example by @WriteAttributeCommand.getPayload()@ to create the payload 
to be sent.

In @ByteArrayOutputStreamSerializer.appendZigBeeType(Object, ZigBeeType)@ the 
types which are greater than 2 bytes are serialized using writeLong. Example
<pre>
  public void appendZigBeeType(Object data, ZigBeeType type) {
    ...
    case UnsignedInteger40bit:
      append_long((Long) data, 5);
      ...
</pre>

and @append_long@ calls @Integers.writeLong()@ which writes MSB first to the 
buffer. I believe this is incorrect. 
For example @Integers.writeShort()@ writes the MSB last, and so is correct, in 
my opinion.
----------------------------------------
Task #262: Check byte-order writing
http://zb4o.aaloa.org/redmine/issues/262#change-682

Author: Philipp  Buluschek
Status: In Progress
Priority: High
Assignee: Stefano Lenzi
Category: zigbee.zcl.library
Target version: org.aaloa.zb4osgi.zigbee.zcl.library-1.X


I implemented the writing of ZigBee data type IEEE_Address (see 
ZigBeeType.IEEEAddress) in ByteArrayOutputStreamSerializer. The original 
Java-data type was String, but I changed it to Long as it is much more adapted 
(as it's also what is returned from SimpleDriver.getIEEEAddress() ).

Writing the IEEE Address (as a long) in ByteArrayOutputStreamSerializer, I 
supposed the code should look like:
@
case IEEEAddress:
  final Long l = (Long) data;
  append_long(l.longValue());
  break;@

But noticed that, the IEEE address gets written byte-order reversed over the 
air. In particular, the ZigBee Spec (1.2.1.3) says that the least significant 
byte must be sent first. But the implementation of Integers.writeLong() does 
the reverse (writes msb first to the buffer). For my case, I simply added a 
implementation of the reversed writing - so not a problem.

But I now wonder - all other data types (larger than 1 byte) are written in the 
same manner as long in Integers.writeXXX(). Should they all be reversed?






-- 
DO NOT ANSWER TO THIS E-MAIL ADDRESS, NO ONE WILL READ IT. PLEASE WRITE TO 
[email protected]
ZigBee 4 OSGi - Redmine E-Mail Notificatioon
You have received this notification because you have either subscribed to it, 
or are involved in it.
To change your notification preferences, please click here: 
http://zb4o.aaloa.org/redmine
_______________________________________________
Dev mailing list
[email protected]
http://zb4osgi.aaloa.org/mailman/listinfo/dev

Reply via email to