From 728940679923788bf65027cedbf853a139e372a2 Mon Sep 17 00:00:00 2001 From: daniel_peintner Date: Wed, 29 Sep 2010 11:08:45 +0000 Subject: [PATCH] * split EXI Header in decoder and encoder part * writing bits revised git-svn-id: https://svn.code.sf.net/p/openv2g/code/trunk@5 d9f2db14-54d0-4bde-b00c-16405c910529 --- ...xml_SCHEMA.exi => sessionSetupReq.xml.exi} | 0 data/test/sessionSetupRes.xml | 28 +++ data/test/sessionSetupRes.xml.exi | 1 + src/codec/BitDecoderChannel.c | 12 +- src/codec/BitDecoderChannel.h | 2 +- src/codec/BitEncoderChannel.c | 8 +- src/codec/BitEncoderChannel.h | 2 +- src/codec/BitOutputStream.c | 4 +- src/codec/BitOutputStream.h | 2 +- src/codec/EXICoder.c | 1 - src/codec/EXIDecoder.c | 2 +- src/codec/EXIEncoder.c | 180 +++++++++--------- src/codec/{EXIHeader.c => EXIHeaderDecoder.c} | 12 +- src/codec/EXIHeaderDecoder.h | 44 +++++ src/codec/EXIHeaderEncoder.c | 43 +++++ src/codec/{EXIHeader.h => EXIHeaderEncoder.h} | 6 +- src/test/main_codec.c | 18 +- 17 files changed, 236 insertions(+), 129 deletions(-) rename data/test/{sessionSetupReq.xml_SCHEMA.exi => sessionSetupReq.xml.exi} (100%) create mode 100644 data/test/sessionSetupRes.xml create mode 100644 data/test/sessionSetupRes.xml.exi rename src/codec/{EXIHeader.c => EXIHeaderDecoder.c} (84%) create mode 100644 src/codec/EXIHeaderDecoder.h create mode 100644 src/codec/EXIHeaderEncoder.c rename src/codec/{EXIHeader.h => EXIHeaderEncoder.h} (89%) diff --git a/data/test/sessionSetupReq.xml_SCHEMA.exi b/data/test/sessionSetupReq.xml.exi similarity index 100% rename from data/test/sessionSetupReq.xml_SCHEMA.exi rename to data/test/sessionSetupReq.xml.exi diff --git a/data/test/sessionSetupRes.xml b/data/test/sessionSetupRes.xml new file mode 100644 index 0000000..6de368f --- /dev/null +++ b/data/test/sessionSetupRes.xml @@ -0,0 +1,28 @@ + + + + + 0Fb80Fb80Fb80Fb8 + 1 + + + + + OK_SessionSetup + 54 + + 0 + 1 + 1 + 0 + 1 + 123456789 + + 123456789 + + + diff --git a/data/test/sessionSetupRes.xml.exi b/data/test/sessionSetupRes.xml.exi new file mode 100644 index 0000000..65496ce --- /dev/null +++ b/data/test/sessionSetupRes.xml.exi @@ -0,0 +1 @@ +@}}}}cTjVk+5t \ No newline at end of file diff --git a/src/codec/BitDecoderChannel.c b/src/codec/BitDecoderChannel.c index de1865d..0780433 100644 --- a/src/codec/BitDecoderChannel.c +++ b/src/codec/BitDecoderChannel.c @@ -49,12 +49,12 @@ int decodeBoolean(bitstream_t* stream, int* b) { return errn; } -int decodeNBitUnsignedInteger(bitstream_t* stream, size_t nbits, uint8_t* b) { +int decodeNBitUnsignedInteger(bitstream_t* stream, size_t nbits, uint8_t* uint8) { if (nbits == 0) { - *b = 0; + *uint8 = 0; return 0; } else { - return readBits(stream, nbits, b); + return readBits(stream, nbits, uint8); } } @@ -67,7 +67,7 @@ int decodeUnsignedInteger32(bitstream_t* stream, uint32_t* uint32) { do { /* 1. Read the next octet */ - errno = decode(stream, &b); + errn = decode(stream, &b); /* 2. Multiply the value of the unsigned number represented by the 7 * least significant * bits of the octet by the current multiplier and add the result to @@ -78,7 +78,7 @@ int decodeUnsignedInteger32(bitstream_t* stream, uint32_t* uint32) { /* 4. If the most significant bit of the octet was 1, go back to step 1 */ } while (errn >= 0 && (b >> 7) == 1); - return errno; + return errn; } /** @@ -94,7 +94,7 @@ int decodeUnsignedInteger64(bitstream_t* stream, uint64_t* uint64) { *uint64 = 0L; do { - errno = decode(stream, &b); + errn = decode(stream, &b); *uint64 += ((uint64_t) (b & 127)) << mShift; mShift += 7; } while (errn >= 0 && (b >> 7) == 1); diff --git a/src/codec/BitDecoderChannel.h b/src/codec/BitDecoderChannel.h index 2188517..5f152fa 100644 --- a/src/codec/BitDecoderChannel.h +++ b/src/codec/BitDecoderChannel.h @@ -41,7 +41,7 @@ int decodeBoolean(bitstream_t* stream, int* b); /** * Decodes and returns an n-bit unsigned integer. */ -int decodeNBitUnsignedInteger(bitstream_t* stream, size_t nbits, uint8_t* uint8 ); +int decodeNBitUnsignedInteger(bitstream_t* stream, size_t nbits, uint8_t* uint8); /** * Decode an arbitrary precision non negative integer using a sequence of diff --git a/src/codec/BitEncoderChannel.c b/src/codec/BitEncoderChannel.c index 0d27d45..35d5c35 100644 --- a/src/codec/BitEncoderChannel.c +++ b/src/codec/BitEncoderChannel.c @@ -69,7 +69,7 @@ uint8_t numberOf7BitBlocksToRepresent(int n) { int encode(bitstream_t* stream, uint8_t b) { - return writeBits(stream, b, 8); + return writeBits(stream, 8, b); } /** @@ -78,7 +78,7 @@ int encode(bitstream_t* stream, uint8_t b) { */ int encodeBoolean(bitstream_t* stream, int b) { uint8_t val = b ? 1 : 0; - return writeBits(stream, val, 1); + return writeBits(stream, 1, val); } @@ -86,8 +86,8 @@ int encodeBoolean(bitstream_t* stream, int b) { * Encode n-bit unsigned integer. The n least significant bits of parameter * b starting with the most significant, i.e. from left to right. */ -int encodeNBitUnsignedInteger(bitstream_t* stream, uint8_t val, size_t nbits) { - return writeBits(stream, val, nbits); +int encodeNBitUnsignedInteger(bitstream_t* stream, size_t nbits, uint8_t val) { + return writeBits(stream, nbits, val); } diff --git a/src/codec/BitEncoderChannel.h b/src/codec/BitEncoderChannel.h index 950cba0..2210ae3 100644 --- a/src/codec/BitEncoderChannel.h +++ b/src/codec/BitEncoderChannel.h @@ -45,7 +45,7 @@ int encodeBoolean(bitstream_t* stream, int b); * Encode n-bit unsigned integer. The n least significant bits of parameter * b starting with the most significant, i.e. from left to right. */ -int encodeNBitUnsignedInteger(bitstream_t* stream, uint8_t val, size_t nbits); +int encodeNBitUnsignedInteger(bitstream_t* stream, size_t nbits, uint8_t val); /** diff --git a/src/codec/BitOutputStream.c b/src/codec/BitOutputStream.c index 9a4e812..c80d809 100644 --- a/src/codec/BitOutputStream.c +++ b/src/codec/BitOutputStream.c @@ -32,7 +32,7 @@ #define BIT_OUTPUT_STREAM_C /* NOTE: nbits <= 8 */ -int writeBits(bitstream_t* stream, uint8_t val, size_t nbits) { +int writeBits(bitstream_t* stream, size_t nbits, uint8_t val) { /* is there enough space in the buffer */ if (nbits <= stream->capacity) { /* all bits fit into the current buffer */ @@ -87,7 +87,7 @@ int flush(bitstream_t* stream) { /* nothing to do, no bits in buffer */ return 0; } else { - return writeBits(stream, 0, stream->capacity); + return writeBits(stream, stream->capacity, 0); } } diff --git a/src/codec/BitOutputStream.h b/src/codec/BitOutputStream.h index ac04b3d..a2f04b3 100644 --- a/src/codec/BitOutputStream.h +++ b/src/codec/BitOutputStream.h @@ -34,7 +34,7 @@ extern "C" { #ifndef BIT_OUTPUT_STREAM_H #define BIT_OUTPUT_STREAM_H -int writeBits(bitstream_t* stream, uint8_t bits, size_t nbits); +int writeBits(bitstream_t* stream, size_t nbits, uint8_t bits); /* flush output */ int flush(bitstream_t* stream); diff --git a/src/codec/EXICoder.c b/src/codec/EXICoder.c index abde249..445c91f 100644 --- a/src/codec/EXICoder.c +++ b/src/codec/EXICoder.c @@ -37,7 +37,6 @@ #include "assert.h" #include "EXICoder.h" -#include "EXIHeader.h" /* size_t exiGetCurrentState(struct exiState* state) { diff --git a/src/codec/EXIDecoder.c b/src/codec/EXIDecoder.c index e4e2a48..e0d9ece 100644 --- a/src/codec/EXIDecoder.c +++ b/src/codec/EXIDecoder.c @@ -37,7 +37,7 @@ #include "BitDecoderChannel.h" #include "EXICoder.h" -#include "EXIHeader.h" +#include "EXIHeaderDecoder.h" #include "StringTable.h" diff --git a/src/codec/EXIEncoder.c b/src/codec/EXIEncoder.c index 3824c29..6172fc2 100644 --- a/src/codec/EXIEncoder.c +++ b/src/codec/EXIEncoder.c @@ -37,7 +37,7 @@ #include "BitEncoderChannel.h" #include "EXICoder.h" -#include "EXIHeader.h" +#include "EXIHeaderEncoder.h" #include "StringTable.h" /* ==================================== */ @@ -75,7 +75,7 @@ int exiEncodeStartElement(bitstream_t* stream, exi_state_t* state, /* DocContent[START_ELEMENT({urn:iso:15118:2:2010:MsgDef}BodyElement), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}LineLockReq), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}LineLockRes), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}MeteringReceiptReq), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}MeteringReceiptRes), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}MeteringStatusReq), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}MeteringStatusRes), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}PaymentDetailsReq), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}PaymentDetailsRes), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}PowerDeliveryReq), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}PowerDeliveryRes), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}PowerDiscoveryReq), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}PowerDiscoveryRes), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ServiceDiscoveryReq), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ServiceDiscoveryRes), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ServicePaymentSelectionReq), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ServicePaymentSelectionRes), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}SessionSetupReq), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}SessionSetupRes), START_ELEMENT({urn:iso:15118:2:2010:MsgDef}V2G_Message), START_ELEMENT_GENERIC] */ if ( se->localPart == 2 && se->namespaceURI == 6 ) { /* START_ELEMENT({urn:iso:15118:2:2010:MsgDef}BodyElement) */ - encodeNBitUnsignedInteger(stream, 0, 5); + encodeNBitUnsignedInteger(stream, 5, 0); /* move on */ state->grammarStack[state->stackIndex] = 2; /* push element on stack */ @@ -83,7 +83,7 @@ int exiEncodeStartElement(bitstream_t* stream, exi_state_t* state, } else if ( se->localPart == 10 && se->namespaceURI == 4 ) { /* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}LineLockReq) */ - encodeNBitUnsignedInteger(stream, 1, 5); + encodeNBitUnsignedInteger(stream, 5, 1); /* move on */ state->grammarStack[state->stackIndex] = 2; /* push element on stack */ @@ -91,7 +91,7 @@ int exiEncodeStartElement(bitstream_t* stream, exi_state_t* state, } else if ( se->localPart == 12 && se->namespaceURI == 4 ) { /* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}LineLockRes) */ - encodeNBitUnsignedInteger(stream, 2, 5); + encodeNBitUnsignedInteger(stream, 5, 2); /* move on */ state->grammarStack[state->stackIndex] = 2; /* push element on stack */ @@ -99,7 +99,7 @@ int exiEncodeStartElement(bitstream_t* stream, exi_state_t* state, } else if ( se->localPart == 16 && se->namespaceURI == 4 ) { /* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}MeteringReceiptReq) */ - encodeNBitUnsignedInteger(stream, 3, 5); + encodeNBitUnsignedInteger(stream, 5, 3); /* move on */ state->grammarStack[state->stackIndex] = 2; /* push element on stack */ @@ -107,7 +107,7 @@ int exiEncodeStartElement(bitstream_t* stream, exi_state_t* state, } else if ( se->localPart == 18 && se->namespaceURI == 4 ) { /* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}MeteringReceiptRes) */ - encodeNBitUnsignedInteger(stream, 4, 5); + encodeNBitUnsignedInteger(stream, 5, 4); /* move on */ state->grammarStack[state->stackIndex] = 2; /* push element on stack */ @@ -123,7 +123,7 @@ int exiEncodeStartElement(bitstream_t* stream, exi_state_t* state, } else if ( se->localPart == 22 && se->namespaceURI == 4 ) { /* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}MeteringStatusRes) */ - encodeNBitUnsignedInteger(stream, 6, 5); + encodeNBitUnsignedInteger(stream, 5, 6); /* move on */ state->grammarStack[state->stackIndex] = 2; /* push element on stack */ @@ -131,7 +131,7 @@ int exiEncodeStartElement(bitstream_t* stream, exi_state_t* state, } else if ( se->localPart == 32 && se->namespaceURI == 4 ) { /* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}PaymentDetailsReq) */ - encodeNBitUnsignedInteger(stream, 7, 5); + encodeNBitUnsignedInteger(stream, 5, 7); /* move on */ state->grammarStack[state->stackIndex] = 2; /* push element on stack */ @@ -139,7 +139,7 @@ int exiEncodeStartElement(bitstream_t* stream, exi_state_t* state, } else if ( se->localPart == 34 && se->namespaceURI == 4 ) { /* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}PaymentDetailsRes) */ - encodeNBitUnsignedInteger(stream, 8, 5); + encodeNBitUnsignedInteger(stream, 5, 8); /* move on */ state->grammarStack[state->stackIndex] = 2; /* push element on stack */ @@ -147,7 +147,7 @@ int exiEncodeStartElement(bitstream_t* stream, exi_state_t* state, } else if ( se->localPart == 36 && se->namespaceURI == 4 ) { /* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}PowerDeliveryReq) */ - encodeNBitUnsignedInteger(stream, 9, 5); + encodeNBitUnsignedInteger(stream, 5, 9); /* move on */ state->grammarStack[state->stackIndex] = 2; /* push element on stack */ @@ -155,7 +155,7 @@ int exiEncodeStartElement(bitstream_t* stream, exi_state_t* state, } else if ( se->localPart == 38 && se->namespaceURI == 4 ) { /* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}PowerDeliveryRes) */ - encodeNBitUnsignedInteger(stream, 10, 5); + encodeNBitUnsignedInteger(stream, 5, 10); /* move on */ state->grammarStack[state->stackIndex] = 2; /* push element on stack */ @@ -163,7 +163,7 @@ int exiEncodeStartElement(bitstream_t* stream, exi_state_t* state, } else if ( se->localPart == 40 && se->namespaceURI == 4 ) { /* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}PowerDiscoveryReq) */ - encodeNBitUnsignedInteger(stream, 11, 5); + encodeNBitUnsignedInteger(stream, 5, 11); /* move on */ state->grammarStack[state->stackIndex] = 2; /* push element on stack */ @@ -171,7 +171,7 @@ int exiEncodeStartElement(bitstream_t* stream, exi_state_t* state, } else if ( se->localPart == 42 && se->namespaceURI == 4 ) { /* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}PowerDiscoveryRes) */ - encodeNBitUnsignedInteger(stream, 12, 5); + encodeNBitUnsignedInteger(stream, 5, 12); /* move on */ state->grammarStack[state->stackIndex] = 2; /* push element on stack */ @@ -179,7 +179,7 @@ int exiEncodeStartElement(bitstream_t* stream, exi_state_t* state, } else if ( se->localPart == 47 && se->namespaceURI == 4 ) { /* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ServiceDiscoveryReq) */ - encodeNBitUnsignedInteger(stream, 13, 5); + encodeNBitUnsignedInteger(stream, 5, 13); /* move on */ state->grammarStack[state->stackIndex] = 2; /* push element on stack */ @@ -187,7 +187,7 @@ int exiEncodeStartElement(bitstream_t* stream, exi_state_t* state, } else if ( se->localPart == 49 && se->namespaceURI == 4 ) { /* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ServiceDiscoveryRes) */ - encodeNBitUnsignedInteger(stream, 14, 5); + encodeNBitUnsignedInteger(stream, 5, 14); /* move on */ state->grammarStack[state->stackIndex] = 2; /* push element on stack */ @@ -195,7 +195,7 @@ int exiEncodeStartElement(bitstream_t* stream, exi_state_t* state, } else if ( se->localPart == 52 && se->namespaceURI == 4 ) { /* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ServicePaymentSelectionReq) */ - encodeNBitUnsignedInteger(stream, 15, 5); + encodeNBitUnsignedInteger(stream, 5, 15); /* move on */ state->grammarStack[state->stackIndex] = 2; /* push element on stack */ @@ -203,7 +203,7 @@ int exiEncodeStartElement(bitstream_t* stream, exi_state_t* state, } else if ( se->localPart == 54 && se->namespaceURI == 4 ) { /* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ServicePaymentSelectionRes) */ - encodeNBitUnsignedInteger(stream, 16, 5); + encodeNBitUnsignedInteger(stream, 5, 16); /* move on */ state->grammarStack[state->stackIndex] = 2; /* push element on stack */ @@ -211,7 +211,7 @@ int exiEncodeStartElement(bitstream_t* stream, exi_state_t* state, } else if ( se->localPart == 58 && se->namespaceURI == 4 ) { /* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}SessionSetupReq) */ - encodeNBitUnsignedInteger(stream, 17, 5); + encodeNBitUnsignedInteger(stream, 5, 17); /* move on */ state->grammarStack[state->stackIndex] = 2; /* push element on stack */ @@ -219,7 +219,7 @@ int exiEncodeStartElement(bitstream_t* stream, exi_state_t* state, } else if ( se->localPart == 60 && se->namespaceURI == 4 ) { /* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}SessionSetupRes) */ - encodeNBitUnsignedInteger(stream, 18, 5); + encodeNBitUnsignedInteger(stream, 5, 18); /* move on */ state->grammarStack[state->stackIndex] = 2; /* push element on stack */ @@ -227,7 +227,7 @@ int exiEncodeStartElement(bitstream_t* stream, exi_state_t* state, } else if ( se->localPart == 8 && se->namespaceURI == 6 ) { /* START_ELEMENT({urn:iso:15118:2:2010:MsgDef}V2G_Message) */ - encodeNBitUnsignedInteger(stream, 19, 5); + encodeNBitUnsignedInteger(stream, 5, 19); /* move on */ state->grammarStack[state->stackIndex] = 2; /* push element on stack */ @@ -258,7 +258,7 @@ int exiEncodeStartElement(bitstream_t* stream, exi_state_t* state, /* FirstStartTagStartTag[START_ELEMENT({urn:iso:15118:2:2010:MsgBody}PEVID), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}PEVStatus)] */ if ( se->localPart == 25 && se->namespaceURI == 4 ) { /* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}PEVID) */ - encodeNBitUnsignedInteger(stream, 0, 1); + encodeNBitUnsignedInteger(stream, 1, 0); /* move on */ state->grammarStack[state->stackIndex] = 52; /* push element on stack */ @@ -357,7 +357,7 @@ int exiEncodeStartElement(bitstream_t* stream, exi_state_t* state, /* FirstStartTagStartTag[START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ServiceType), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ServiceScope), END_ELEMENT] */ if ( se->localPart == 57 && se->namespaceURI == 4 ) { /* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ServiceType) */ - encodeNBitUnsignedInteger(stream, 0, 2); + encodeNBitUnsignedInteger(stream, 2, 0); /* move on */ state->grammarStack[state->stackIndex] = 126; /* push element on stack */ @@ -365,7 +365,7 @@ int exiEncodeStartElement(bitstream_t* stream, exi_state_t* state, } else if ( se->localPart == 56 && se->namespaceURI == 4 ) { /* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ServiceScope) */ - encodeNBitUnsignedInteger(stream, 1, 2); + encodeNBitUnsignedInteger(stream, 2, 1); /* move on */ state->grammarStack[state->stackIndex] = 128; /* push element on stack */ @@ -406,7 +406,7 @@ int exiEncodeStartElement(bitstream_t* stream, exi_state_t* state, /* FirstStartTagStartTag[START_ELEMENT({urn:iso:15118:2:2010:MsgBody}PEVID), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}PEVStatus)] */ if ( se->localPart == 25 && se->namespaceURI == 4 ) { /* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}PEVID) */ - encodeNBitUnsignedInteger(stream, 0, 1); + encodeNBitUnsignedInteger(stream, 1, 0); /* move on */ state->grammarStack[state->stackIndex] = 156; /* push element on stack */ @@ -555,7 +555,7 @@ int exiEncodeStartElement(bitstream_t* stream, exi_state_t* state, /* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgBody}TCurrent), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}Tariff)] */ if ( se->localPart == 62 && se->namespaceURI == 4 ) { /* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}TCurrent) */ - encodeNBitUnsignedInteger(stream, 0, 1); + encodeNBitUnsignedInteger(stream, 1, 0); /* move on */ state->grammarStack[state->stackIndex] = 55; /* push element on stack */ @@ -594,7 +594,7 @@ int exiEncodeStartElement(bitstream_t* stream, exi_state_t* state, /* FirstStartTagStartTag[START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}MeterID), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}MeterPubKey), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}MeterReading), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}MeterStatus), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}TMeter), END_ELEMENT] */ if ( se->localPart == 16 && se->namespaceURI == 5 ) { /* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}MeterID) */ - encodeNBitUnsignedInteger(stream, 0, 3); + encodeNBitUnsignedInteger(stream, 3, 0); /* move on */ state->grammarStack[state->stackIndex] = 62; /* push element on stack */ @@ -602,7 +602,7 @@ int exiEncodeStartElement(bitstream_t* stream, exi_state_t* state, } else if ( se->localPart == 18 && se->namespaceURI == 5 ) { /* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}MeterPubKey) */ - encodeNBitUnsignedInteger(stream, 1, 3); + encodeNBitUnsignedInteger(stream, 3, 1); /* move on */ state->grammarStack[state->stackIndex] = 64; /* push element on stack */ @@ -610,7 +610,7 @@ int exiEncodeStartElement(bitstream_t* stream, exi_state_t* state, } else if ( se->localPart == 19 && se->namespaceURI == 5 ) { /* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}MeterReading) */ - encodeNBitUnsignedInteger(stream, 2, 3); + encodeNBitUnsignedInteger(stream, 3, 2); /* move on */ state->grammarStack[state->stackIndex] = 66; /* push element on stack */ @@ -626,7 +626,7 @@ int exiEncodeStartElement(bitstream_t* stream, exi_state_t* state, } else if ( se->localPart == 39 && se->namespaceURI == 5 ) { /* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}TMeter) */ - encodeNBitUnsignedInteger(stream, 4, 3); + encodeNBitUnsignedInteger(stream, 3, 4); /* move on */ state->grammarStack[state->stackIndex] = 70; /* push element on stack */ @@ -637,7 +637,7 @@ int exiEncodeStartElement(bitstream_t* stream, exi_state_t* state, /* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}MeterPubKey), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}MeterReading), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}MeterStatus), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}TMeter), END_ELEMENT] */ if ( se->localPart == 18 && se->namespaceURI == 5 ) { /* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}MeterPubKey) */ - encodeNBitUnsignedInteger(stream, 0, 3); + encodeNBitUnsignedInteger(stream, 3, 0); /* move on */ state->grammarStack[state->stackIndex] = 64; /* push element on stack */ @@ -645,7 +645,7 @@ int exiEncodeStartElement(bitstream_t* stream, exi_state_t* state, } else if ( se->localPart == 19 && se->namespaceURI == 5 ) { /* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}MeterReading) */ - encodeNBitUnsignedInteger(stream, 1, 3); + encodeNBitUnsignedInteger(stream, 3, 1); /* move on */ state->grammarStack[state->stackIndex] = 66; /* push element on stack */ @@ -653,7 +653,7 @@ int exiEncodeStartElement(bitstream_t* stream, exi_state_t* state, } else if ( se->localPart == 20 && se->namespaceURI == 5 ) { /* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}MeterStatus) */ - encodeNBitUnsignedInteger(stream, 2, 3); + encodeNBitUnsignedInteger(stream, 3, 2); /* move on */ state->grammarStack[state->stackIndex] = 68; /* push element on stack */ @@ -672,7 +672,7 @@ int exiEncodeStartElement(bitstream_t* stream, exi_state_t* state, /* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}MeterReading), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}MeterStatus), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}TMeter), END_ELEMENT] */ if ( se->localPart == 19 && se->namespaceURI == 5 ) { /* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}MeterReading) */ - encodeNBitUnsignedInteger(stream, 0, 2); + encodeNBitUnsignedInteger(stream, 2, 0); /* move on */ state->grammarStack[state->stackIndex] = 66; /* push element on stack */ @@ -680,7 +680,7 @@ int exiEncodeStartElement(bitstream_t* stream, exi_state_t* state, } else if ( se->localPart == 20 && se->namespaceURI == 5 ) { /* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}MeterStatus) */ - encodeNBitUnsignedInteger(stream, 1, 2); + encodeNBitUnsignedInteger(stream, 2, 1); /* move on */ state->grammarStack[state->stackIndex] = 68; /* push element on stack */ @@ -699,7 +699,7 @@ int exiEncodeStartElement(bitstream_t* stream, exi_state_t* state, /* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}MeterStatus), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}TMeter), END_ELEMENT] */ if ( se->localPart == 20 && se->namespaceURI == 5 ) { /* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}MeterStatus) */ - encodeNBitUnsignedInteger(stream, 0, 2); + encodeNBitUnsignedInteger(stream, 2, 0); /* move on */ state->grammarStack[state->stackIndex] = 68; /* push element on stack */ @@ -707,7 +707,7 @@ int exiEncodeStartElement(bitstream_t* stream, exi_state_t* state, } else if ( se->localPart == 39 && se->namespaceURI == 5 ) { /* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}TMeter) */ - encodeNBitUnsignedInteger(stream, 1, 2); + encodeNBitUnsignedInteger(stream, 2, 1); /* move on */ state->grammarStack[state->stackIndex] = 70; /* push element on stack */ @@ -728,7 +728,7 @@ int exiEncodeStartElement(bitstream_t* stream, exi_state_t* state, /* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}TMeter), END_ELEMENT] */ if ( se->localPart == 39 && se->namespaceURI == 5 ) { /* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}TMeter) */ - encodeNBitUnsignedInteger(stream, 0, 1); + encodeNBitUnsignedInteger(stream, 1, 0); /* move on */ state->grammarStack[state->stackIndex] = 70; /* push element on stack */ @@ -799,7 +799,7 @@ int exiEncodeStartElement(bitstream_t* stream, exi_state_t* state, /* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgBody}PCurrent), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}MeterInfo), END_ELEMENT] */ if ( se->localPart == 24 && se->namespaceURI == 4 ) { /* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}PCurrent) */ - encodeNBitUnsignedInteger(stream, 0, 2); + encodeNBitUnsignedInteger(stream, 2, 0); /* move on */ state->grammarStack[state->stackIndex] = 91; /* push element on stack */ @@ -807,7 +807,7 @@ int exiEncodeStartElement(bitstream_t* stream, exi_state_t* state, } else if ( se->localPart == 14 && se->namespaceURI == 4 ) { /* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}MeterInfo) */ - encodeNBitUnsignedInteger(stream, 1, 2); + encodeNBitUnsignedInteger(stream, 2, 1); /* move on */ state->grammarStack[state->stackIndex] = 92; /* push element on stack */ @@ -818,7 +818,7 @@ int exiEncodeStartElement(bitstream_t* stream, exi_state_t* state, /* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgBody}MeterInfo), END_ELEMENT] */ if ( se->localPart == 14 && se->namespaceURI == 4 ) { /* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}MeterInfo) */ - encodeNBitUnsignedInteger(stream, 0, 1); + encodeNBitUnsignedInteger(stream, 1, 0); /* move on */ state->grammarStack[state->stackIndex] = 92; /* push element on stack */ @@ -839,7 +839,7 @@ int exiEncodeStartElement(bitstream_t* stream, exi_state_t* state, /* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgBody}Tariff), END_ELEMENT] */ if ( se->localPart == 63 && se->namespaceURI == 4 ) { /* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}Tariff) */ - encodeNBitUnsignedInteger(stream, 0, 1); + encodeNBitUnsignedInteger(stream, 1, 0); /* move on */ state->grammarStack[state->stackIndex] = 103; /* push element on stack */ @@ -950,7 +950,7 @@ int exiEncodeStartElement(bitstream_t* stream, exi_state_t* state, /* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgBody}EnergyProvider), END_ELEMENT] */ if ( se->localPart == 8 && se->namespaceURI == 4 ) { /* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}EnergyProvider) */ - encodeNBitUnsignedInteger(stream, 0, 1); + encodeNBitUnsignedInteger(stream, 1, 0); /* move on */ state->grammarStack[state->stackIndex] = 122; /* push element on stack */ @@ -961,7 +961,7 @@ int exiEncodeStartElement(bitstream_t* stream, exi_state_t* state, /* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ServiceScope), END_ELEMENT] */ if ( se->localPart == 56 && se->namespaceURI == 4 ) { /* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ServiceScope) */ - encodeNBitUnsignedInteger(stream, 0, 1); + encodeNBitUnsignedInteger(stream, 1, 0); /* move on */ state->grammarStack[state->stackIndex] = 128; /* push element on stack */ @@ -972,7 +972,7 @@ int exiEncodeStartElement(bitstream_t* stream, exi_state_t* state, /* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ServiceList), END_ELEMENT] */ if ( se->localPart == 51 && se->namespaceURI == 4 ) { /* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ServiceList) */ - encodeNBitUnsignedInteger(stream, 0, 1); + encodeNBitUnsignedInteger(stream, 1, 0); /* move on */ state->grammarStack[state->stackIndex] = 134; /* push element on stack */ @@ -993,7 +993,7 @@ int exiEncodeStartElement(bitstream_t* stream, exi_state_t* state, /* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}Service), END_ELEMENT] */ if ( se->localPart == 27 && se->namespaceURI == 5 ) { /* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}Service) */ - encodeNBitUnsignedInteger(stream, 0, 1); + encodeNBitUnsignedInteger(stream, 1, 0); /* move on */ state->grammarStack[state->stackIndex] = 137; /* push element on stack */ @@ -1014,7 +1014,7 @@ int exiEncodeStartElement(bitstream_t* stream, exi_state_t* state, /* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}ServiceName), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}ServiceType), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}ServiceScope), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}ServiceDetails), END_ELEMENT] */ if ( se->localPart == 32 && se->namespaceURI == 5 ) { /* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}ServiceName) */ - encodeNBitUnsignedInteger(stream, 0, 3); + encodeNBitUnsignedInteger(stream, 3, 0); /* move on */ state->grammarStack[state->stackIndex] = 141; /* push element on stack */ @@ -1022,7 +1022,7 @@ int exiEncodeStartElement(bitstream_t* stream, exi_state_t* state, } else if ( se->localPart == 35 && se->namespaceURI == 5 ) { /* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}ServiceType) */ - encodeNBitUnsignedInteger(stream, 1, 3); + encodeNBitUnsignedInteger(stream, 3, 1); /* move on */ state->grammarStack[state->stackIndex] = 143; /* push element on stack */ @@ -1030,7 +1030,7 @@ int exiEncodeStartElement(bitstream_t* stream, exi_state_t* state, } else if ( se->localPart == 33 && se->namespaceURI == 5 ) { /* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}ServiceScope) */ - encodeNBitUnsignedInteger(stream, 2, 3); + encodeNBitUnsignedInteger(stream, 3, 2); /* move on */ state->grammarStack[state->stackIndex] = 144; /* push element on stack */ @@ -1049,7 +1049,7 @@ int exiEncodeStartElement(bitstream_t* stream, exi_state_t* state, /* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}ServiceType), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}ServiceScope), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}ServiceDetails), END_ELEMENT] */ if ( se->localPart == 35 && se->namespaceURI == 5 ) { /* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}ServiceType) */ - encodeNBitUnsignedInteger(stream, 0, 2); + encodeNBitUnsignedInteger(stream, 2, 0); /* move on */ state->grammarStack[state->stackIndex] = 143; /* push element on stack */ @@ -1057,7 +1057,7 @@ int exiEncodeStartElement(bitstream_t* stream, exi_state_t* state, } else if ( se->localPart == 33 && se->namespaceURI == 5 ) { /* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}ServiceScope) */ - encodeNBitUnsignedInteger(stream, 1, 2); + encodeNBitUnsignedInteger(stream, 2, 1); /* move on */ state->grammarStack[state->stackIndex] = 144; /* push element on stack */ @@ -1076,7 +1076,7 @@ int exiEncodeStartElement(bitstream_t* stream, exi_state_t* state, /* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}ServiceScope), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}ServiceDetails), END_ELEMENT] */ if ( se->localPart == 33 && se->namespaceURI == 5 ) { /* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}ServiceScope) */ - encodeNBitUnsignedInteger(stream, 0, 2); + encodeNBitUnsignedInteger(stream, 2, 0); /* move on */ state->grammarStack[state->stackIndex] = 144; /* push element on stack */ @@ -1084,7 +1084,7 @@ int exiEncodeStartElement(bitstream_t* stream, exi_state_t* state, } else if ( se->localPart == 29 && se->namespaceURI == 5 ) { /* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}ServiceDetails) */ - encodeNBitUnsignedInteger(stream, 1, 2); + encodeNBitUnsignedInteger(stream, 2, 1); /* move on */ state->grammarStack[state->stackIndex] = 145; /* push element on stack */ @@ -1095,7 +1095,7 @@ int exiEncodeStartElement(bitstream_t* stream, exi_state_t* state, /* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}ServiceDetails), END_ELEMENT] */ if ( se->localPart == 29 && se->namespaceURI == 5 ) { /* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}ServiceDetails) */ - encodeNBitUnsignedInteger(stream, 0, 1); + encodeNBitUnsignedInteger(stream, 1, 0); /* move on */ state->grammarStack[state->stackIndex] = 145; /* push element on stack */ @@ -1116,7 +1116,7 @@ int exiEncodeStartElement(bitstream_t* stream, exi_state_t* state, /* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgBody}MeteringAuthPubKey), END_ELEMENT] */ if ( se->localPart == 15 && se->namespaceURI == 4 ) { /* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}MeteringAuthPubKey) */ - encodeNBitUnsignedInteger(stream, 0, 1); + encodeNBitUnsignedInteger(stream, 1, 0); /* move on */ state->grammarStack[state->stackIndex] = 154; /* push element on stack */ @@ -1187,7 +1187,7 @@ int exiEncodeStartElement(bitstream_t* stream, exi_state_t* state, /* FirstStartTagStartTag[START_ELEMENT({urn:iso:15118:2:2010:MsgDef}BodyElement), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}LineLockReq), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}LineLockRes), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}MeteringReceiptReq), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}MeteringReceiptRes), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}MeteringStatusReq), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}MeteringStatusRes), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}PaymentDetailsReq), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}PaymentDetailsRes), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}PowerDeliveryReq), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}PowerDeliveryRes), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}PowerDiscoveryReq), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}PowerDiscoveryRes), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ServiceDiscoveryReq), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ServiceDiscoveryRes), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ServicePaymentSelectionReq), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ServicePaymentSelectionRes), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}SessionSetupReq), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}SessionSetupRes), END_ELEMENT] */ if ( se->localPart == 2 && se->namespaceURI == 6 ) { /* START_ELEMENT({urn:iso:15118:2:2010:MsgDef}BodyElement) */ - encodeNBitUnsignedInteger(stream, 0, 5); + encodeNBitUnsignedInteger(stream, 5, 0); /* move on */ state->grammarStack[state->stackIndex] = 190; /* push element on stack */ @@ -1195,7 +1195,7 @@ int exiEncodeStartElement(bitstream_t* stream, exi_state_t* state, } else if ( se->localPart == 10 && se->namespaceURI == 4 ) { /* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}LineLockReq) */ - encodeNBitUnsignedInteger(stream, 1, 5); + encodeNBitUnsignedInteger(stream, 5, 1); /* move on */ state->grammarStack[state->stackIndex] = 190; /* push element on stack */ @@ -1203,7 +1203,7 @@ int exiEncodeStartElement(bitstream_t* stream, exi_state_t* state, } else if ( se->localPart == 12 && se->namespaceURI == 4 ) { /* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}LineLockRes) */ - encodeNBitUnsignedInteger(stream, 2, 5); + encodeNBitUnsignedInteger(stream, 5, 2); /* move on */ state->grammarStack[state->stackIndex] = 190; /* push element on stack */ @@ -1211,7 +1211,7 @@ int exiEncodeStartElement(bitstream_t* stream, exi_state_t* state, } else if ( se->localPart == 16 && se->namespaceURI == 4 ) { /* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}MeteringReceiptReq) */ - encodeNBitUnsignedInteger(stream, 3, 5); + encodeNBitUnsignedInteger(stream, 5, 3); /* move on */ state->grammarStack[state->stackIndex] = 190; /* push element on stack */ @@ -1219,7 +1219,7 @@ int exiEncodeStartElement(bitstream_t* stream, exi_state_t* state, } else if ( se->localPart == 18 && se->namespaceURI == 4 ) { /* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}MeteringReceiptRes) */ - encodeNBitUnsignedInteger(stream, 4, 5); + encodeNBitUnsignedInteger(stream, 5, 4); /* move on */ state->grammarStack[state->stackIndex] = 190; /* push element on stack */ @@ -1235,7 +1235,7 @@ int exiEncodeStartElement(bitstream_t* stream, exi_state_t* state, } else if ( se->localPart == 22 && se->namespaceURI == 4 ) { /* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}MeteringStatusRes) */ - encodeNBitUnsignedInteger(stream, 6, 5); + encodeNBitUnsignedInteger(stream, 5, 6); /* move on */ state->grammarStack[state->stackIndex] = 190; /* push element on stack */ @@ -1243,7 +1243,7 @@ int exiEncodeStartElement(bitstream_t* stream, exi_state_t* state, } else if ( se->localPart == 32 && se->namespaceURI == 4 ) { /* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}PaymentDetailsReq) */ - encodeNBitUnsignedInteger(stream, 7, 5); + encodeNBitUnsignedInteger(stream, 5, 7); /* move on */ state->grammarStack[state->stackIndex] = 190; /* push element on stack */ @@ -1251,7 +1251,7 @@ int exiEncodeStartElement(bitstream_t* stream, exi_state_t* state, } else if ( se->localPart == 34 && se->namespaceURI == 4 ) { /* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}PaymentDetailsRes) */ - encodeNBitUnsignedInteger(stream, 8, 5); + encodeNBitUnsignedInteger(stream, 5, 8); /* move on */ state->grammarStack[state->stackIndex] = 190; /* push element on stack */ @@ -1259,7 +1259,7 @@ int exiEncodeStartElement(bitstream_t* stream, exi_state_t* state, } else if ( se->localPart == 36 && se->namespaceURI == 4 ) { /* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}PowerDeliveryReq) */ - encodeNBitUnsignedInteger(stream, 9, 5); + encodeNBitUnsignedInteger(stream, 5, 9); /* move on */ state->grammarStack[state->stackIndex] = 190; /* push element on stack */ @@ -1267,7 +1267,7 @@ int exiEncodeStartElement(bitstream_t* stream, exi_state_t* state, } else if ( se->localPart == 38 && se->namespaceURI == 4 ) { /* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}PowerDeliveryRes) */ - encodeNBitUnsignedInteger(stream, 10, 5); + encodeNBitUnsignedInteger(stream, 5, 10); /* move on */ state->grammarStack[state->stackIndex] = 190; /* push element on stack */ @@ -1275,7 +1275,7 @@ int exiEncodeStartElement(bitstream_t* stream, exi_state_t* state, } else if ( se->localPart == 40 && se->namespaceURI == 4 ) { /* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}PowerDiscoveryReq) */ - encodeNBitUnsignedInteger(stream, 11, 5); + encodeNBitUnsignedInteger(stream, 5, 11); /* move on */ state->grammarStack[state->stackIndex] = 190; /* push element on stack */ @@ -1283,7 +1283,7 @@ int exiEncodeStartElement(bitstream_t* stream, exi_state_t* state, } else if ( se->localPart == 42 && se->namespaceURI == 4 ) { /* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}PowerDiscoveryRes) */ - encodeNBitUnsignedInteger(stream, 12, 5); + encodeNBitUnsignedInteger(stream, 5, 12); /* move on */ state->grammarStack[state->stackIndex] = 190; /* push element on stack */ @@ -1291,7 +1291,7 @@ int exiEncodeStartElement(bitstream_t* stream, exi_state_t* state, } else if ( se->localPart == 47 && se->namespaceURI == 4 ) { /* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ServiceDiscoveryReq) */ - encodeNBitUnsignedInteger(stream, 13, 5); + encodeNBitUnsignedInteger(stream, 5, 13); /* move on */ state->grammarStack[state->stackIndex] = 190; /* push element on stack */ @@ -1299,7 +1299,7 @@ int exiEncodeStartElement(bitstream_t* stream, exi_state_t* state, } else if ( se->localPart == 49 && se->namespaceURI == 4 ) { /* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ServiceDiscoveryRes) */ - encodeNBitUnsignedInteger(stream, 14, 5); + encodeNBitUnsignedInteger(stream, 5, 14); /* move on */ state->grammarStack[state->stackIndex] = 190; /* push element on stack */ @@ -1307,7 +1307,7 @@ int exiEncodeStartElement(bitstream_t* stream, exi_state_t* state, } else if ( se->localPart == 52 && se->namespaceURI == 4 ) { /* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ServicePaymentSelectionReq) */ - encodeNBitUnsignedInteger(stream, 15, 5); + encodeNBitUnsignedInteger(stream, 5, 15); /* move on */ state->grammarStack[state->stackIndex] = 190; /* push element on stack */ @@ -1315,7 +1315,7 @@ int exiEncodeStartElement(bitstream_t* stream, exi_state_t* state, } else if ( se->localPart == 54 && se->namespaceURI == 4 ) { /* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ServicePaymentSelectionRes) */ - encodeNBitUnsignedInteger(stream, 16, 5); + encodeNBitUnsignedInteger(stream, 5, 16); /* move on */ state->grammarStack[state->stackIndex] = 190; /* push element on stack */ @@ -1323,7 +1323,7 @@ int exiEncodeStartElement(bitstream_t* stream, exi_state_t* state, } else if ( se->localPart == 58 && se->namespaceURI == 4 ) { /* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}SessionSetupReq) */ - encodeNBitUnsignedInteger(stream, 17, 5); + encodeNBitUnsignedInteger(stream, 5, 17); /* move on */ state->grammarStack[state->stackIndex] = 190; /* push element on stack */ @@ -1331,7 +1331,7 @@ int exiEncodeStartElement(bitstream_t* stream, exi_state_t* state, } else if ( se->localPart == 60 && se->namespaceURI == 4 ) { /* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}SessionSetupRes) */ - encodeNBitUnsignedInteger(stream, 18, 5); + encodeNBitUnsignedInteger(stream, 5, 18); /* move on */ state->grammarStack[state->stackIndex] = 190; /* push element on stack */ @@ -1342,7 +1342,7 @@ int exiEncodeStartElement(bitstream_t* stream, exi_state_t* state, /* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgDef}Notification), END_ELEMENT] */ if ( se->localPart == 6 && se->namespaceURI == 6 ) { /* START_ELEMENT({urn:iso:15118:2:2010:MsgDef}Notification) */ - encodeNBitUnsignedInteger(stream, 0, 1); + encodeNBitUnsignedInteger(stream, 1, 0); /* move on */ state->grammarStack[state->stackIndex] = 170; /* push element on stack */ @@ -1363,7 +1363,7 @@ int exiEncodeStartElement(bitstream_t* stream, exi_state_t* state, /* FirstStartTagStartTag[START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}FaultCode), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}FaultMsg), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}EventList), END_ELEMENT] */ if ( se->localPart == 13 && se->namespaceURI == 5 ) { /* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}FaultCode) */ - encodeNBitUnsignedInteger(stream, 0, 2); + encodeNBitUnsignedInteger(stream, 2, 0); /* move on */ state->grammarStack[state->stackIndex] = 179; /* push element on stack */ @@ -1371,7 +1371,7 @@ int exiEncodeStartElement(bitstream_t* stream, exi_state_t* state, } else if ( se->localPart == 14 && se->namespaceURI == 5 ) { /* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}FaultMsg) */ - encodeNBitUnsignedInteger(stream, 1, 2); + encodeNBitUnsignedInteger(stream, 2, 1); /* move on */ state->grammarStack[state->stackIndex] = 181; /* push element on stack */ @@ -1390,7 +1390,7 @@ int exiEncodeStartElement(bitstream_t* stream, exi_state_t* state, /* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}ServiceSessionID), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}ProtocolVersion), END_ELEMENT] */ if ( se->localPart == 34 && se->namespaceURI == 5 ) { /* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}ServiceSessionID) */ - encodeNBitUnsignedInteger(stream, 0, 2); + encodeNBitUnsignedInteger(stream, 2, 0); /* move on */ state->grammarStack[state->stackIndex] = 174; /* push element on stack */ @@ -1398,7 +1398,7 @@ int exiEncodeStartElement(bitstream_t* stream, exi_state_t* state, } else if ( se->localPart == 25 && se->namespaceURI == 5 ) { /* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}ProtocolVersion) */ - encodeNBitUnsignedInteger(stream, 1, 2); + encodeNBitUnsignedInteger(stream, 2, 1); /* move on */ state->grammarStack[state->stackIndex] = 175; /* push element on stack */ @@ -1409,7 +1409,7 @@ int exiEncodeStartElement(bitstream_t* stream, exi_state_t* state, /* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}ProtocolVersion), END_ELEMENT] */ if ( se->localPart == 25 && se->namespaceURI == 5 ) { /* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}ProtocolVersion) */ - encodeNBitUnsignedInteger(stream, 0, 1); + encodeNBitUnsignedInteger(stream, 1, 0); /* move on */ state->grammarStack[state->stackIndex] = 175; /* push element on stack */ @@ -1420,7 +1420,7 @@ int exiEncodeStartElement(bitstream_t* stream, exi_state_t* state, /* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}FaultMsg), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}EventList), END_ELEMENT] */ if ( se->localPart == 14 && se->namespaceURI == 5 ) { /* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}FaultMsg) */ - encodeNBitUnsignedInteger(stream, 0, 2); + encodeNBitUnsignedInteger(stream, 2, 0); /* move on */ state->grammarStack[state->stackIndex] = 181; /* push element on stack */ @@ -1428,7 +1428,7 @@ int exiEncodeStartElement(bitstream_t* stream, exi_state_t* state, } else if ( se->localPart == 10 && se->namespaceURI == 5 ) { /* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}EventList) */ - encodeNBitUnsignedInteger(stream, 1, 2); + encodeNBitUnsignedInteger(stream, 2, 1); /* move on */ state->grammarStack[state->stackIndex] = 183; /* push element on stack */ @@ -1439,7 +1439,7 @@ int exiEncodeStartElement(bitstream_t* stream, exi_state_t* state, /* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}EventList), END_ELEMENT] */ if ( se->localPart == 10 && se->namespaceURI == 5 ) { /* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}EventList) */ - encodeNBitUnsignedInteger(stream, 0, 1); + encodeNBitUnsignedInteger(stream, 1, 0); /* move on */ state->grammarStack[state->stackIndex] = 183; /* push element on stack */ @@ -1541,15 +1541,15 @@ int exiEncodeEndElement(bitstream_t* stream, exi_state_t* state, break; case 64: /* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}MeterReading), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}MeterStatus), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}TMeter), END_ELEMENT] */ - encodeNBitUnsignedInteger(stream, 3, 2); + encodeNBitUnsignedInteger(stream, 2, 3); break; case 62: /* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}MeterPubKey), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}MeterReading), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}MeterStatus), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}TMeter), END_ELEMENT] */ - encodeNBitUnsignedInteger(stream, 4, 3); + encodeNBitUnsignedInteger(stream, 3, 4); break; case 59: /* FirstStartTagStartTag[START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}MeterID), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}MeterPubKey), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}MeterReading), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}MeterStatus), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}TMeter), END_ELEMENT] */ - encodeNBitUnsignedInteger(stream, 5, 3); + encodeNBitUnsignedInteger(stream, 3, 5); break; case 71: /* Element[END_ELEMENT] */ @@ -1713,11 +1713,11 @@ int exiEncodeEndElement(bitstream_t* stream, exi_state_t* state, break; case 141: /* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}ServiceType), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}ServiceScope), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}ServiceDetails), END_ELEMENT] */ - encodeNBitUnsignedInteger(stream, 3, 2); + encodeNBitUnsignedInteger(stream, 2, 3); break; case 139: /* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}ServiceName), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}ServiceType), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}ServiceScope), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}ServiceDetails), END_ELEMENT] */ - encodeNBitUnsignedInteger(stream, 4, 3); + encodeNBitUnsignedInteger(stream, 3, 4); break; case 147: /* Element[END_ELEMENT] */ @@ -1805,7 +1805,7 @@ int exiEncodeEndElement(bitstream_t* stream, exi_state_t* state, break; case 171: /* FirstStartTagStartTag[START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}FaultCode), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}FaultMsg), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}EventList), END_ELEMENT] */ - encodeNBitUnsignedInteger(stream, 3, 2); + encodeNBitUnsignedInteger(stream, 2, 3); break; case 185: /* Element[END_ELEMENT] */ @@ -1829,7 +1829,7 @@ int exiEncodeEndElement(bitstream_t* stream, exi_state_t* state, break; case 167: /* FirstStartTagStartTag[START_ELEMENT({urn:iso:15118:2:2010:MsgDef}BodyElement), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}LineLockReq), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}LineLockRes), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}MeteringReceiptReq), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}MeteringReceiptRes), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}MeteringStatusReq), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}MeteringStatusRes), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}PaymentDetailsReq), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}PaymentDetailsRes), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}PowerDeliveryReq), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}PowerDeliveryRes), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}PowerDiscoveryReq), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}PowerDiscoveryRes), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ServiceDiscoveryReq), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ServiceDiscoveryRes), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ServicePaymentSelectionReq), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ServicePaymentSelectionRes), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}SessionSetupReq), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}SessionSetupRes), END_ELEMENT] */ - encodeNBitUnsignedInteger(stream, 19, 5); + encodeNBitUnsignedInteger(stream, 5, 19); break; default: @@ -1955,7 +1955,7 @@ int exiEncodeCharacters(bitstream_t* stream, exi_state_t* state, if (val->type == INTEGER_64) { /* CHARACTERS[INTEGER_64] */ /* xsi:type OR xsi:nil */ - encodeNBitUnsignedInteger(stream, 0, 1); + encodeNBitUnsignedInteger(stream, 1, 0); encodeInteger64(stream, val->int64); /* move on */ state->grammarStack[state->stackIndex] = 79; @@ -2146,7 +2146,7 @@ int exiEncodeCharacters(bitstream_t* stream, exi_state_t* state, if (val->type == STRING) { /* CHARACTERS[STRING] */ /* xsi:type OR xsi:nil */ - encodeNBitUnsignedInteger(stream, 0, 1); + encodeNBitUnsignedInteger(stream, 1, 0); encodeStringValue(stream, &val->string); /* move on */ state->grammarStack[state->stackIndex] = 186; diff --git a/src/codec/EXIHeader.c b/src/codec/EXIHeaderDecoder.c similarity index 84% rename from src/codec/EXIHeader.c rename to src/codec/EXIHeaderDecoder.c index 90857e1..51a7cd4 100644 --- a/src/codec/EXIHeader.c +++ b/src/codec/EXIHeaderDecoder.c @@ -26,14 +26,12 @@ #include #include -#include "EXIHeader.h" +#include "EXIHeaderDecoder.h" #include "BitInputStream.h" -#include "BitOutputStream.h" #include "BitDecoderChannel.h" -#include "BitEncoderChannel.h" -#ifndef EXI_HEADER_C -#define EXI_HEADER_C +#ifndef EXI_HEADER_DECODER_C +#define EXI_HEADER_DECODER_C int readEXIHeader(bitstream_t* stream) { uint8_t header; @@ -54,10 +52,6 @@ int readEXIHeader(bitstream_t* stream) { return errn; } -int writeEXIHeader(bitstream_t* stream) { - return writeBits(stream, 144, 8); -} - #endif diff --git a/src/codec/EXIHeaderDecoder.h b/src/codec/EXIHeaderDecoder.h new file mode 100644 index 0000000..a6c3b5a --- /dev/null +++ b/src/codec/EXIHeaderDecoder.h @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2007-2010 Siemens AG + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ + +/******************************************************************* + * + * @author Daniel.Peintner.EXT@siemens.com + * @version 0.1 + * @contact Joerg.Heuer@siemens.com + * + ********************************************************************/ + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#include "EXITypes.h" + +#ifndef EXI_HEADER_DECODER_H +#define EXI_HEADER_DECODER_H + +int readEXIHeader(bitstream_t* stream); + +#endif + + +#ifdef __cplusplus +} +#endif diff --git a/src/codec/EXIHeaderEncoder.c b/src/codec/EXIHeaderEncoder.c new file mode 100644 index 0000000..d14e91e --- /dev/null +++ b/src/codec/EXIHeaderEncoder.c @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2007-2010 Siemens AG + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ + +/******************************************************************* + * + * @author Daniel.Peintner.EXT@siemens.com + * @version 0.1 + * @contact Joerg.Heuer@siemens.com + * + ********************************************************************/ + +#include +#include + +#include "EXIHeaderEncoder.h" +#include "BitOutputStream.h" +#include "BitEncoderChannel.h" + +#ifndef EXI_HEADER_ENCODER_C +#define EXI_HEADER_ENCODER_C + +int writeEXIHeader(bitstream_t* stream) { + return writeBits(stream, 8, 144); +} + + +#endif + + diff --git a/src/codec/EXIHeader.h b/src/codec/EXIHeaderEncoder.h similarity index 89% rename from src/codec/EXIHeader.h rename to src/codec/EXIHeaderEncoder.h index 6a2b1a0..b286f07 100644 --- a/src/codec/EXIHeader.h +++ b/src/codec/EXIHeaderEncoder.h @@ -31,10 +31,8 @@ extern "C" { #include "EXITypes.h" -#ifndef EXI_HEADER_H -#define EXI_HEADER_H - -int readEXIHeader(bitstream_t* stream); +#ifndef EXI_HEADER_ENCODER_H +#define EXI_HEADER_ENCODER_H int writeEXIHeader(bitstream_t* stream); diff --git a/src/test/main_codec.c b/src/test/main_codec.c index c960265..408ce30 100644 --- a/src/test/main_codec.c +++ b/src/test/main_codec.c @@ -24,7 +24,7 @@ *

Sample program to illustrate how to read an EXI stream and * directly write it again to an output

* - *

e.g., data/test/sessionSetupReq.xml_SCHEMA.exi out/test/sessionSetupReq.xml_SCHEMA.exi

+ *

e.g., data/test/sessionSetupReq.xml.exi out/test/sessionSetupReq.xml.exi

********************************************************************/ #include @@ -104,13 +104,13 @@ int main(int argc, char *argv[]) { do { if (errn < 0) { - printf("[Encode-ERROR] %d \n", errno); + printf("[Encode-ERROR] %d \n", errn); return errn; } errn = exiDecodeNextEvent(&iStream, &stateDecode, &event); if (errn < 0) { - printf("[Decode-ERROR] %d \n", errno); + printf("[Decode-ERROR] %d \n", errn); return errn; } @@ -119,7 +119,7 @@ int main(int argc, char *argv[]) { /* decode */ errn = exiDecodeStartDocument(&iStream, &stateDecode); if (errn < 0) { - printf("[Decode-ERROR] %d \n", errno); + printf("[Decode-ERROR] %d \n", errn); return errn; } printf(">> START_DOCUMENT \n"); @@ -130,7 +130,7 @@ int main(int argc, char *argv[]) { /* decode */ errn = exiDecodeEndDocument(&iStream, &stateDecode); if (errn < 0) { - printf("[Decode-ERROR] %d \n", errno); + printf("[Decode-ERROR] %d \n", errn); return errn; } printf(">> END_DOCUMENT \n"); @@ -143,7 +143,7 @@ int main(int argc, char *argv[]) { /* decode */ errn = exiDecodeStartElement(&iStream, &stateDecode, &eqn); if (errn < 0) { - printf("[Decode-ERROR] %d \n", errno); + printf("[Decode-ERROR] %d \n", errn); return errn; } exiGetLocalName(eqn.namespaceURI, eqn.localPart, &localName); @@ -156,7 +156,7 @@ int main(int argc, char *argv[]) { /* decode */ errn = exiDecodeEndElement(&iStream, &stateDecode, &eqn); if (errn < 0) { - printf("[Decode-ERROR] %d \n", errno); + printf("[Decode-ERROR] %d \n", errn); return errn; } exiGetLocalName(eqn.namespaceURI, eqn.localPart, &localName); @@ -169,7 +169,7 @@ int main(int argc, char *argv[]) { /* decode */ errn = exiDecodeCharacters(&iStream, &stateDecode, &val); if (errn < 0) { - printf("[Decode-ERROR] %d \n", errno); + printf("[Decode-ERROR] %d \n", errn); return errn; } if (val.type == INTEGER_BIG) { @@ -198,7 +198,7 @@ int main(int argc, char *argv[]) { /* decode */ errn = exiDecodeAttribute(&iStream, &stateDecode, &eqn, &val); if (errn < 0) { - printf("[Decode-ERROR] %d \n", errno); + printf("[Decode-ERROR] %d \n", errn); return errn; } exiGetLocalName(eqn.namespaceURI, eqn.localPart, &localName);