Ember+ Multi-Package Framing

172 views
Skip to first unread message

tuxfan

unread,
Apr 26, 2016, 9:59:05 AM4/26/16
to ember-plus-development
Hey There. I'm using libember for a consumer I'm writing and I'm having a bit of trouble decoding multi-package responses from my device.

I presumed that I would just strip out the package bodies and append them into a single OctetStream (StreamBuffer) which I could then call 'DomReader().decodeTree( stream, GlowNodeFactory::getFactory() )' on, but this is throwing an 'Implicit tag or universal outer tag found' exception. Decoding single responses doesn't work either. 

Am I missing something? I can't find any information about how they actually get split.

Cheers

Stefan Weber

unread,
Apr 26, 2016, 10:36:40 AM4/26/16
to ember-plus-development
Are you aware that the byte stream is s101-encoded?

tuxfan

unread,
Apr 26, 2016, 10:54:00 AM4/26/16
to ember-plus-development
You mean a whole package structure of:

0xFE BOF
0x00 Device Slot 
0x0E Message type: EmBER 
0x00 Command type: EmBER Packet 
0x01 Version 
0xC0 Flags: Single Packet message (First packet | Last packet) 
0x01 DTD Type: Glow DTD 
0x02 Application Bytes 
0x05 Minor Glow DTD Version 
0x02 Major Glow DTD Version 
<payload>
CRC
CRC
0xFF EOF

With escaped characters in the payload?

I'm stripping off everything (after checking) and leaving the payloads intact.

Stefan Weber

unread,
Apr 26, 2016, 11:11:28 AM4/26/16
to ember-plus-development
So the answer to my question is: yes you are...What I do is first decode the entire received buffer(s) with libs101::StreamDecoder and interpret the payload with libember::dom::AsyncDomReader::read(). Since you cannot know if this was the last message of a s101-sequence, you should evaluate the result tree when AsyncDomReader::isRootReady() returns true.

tuxfan

unread,
Apr 26, 2016, 11:26:44 AM4/26/16
to ember-plus-development
Brilliant. Was worried I was missing something with the S101 decoding. I'll stick that in. Cheers mate.
Reply all
Reply to author
Forward
0 new messages