This commit is contained in:
sebastiankb 2011-04-15 12:13:20 +00:00
parent 4360ffa8a1
commit c6a1d57ae9
180 changed files with 50929 additions and 0 deletions
tags
release_0.3.1
release_0.3

1112
tags/release_0.3.1/.cproject Normal file

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,69 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>OpenV2G</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
<triggers>clean,full,incremental,</triggers>
<arguments>
<dictionary>
<key>?name?</key>
<value></value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.append_environment</key>
<value>true</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.buildArguments</key>
<value></value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.buildCommand</key>
<value>make</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.buildLocation</key>
<value>${workspace_loc:/OpenV2G/Debug}</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.contents</key>
<value>org.eclipse.cdt.make.core.activeConfigSettings</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.enableAutoBuild</key>
<value>false</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.enableCleanBuild</key>
<value>true</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.enableFullBuild</key>
<value>true</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.stopOnError</key>
<value>true</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.useDefaultBuildCmd</key>
<value>true</value>
</dictionary>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.cdt.core.cnature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
</natures>
</projectDescription>

View file

@ -0,0 +1,165 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
This version of the GNU Lesser General Public License incorporates
the terms and conditions of version 3 of the GNU General Public
License, supplemented by the additional permissions listed below.
0. Additional Definitions.
As used herein, "this License" refers to version 3 of the GNU Lesser
General Public License, and the "GNU GPL" refers to version 3 of the GNU
General Public License.
"The Library" refers to a covered work governed by this License,
other than an Application or a Combined Work as defined below.
An "Application" is any work that makes use of an interface provided
by the Library, but which is not otherwise based on the Library.
Defining a subclass of a class defined by the Library is deemed a mode
of using an interface provided by the Library.
A "Combined Work" is a work produced by combining or linking an
Application with the Library. The particular version of the Library
with which the Combined Work was made is also called the "Linked
Version".
The "Minimal Corresponding Source" for a Combined Work means the
Corresponding Source for the Combined Work, excluding any source code
for portions of the Combined Work that, considered in isolation, are
based on the Application, and not on the Linked Version.
The "Corresponding Application Code" for a Combined Work means the
object code and/or source code for the Application, including any data
and utility programs needed for reproducing the Combined Work from the
Application, but excluding the System Libraries of the Combined Work.
1. Exception to Section 3 of the GNU GPL.
You may convey a covered work under sections 3 and 4 of this License
without being bound by section 3 of the GNU GPL.
2. Conveying Modified Versions.
If you modify a copy of the Library, and, in your modifications, a
facility refers to a function or data to be supplied by an Application
that uses the facility (other than as an argument passed when the
facility is invoked), then you may convey a copy of the modified
version:
a) under this License, provided that you make a good faith effort to
ensure that, in the event an Application does not supply the
function or data, the facility still operates, and performs
whatever part of its purpose remains meaningful, or
b) under the GNU GPL, with none of the additional permissions of
this License applicable to that copy.
3. Object Code Incorporating Material from Library Header Files.
The object code form of an Application may incorporate material from
a header file that is part of the Library. You may convey such object
code under terms of your choice, provided that, if the incorporated
material is not limited to numerical parameters, data structure
layouts and accessors, or small macros, inline functions and templates
(ten or fewer lines in length), you do both of the following:
a) Give prominent notice with each copy of the object code that the
Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the object code with a copy of the GNU GPL and this license
document.
4. Combined Works.
You may convey a Combined Work under terms of your choice that,
taken together, effectively do not restrict modification of the
portions of the Library contained in the Combined Work and reverse
engineering for debugging such modifications, if you also do each of
the following:
a) Give prominent notice with each copy of the Combined Work that
the Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the Combined Work with a copy of the GNU GPL and this license
document.
c) For a Combined Work that displays copyright notices during
execution, include the copyright notice for the Library among
these notices, as well as a reference directing the user to the
copies of the GNU GPL and this license document.
d) Do one of the following:
0) Convey the Minimal Corresponding Source under the terms of this
License, and the Corresponding Application Code in a form
suitable for, and under terms that permit, the user to
recombine or relink the Application with a modified version of
the Linked Version to produce a modified Combined Work, in the
manner specified by section 6 of the GNU GPL for conveying
Corresponding Source.
1) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (a) uses at run time
a copy of the Library already present on the user's computer
system, and (b) will operate properly with a modified version
of the Library that is interface-compatible with the Linked
Version.
e) Provide Installation Information, but only if you would otherwise
be required to provide such information under section 6 of the
GNU GPL, and only to the extent that such information is
necessary to install and execute a modified version of the
Combined Work produced by recombining or relinking the
Application with a modified version of the Linked Version. (If
you use option 4d0, the Installation Information must accompany
the Minimal Corresponding Source and Corresponding Application
Code. If you use option 4d1, you must provide the Installation
Information in the manner specified by section 6 of the GNU GPL
for conveying Corresponding Source.)
5. Combined Libraries.
You may place library facilities that are a work based on the
Library side by side in a single library together with other library
facilities that are not Applications and are not covered by this
License, and convey such a combined library under terms of your
choice, if you do both of the following:
a) Accompany the combined library with a copy of the same work based
on the Library, uncombined with any other library facilities,
conveyed under the terms of this License.
b) Give prominent notice with the combined library that part of it
is a work based on the Library, and explaining where to find the
accompanying uncombined form of the same work.
6. Revised Versions of the GNU Lesser General Public License.
The Free Software Foundation may publish revised and/or new versions
of the GNU Lesser General Public License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the
Library as you received it specifies that a certain numbered version
of the GNU Lesser General Public License "or any later version"
applies to it, you have the option of following the terms and
conditions either of that published version or of any later version
published by the Free Software Foundation. If the Library as you
received it does not specify a version number of the GNU Lesser
General Public License, you may choose any version of the GNU Lesser
General Public License ever published by the Free Software Foundation.
If the Library as you received it specifies that a proxy can decide
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.

View file

@ -0,0 +1,61 @@
-------------------------------------------------------------------------
OpenV2G - an open source project implementing the basic functionality of the ISO IEC 15118 vehicle to grid (V2G) communication interface
Version 0.3.1, released December 22, 2010
http://openv2g.sourceforge.net/
Please report bugs via the SourceForge bug tracking system at http://sourceforge.net/tracker/?group_id=350113.
Thank you.
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 <http://www.gnu.org/licenses/>.
-------------------------------------------------------------------------
CHANGES from version 0.3:
-------------------------------------------------------------------------
* Bug-fixes
* reduced memory usage
* some type changes in the EXI codec and V2G service:
** struct v2gService->struct EXIService in v2g_service.h
** size_t->uint16_t in v2g_serviceClientDataTransmitter.h and doIP.h
* renaming of some enumeration values in v2g_serviceDataTypes.h
-------------------------------------------------------------------------
CHANGES from version 0.2.2:
-------------------------------------------------------------------------
* Bug-fixes
* first DoIP implementation
* V2G message error handling
* adaption of V2G schema changes
* code optimizations
-------------------------------------------------------------------------
CHANGES from version 0.2.1:
-------------------------------------------------------------------------
* Bug-fixes
* adaption of V2G schema changes
* some code optimizations
-------------------------------------------------------------------------
CHANGES from version 0.2:
-------------------------------------------------------------------------
* Bug-fixes
* Fixed compiler warnings
-------------------------------------------------------------------------
CHANGES from version 0.1:
-------------------------------------------------------------------------
* Bug-fixes
* Service and Client added

View file

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<ns3:V2G_Message xmlns:ns1="urn:iso:15118:2:2010:MsgBody"
xmlns:ns2="urn:iso:15118:2:2010:MsgDataTypes"
xmlns:ns3="urn:iso:15118:2:2010:MsgDef"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:iso:15118:2:2010:MsgDef V2G_CI_MsgDef.xsd">
<ns3:Header>
<ns3:SessionInformation>
<ns2:SessionID>3031323334353637</ns2:SessionID>
<ns2:ProtocolVersion>1</ns2:ProtocolVersion>
</ns3:SessionInformation>
</ns3:Header>
<ns3:Body>
<ns1:SessionSetupReq>
<ns1:PEVStatus>
<ns2:ConnectorLocked>0</ns2:ConnectorLocked>
<ns2:ChargerStandby>1</ns2:ChargerStandby>
</ns1:PEVStatus>
</ns1:SessionSetupReq>
</ns3:Body>
</ns3:V2G_Message>

View file

@ -0,0 +1 @@
<EFBFBD>˜A<EFBFBD>™¡©±ºc<>

View file

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<v2gci_d:V2G_Message xmlns:v2gci_d="urn:iso:15118:2:2010:MsgDef"
xmlns:v2gci_t="urn:iso:15118:2:2010:MsgDataTypes"
xmlns:ns0="urn:iso:15118:2:2010:MsgBody"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:iso:15118:2:2010:MsgDef V2G_CI_MsgDef.xsd">
<v2gci_d:Header>
<v2gci_d:SessionInformation>
<v2gci_t:SessionID>0Fb80Fb80Fb80Fb8</v2gci_t:SessionID>
<v2gci_t:ProtocolVersion>1</v2gci_t:ProtocolVersion>
</v2gci_d:SessionInformation>
</v2gci_d:Header>
<v2gci_d:Body>
<ns0:SessionSetupRes>
<ns0:ResponseCode>OK_SessionSetup</ns0:ResponseCode>
<ns0:EVSEID>54</ns0:EVSEID>
<ns0:EVSEStatus>
<v2gci_t:FatalError>0</v2gci_t:FatalError>
<v2gci_t:EVSEStandby>1</v2gci_t:EVSEStandby>
<v2gci_t:ConnectorLocked>1</v2gci_t:ConnectorLocked>
<v2gci_t:PowerSwitchClosed>0</v2gci_t:PowerSwitchClosed>
<v2gci_t:RCD>1</v2gci_t:RCD>
<v2gci_t:ShutDownTime>123456789</v2gci_t:ShutDownTime>
</ns0:EVSEStatus>
<ns0:TCurrent>123456789</ns0:TCurrent>
</ns0:SessionSetupRes>
</v2gci_d:Body>
</v2gci_d:V2G_Message>

View file

@ -0,0 +1 @@
<EFBFBD>˜@}À}À}À}Âc<>TjVk¼é+5Þt

View file

@ -0,0 +1,288 @@
/*
* 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 <http://www.gnu.org/licenses/>.
*/
/*******************************************************************
*
* @author Daniel.Peintner.EXT@siemens.com
* @version 0.3.1
* @contact Joerg.Heuer@siemens.com
*
* Bit decoding functionalities
*
********************************************************************/
#include <stdlib.h>
#include <stdint.h>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include "BitDecoderChannel.h"
#include "BitInputStream.h"
#include "EXITypes.h"
#ifndef BIT_DECODER_CHANNEL_C
#define BIT_DECODER_CHANNEL_C
/* only the least significant 8 bits are filled properly */
int _decode(bitstream_t* stream, uint32_t* b) {
return readBits(stream, 8, b);
}
int decodeBoolean(bitstream_t* stream, int* b) {
uint32_t ub;
int errn = readBits(stream, 1, &ub);
*b = (ub == 0) ? 0 : 1;
return errn;
}
int decodeNBitUnsignedInteger(bitstream_t* stream, uint16_t nbits, uint32_t* uint32) {
if (nbits == 0) {
*uint32 = 0;
return 0;
} else {
return readBits(stream, nbits, uint32);
}
}
int decodeUnsignedInteger16(bitstream_t* stream, uint16_t* uint16) {
unsigned int mShift = 0;
int errn = 0;
uint32_t b;
*uint16 = 0;
do {
/* 1. Read the next octet */
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
* the current value */
*uint16 += (b & 127) << mShift;
/* 3. Multiply the multiplier by 128 */
mShift += 7;
/* 4. If the most significant bit of the octet was 1, go back to step 1 */
} while (errn >= 0 && (b >> 7) == 1);
return errn;
}
int decodeUnsignedInteger32(bitstream_t* stream, uint32_t* uint32) {
/* 0XXXXXXX ... 1XXXXXXX 1XXXXXXX */
unsigned int mShift = 0;
int errn = 0;
uint32_t b;
*uint32 = 0;
do {
/* 1. Read the next octet */
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
* the current value */
*uint32 += (b & 127) << mShift;
/* 3. Multiply the multiplier by 128 */
mShift += 7;
/* 4. If the most significant bit of the octet was 1, go back to step 1 */
} while (errn >= 0 && (b >> 7) == 1);
return errn;
}
/**
* Decode an arbitrary precision non negative integer using a sequence of
* octets. The most significant bit of the last octet is set to zero to
* indicate sequence termination. Only seven bits per octet are used to
* store the integer's value.
*/
int decodeUnsignedInteger64(bitstream_t* stream, uint64_t* uint64) {
unsigned int mShift = 0;
int errn = 0;
uint32_t b;
*uint64 = 0L;
do {
errn = _decode(stream, &b);
*uint64 += ((uint64_t) (b & 127)) << mShift;
mShift += 7;
} while (errn >= 0 && (b >> 7) == 1);
return errn;
}
/**
* Decode an arbitrary precision integer using a sign bit followed by a
* sequence of octets. The most significant bit of the last octet is set to
* zero to indicate sequence termination. Only seven bits per octet are used
* to store the integer's value.
*/
int decodeInteger32(bitstream_t* stream, int32_t* int32) {
int b;
uint32_t uint32;
int errn = decodeBoolean(stream, &b);
if (errn < 0) {
return errn;
}
if (b) {
/* For negative values, the Unsigned Integer holds the
* magnitude of the value minus 1 */
errn = decodeUnsignedInteger32(stream, &uint32);
*int32 = -(uint32 + 1);
} else {
/* positive */
errn = decodeUnsignedInteger32(stream, &uint32);
*int32 = (int32_t)(uint32);
}
return errn;
}
/**
* Decode an arbitrary precision integer using a sign bit followed by a
* sequence of octets. The most significant bit of the last octet is set to
* zero to indicate sequence termination. Only seven bits per octet are used
* to store the integer's value.
*/
int decodeInteger64(bitstream_t* stream, int64_t* int64) {
int b;
uint64_t uint64;
int errn = decodeBoolean(stream, &b);
if (errn < 0) {
return errn;
}
if (b) {
/* For negative values, the Unsigned Integer holds the
* magnitude of the value minus 1 */
errn = decodeUnsignedInteger64(stream, &uint64);
*int64 = -(uint64 + 1);
} else {
/* positive */
errn = decodeUnsignedInteger64(stream, &uint64);
*int64 = (int64_t)(uint64);
}
return errn;
}
/**
* Decode a Float datatype as two consecutive Integers.
* The first Integer represents the mantissa of the floating point
* number and the second Integer represents the base-10 exponent
* of the floating point number.
*/
int decodeFloat(bitstream_t* stream, float_me_t* f) {
int errn = decodeInteger64(stream, &f->mantissa);
if (errn < 0) {
return errn;
}
return decodeInteger32(stream, &f->exponent);
}
/**
* Decode a sequence of characters for a given length.
*/
int decodeStringOnly(bitstream_t* stream, uint16_t len, string_ucs_t* s) {
decodeCharacters(stream, len, s->codepoints);
s->len = len;
return 0;
}
/**
* Decode a length prefixed sequence of characters.
*/
int decodeString(bitstream_t* stream, string_ucs_t* s) {
int errn = decodeUnsignedInteger16(stream, &s->len);
if (errn < 0) {
return errn;
}
return decodeStringOnly(stream, s->len, s);
}
int decodeStringValue(bitstream_t* stream, string_ucs_t* s) {
int errn = decodeUnsignedInteger16(stream, &s->len);
if (errn < 0) {
return errn;
}
switch (s->len) {
case 0:
/* local value partition */
printf("[ERROR] String local value partition hit not supported \n");
return -2;
case 1:
/* found in global value partition */
printf("[ERROR] String global value partition hit not supported \n");
return -3;
default:
/* not found in global value (and local value) partition
* ==> string literal is encoded as a String with the length
* incremented by two */
return decodeStringOnly(stream, ((s->len) - 2), s);
/* After encoding the string value, it is added to both the
* associated "local" value string table partition and the global
* value string table partition */
/* addValue(context, value); */
}
}
/**
* Decode a sequence of characters according to a given length.
* Each character is represented by its UCS [ISO/IEC 10646]
* code point encoded as an Unsigned Integer
*/
int decodeCharacters(bitstream_t* stream, uint16_t len, uint32_t* chars) {
unsigned int i;
int errn = 0;
for (i = 0; i < len && errn >= 0; i++) {
errn = decodeUnsignedInteger32(stream, &chars[i]);
if (errn < 0) {
return errn;
}
}
return errn;
}
/**
* Decode a binary value as a length-prefixed sequence of octets.
*/
int decodeBinary(bitstream_t* stream, bytes_t* bytes) {
unsigned int i;
uint32_t b;
int errn = decodeUnsignedInteger16(stream, &bytes->len);
if (errn < 0) {
return errn;
}
for (i = 0; i < bytes->len && errn >= 0; i++) {
errn = _decode(stream, &b);
if (errn < 0) {
return errn;
}
bytes->data[i] = (uint8_t)b;
}
return errn;
}
#endif

View file

@ -0,0 +1,131 @@
/*
* 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 <http://www.gnu.org/licenses/>.
*/
/*******************************************************************
*
* @author Daniel.Peintner.EXT@siemens.com
* @version 0.3.1
* @contact Joerg.Heuer@siemens.com
*
********************************************************************/
#ifdef __cplusplus
extern "C" {
#endif
#include "EXITypes.h"
#ifndef BIT_DECODER_CHANNEL_H
#define BIT_DECODER_CHANNEL_H
/**
* Decode a single boolean value. The value false is represented by the bit
* 0, and the value true is represented by the bit 1.
*/
int decodeBoolean(bitstream_t* stream, int* b);
/**
* Decodes and returns an n-bit unsigned integer.
*/
int decodeNBitUnsignedInteger(bitstream_t* stream, uint16_t nbits, uint32_t* uint32);
/**
* Decode an arbitrary precision non negative integer using a sequence of
* octets. The most significant bit of the last octet is set to zero to
* indicate sequence termination. Only seven bits per octet are used to
* store the integer's value.
*/
int decodeUnsignedInteger16(bitstream_t* stream, uint16_t* uint16);
/**
* Decode an arbitrary precision non negative integer using a sequence of
* octets. The most significant bit of the last octet is set to zero to
* indicate sequence termination. Only seven bits per octet are used to
* store the integer's value.
*/
int decodeUnsignedInteger32(bitstream_t* stream, uint32_t* uint32);
/**
* Decode an arbitrary precision non negative integer using a sequence of
* octets. The most significant bit of the last octet is set to zero to
* indicate sequence termination. Only seven bits per octet are used to
* store the integer's value.
*/
int decodeUnsignedInteger64(bitstream_t* stream, uint64_t* uint64);
/**
* Decode an arbitrary precision integer using a sign bit followed by a
* sequence of octets. The most significant bit of the last octet is set to
* zero to indicate sequence termination. Only seven bits per octet are used
* to store the integer's value.
*/
int decodeInteger32(bitstream_t* stream, int32_t* int32);
/**
* Decode an arbitrary precision integer using a sign bit followed by a
* sequence of octets. The most significant bit of the last octet is set to
* zero to indicate sequence termination. Only seven bits per octet are used
* to store the integer's value.
*/
int decodeInteger64(bitstream_t* stream, int64_t* int64);
/**
* Decode a Float datatype as two consecutive Integers.
* The first Integer represents the mantissa of the floating point
* number and the second Integer represents the base-10 exponent
* of the floating point number.
*/
int decodeFloat(bitstream_t* stream, float_me_t* f);
/**
* Decode a sequence of characters for a given length.
*/
int decodeStringOnly(bitstream_t* stream, uint16_t len, string_ucs_t* s);
/**
* Decode a length prefixed sequence of characters.
*/
int decodeString(bitstream_t* stream, string_ucs_t* s);
/**
* Decode a length prefixed sequence of characters in the sense of string tables.
* length == 0, local value partition hit
* length == 1, global value partition hit
* --> string literal is encoded as a String with the length incremented by two
*/
int decodeStringValue(bitstream_t* stream, string_ucs_t* s);
/**
* Decode a sequence of characters according to a given length.
*/
int decodeCharacters(bitstream_t* stream, uint16_t len, uint32_t* chars);
/**
* Decode a binary value as a length-prefixed sequence of octets.
*/
int decodeBinary(bitstream_t* stream, bytes_t* bytes);
#endif
#ifdef __cplusplus
}
#endif

View file

@ -0,0 +1,298 @@
/*
* 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 <http://www.gnu.org/licenses/>.
*/
/*******************************************************************
*
* @author Daniel.Peintner.EXT@siemens.com
* @version 0.3.1
* @contact Joerg.Heuer@siemens.com
*
********************************************************************/
#include <stdio.h>
#include <string.h>
#include <stdint.h>
#include "BitEncoderChannel.h"
#include "BitOutputStream.h"
#include "EXITypes.h"
#ifndef BIT_ENCODER_CHANNEL_C
#define BIT_ENCODER_CHANNEL_C
/**
* Returns the least number of 7 bit-blocks that is needed to represent the
* int <param>n</param>. Returns 1 if <param>n</param> is 0.
*
* @param n
* integer value
*
*/
uint8_t numberOf7BitBlocksToRepresent(int n) {
/* assert (n >= 0); */
/* 7 bits */
if (n < 128) {
return 1;
}
/* 14 bits */
else if (n < 16384) {
return 2;
}
/* 21 bits */
else if (n < 2097152) {
return 3;
}
/* 28 bits */
else if (n < 268435456) {
return 4;
}
/* 35 bits */
else {
/* int, 32 bits */
return 5;
}
}
int encode(bitstream_t* stream, uint8_t b) {
return writeBits(stream, 8, b);
}
/**
* Encode a single boolean value. A false value is encoded as bit 0 and true
* value is encode as bit 1.
*/
int encodeBoolean(bitstream_t* stream, int b) {
uint8_t val = b ? 1 : 0;
return writeBits(stream, 1, val);
}
/**
* 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, uint16_t nbits, uint32_t val) {
return writeBits(stream, nbits, val);
}
/**
* Encode an arbitrary precision non negative integer using a sequence of
* octets. The most significant bit of the last octet is set to zero to
* indicate sequence termination. Only seven bits per octet are used to
* store the integer's value.
*/
int encodeUnsignedInteger32(bitstream_t* stream, uint32_t n) {
int errn = 0;
if (n < 128) {
/* write byte as is */
errn = encode(stream, (uint8_t)n);
} else {
uint8_t n7BitBlocks = numberOf7BitBlocksToRepresent(n);
switch (n7BitBlocks) {
case 5:
errn = encode(stream, (uint8_t)(128 | n));
n = n >> 7;
if (errn < 0) {
break;
}
case 4:
errn = encode(stream, (uint8_t)(128 | n));
n = n >> 7;
if (errn < 0) {
break;
}
case 3:
errn = encode(stream, (uint8_t)(128 | n));
n = n >> 7;
if (errn < 0) {
break;
}
case 2:
errn = encode(stream, (uint8_t)(128 | n));
n = n >> 7;
if (errn < 0) {
break;
}
case 1:
/* 0 .. 7 (last byte) */
errn = encode(stream, (uint8_t)(0 | n));
}
}
return errn;
}
/**
* Encode an arbitrary precision non negative integer using a sequence of
* octets. The most significant bit of the last octet is set to zero to
* indicate sequence termination. Only seven bits per octet are used to
* store the integer's value.
*/
int encodeUnsignedInteger64(bitstream_t* stream, uint64_t n) {
int errn = 0;
uint8_t lastEncode = (uint8_t) n;
n >>= 7;
while (n != 0) {
errn = encode(stream, lastEncode | 128);
if (errn < 0) {
return errn;
}
lastEncode = (uint8_t) n;
n >>= 7;
}
return encode(stream, lastEncode);
}
/**
* Encode an arbitrary precision integer using a sign bit followed by a
* sequence of octets. The most significant bit of the last octet is set to
* zero to indicate sequence termination. Only seven bits per octet are used
* to store the integer's value.
*/
int encodeInteger32(bitstream_t* stream, int32_t n) {
int errn;
/* signalize sign */
if (n < 0) {
errn = encodeBoolean(stream, 1);
/* For negative values, the Unsigned Integer holds the
* magnitude of the value minus 1 */
n = (-n) - 1;
} else {
errn = encodeBoolean(stream, 0);
}
if (errn < 0) {
return errn;
}
return encodeUnsignedInteger32(stream, n);
}
/**
* Encode an arbitrary precision integer using a sign bit followed by a
* sequence of octets. The most significant bit of the last octet is set to
* zero to indicate sequence termination. Only seven bits per octet are used
* to store the integer's value.
*/
int encodeInteger64(bitstream_t* stream, int64_t n) {
int errn;
/* signalize sign */
if (n < 0) {
errn = encodeBoolean(stream, 1);
/* For negative values, the Unsigned Integer holds the
* magnitude of the value minus 1 */
n = (-n) - 1;
} else {
errn = encodeBoolean(stream, 0);
}
if (errn < 0) {
return errn;
}
return encodeUnsignedInteger64(stream, n);
}
/**
* The Float datatype representation is two consecutive Integers.
* The first Integer represents the mantissa of the floating point
* number and the second Integer represents the base-10 exponent
* of the floating point number.
*/
int encodeFloat(bitstream_t* stream, float_me_t* f) {
int errn = encodeInteger64(stream, f->mantissa);
if (errn >= 0) {
errn = encodeInteger32(stream, f->exponent);
}
return errn;
}
/**
* Encode a length prefixed sequence of characters.
*/
int encodeString(bitstream_t* stream, string_ucs_t* string) {
int errn = encodeUnsignedInteger32(stream, string->len);
if (errn >= 0) {
errn = encodeCharacters(stream, string->codepoints, string->len);
}
return errn;
}
int encodeStringValue(bitstream_t* stream, string_ucs_t* string) {
/* encode string as string table miss */
int errn = encodeUnsignedInteger32(stream, string->len+2);
if (errn >= 0) {
errn = encodeCharacters(stream, string->codepoints, string->len);
}
return errn;
}
/**
* Encode a sequence of characters according to a given length.
* Each character is represented by its UCS [ISO/IEC 10646]
* code point encoded as an Unsigned Integer
*/
int encodeCharacters(bitstream_t* stream, uint32_t* chars, uint16_t len) {
unsigned int i;
int errn = 0;
for(i=0; i<len && errn>=0; i++) {
errn = encodeUnsignedInteger32(stream, chars[i]);
}
return errn;
}
/**
* Encode a binary value as a length-prefixed sequence of octets.
*/
int encodeBinary(bitstream_t* stream, bytes_t* bytes) {
unsigned int i;
int errn = encodeUnsignedInteger32(stream, bytes->len);
for(i=0; i<bytes->len && errn>=0; i++) {
errn = encode(stream, bytes->data[i]);
}
return errn;
}
/**
* Flush underlying bit output stream.
*/
int encodeFinish(bitstream_t* stream) {
return flush(stream);
}
#endif

View file

@ -0,0 +1,133 @@
/*
* 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 <http://www.gnu.org/licenses/>.
*/
/*******************************************************************
*
* @author Daniel.Peintner.EXT@siemens.com
* @version 0.3.1
* @contact Joerg.Heuer@siemens.com
*
********************************************************************/
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include "EXITypes.h"
#ifndef BIT_ENCODER_CHANNEL_H
#define BIT_ENCODER_CHANNEL_H
/**
* Encode a single boolean value. A false value is encoded as bit 0 and true
* value is encode as bit 1.
*/
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, uint16_t nbits, uint32_t val);
/**
* Encode an arbitrary precision non negative integer using a sequence of
* octets. The most significant bit of the last octet is set to zero to
* indicate sequence termination. Only seven bits per octet are used to
* store the integer's value.
*/
int encodeUnsignedInteger32(bitstream_t* stream, uint32_t n);
/**
* Encode an arbitrary precision non negative integer using a sequence of
* octets. The most significant bit of the last octet is set to zero to
* indicate sequence termination. Only seven bits per octet are used to
* store the integer's value.
*/
int encodeUnsignedInteger64(bitstream_t* stream, uint64_t n);
/**
* Encode an arbitrary precision integer using a sign bit followed by a
* sequence of octets. The most significant bit of the last octet is set to
* zero to indicate sequence termination. Only seven bits per octet are used
* to store the integer's value.
*/
int encodeInteger32(bitstream_t* stream, int32_t n);
/**
* Encode an arbitrary precision integer using a sign bit followed by a
* sequence of octets. The most significant bit of the last octet is set to
* zero to indicate sequence termination. Only seven bits per octet are used
* to store the integer's value.
*/
int encodeInteger64(bitstream_t* stream, int64_t n);
/**
* Encode a Float datatype as two consecutive Integers.
* The first Integer represents the mantissa of the floating point
* number and the second Integer represents the base-10 exponent
* of the floating point number.
*/
int encodeFloat(bitstream_t* stream, float_me_t* f);
/**
* Encode a length prefixed sequence of characters.
*/
int encodeString(bitstream_t* stream, string_ucs_t* string);
/**
* Encode a length prefixed sequence of characters in the sense of string tables
*/
int encodeStringValue(bitstream_t* stream, string_ucs_t* string);
/**
* Encode a sequence of characters according to a given length.
* Each character is represented by its UCS [ISO/IEC 10646]
* code point encoded as an Unsigned Integer
*/
int encodeCharacters(bitstream_t* stream, uint32_t* chars, uint16_t len);
/**
* Encode a binary value as a length-prefixed sequence of octets.
*/
int encodeBinary(bitstream_t* stream, bytes_t* bytes);
/**
* Flush underlying bit output stream
*/
int encodeFinish(bitstream_t* stream);
#endif
#ifdef __cplusplus
}
#endif

View file

@ -0,0 +1,100 @@
/*
* 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 <http://www.gnu.org/licenses/>.
*/
/*******************************************************************
*
* @author Daniel.Peintner.EXT@siemens.com
* @version 0.3.1
* @contact Joerg.Heuer@siemens.com
*
********************************************************************/
#include <stdio.h>
#include <string.h>
#include <stdint.h>
#include "EXITypes.h"
#include "BitInputStream.h"
#ifndef BIT_INPUT_STREAM_C
#define BIT_INPUT_STREAM_C
/* internal method to (re)fill buffer */
int readBuffer(bitstream_t* stream)
{
int errn = 0;
if(stream->capacity==0)
{
if ( (*stream->pos) < stream->size ) {
stream->buffer = stream->data[(*stream->pos)++];
stream->capacity = BITS_IN_BYTE;
} else {
errn = -1;
}
}
return errn;
}
int readBits(bitstream_t* stream, uint16_t num_bits, uint32_t* b)
{
int errn = readBuffer(stream);
if (errn < 0) {
return errn;
}
/* read the bits in one step */
if(num_bits <= stream->capacity)
{
stream->capacity -= num_bits;
*b = (stream->buffer >> stream->capacity) & (0xff >> (BITS_IN_BYTE - num_bits));
}
else
{
/* read bits as much as possible */
*b = stream->buffer & (0xff >> (BITS_IN_BYTE - stream->capacity));
num_bits -= stream->capacity;
stream->capacity = 0;
/* read whole bytes */
while(num_bits >= 8)
{
errn = readBuffer(stream);
if (errn < 0) {
return errn;
}
*b = ((*b) << BITS_IN_BYTE) | stream->buffer;
num_bits -= BITS_IN_BYTE;
stream->capacity = 0;
}
/* read the spare bits in the buffer */
if(num_bits>0)
{
errn = readBuffer(stream);
if (errn < 0) {
return errn;
}
*b = ((*b) << num_bits) | (stream->buffer >> (BITS_IN_BYTE - num_bits));
stream->capacity = BITS_IN_BYTE - num_bits;
}
}
return errn;
}
#endif

View file

@ -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 <http://www.gnu.org/licenses/>.
*/
/*******************************************************************
*
* @author Daniel.Peintner.EXT@siemens.com
* @version 0.3.1
* @contact Joerg.Heuer@siemens.com
*
********************************************************************/
#ifdef __cplusplus
extern "C" {
#endif
#include "EXITypes.h"
#ifndef BIT_INPUT_STREAM_H
#define BIT_INPUT_STREAM_H
int readBits(bitstream_t* stream, uint16_t num_bits, uint32_t* b);
int flush();
#endif
#ifdef __cplusplus
}
#endif

View file

@ -0,0 +1,95 @@
/*
* 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 <http://www.gnu.org/licenses/>.
*/
/*******************************************************************
*
* @author Daniel.Peintner.EXT@siemens.com
* @version 0.3.1
* @contact Joerg.Heuer@siemens.com
*
********************************************************************/
#include <string.h>
#include "EXITypes.h"
#include "BitOutputStream.h"
#ifndef BIT_OUTPUT_STREAM_C
#define BIT_OUTPUT_STREAM_C
/* NOTE: nbits <= 8 */
int writeBits(bitstream_t* stream, uint16_t nbits, uint32_t val) {
/* is there enough space in the buffer */
if (nbits <= stream->capacity) {
/* all bits fit into the current buffer */
stream->buffer = (stream->buffer << (nbits)) | (val & (0xff
>> (BITS_IN_BYTE - nbits)));
stream->capacity -= nbits;
/* if the buffer is full write it into the data */
if (stream->capacity == 0) {
if ((*stream->pos) >= stream->size) {
return -1;
}
stream->data[(*stream->pos)++] = 0xFF & stream->buffer;
stream->capacity = BITS_IN_BYTE;
stream->buffer = 0;
}
} else {
/* the buffer is not enough
* fill the buffer */
stream->buffer = (stream->buffer << stream->capacity) | ((val >> (nbits
- stream->capacity)) & (0xff >> (BITS_IN_BYTE
- stream->capacity)));
nbits -= stream->capacity;
if ((*stream->pos) >= stream->size) {
return -1;
}
stream->data[(*stream->pos)++] = 0xFF & stream->buffer;
stream->buffer = 0;
/* write whole bytes */
while (nbits >= BITS_IN_BYTE) {
nbits -= BITS_IN_BYTE;
if ((*stream->pos) >= stream->size) {
return -1;
}
stream->data[(*stream->pos)++] = 0xFF & (val >> (nbits));
}
/* spared bits are kept in the buffer */
stream->buffer = val; /* Note: the high bits will be shifted out during further filling */
stream->capacity = BITS_IN_BYTE - (nbits);
}
return 0;
}
/**
* Flush output
*/
int flush(bitstream_t* stream) {
if (stream->capacity == BITS_IN_BYTE) {
/* nothing to do, no bits in buffer */
return 0;
} else {
return writeBits(stream, stream->capacity, 0);
}
}
#endif

View file

@ -0,0 +1,48 @@
/*
* 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 <http://www.gnu.org/licenses/>.
*/
/*******************************************************************
*
* @author Daniel.Peintner.EXT@siemens.com
* @version 0.3.1
* @contact Joerg.Heuer@siemens.com
*
********************************************************************/
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include "EXITypes.h"
#ifndef BIT_OUTPUT_STREAM_H
#define BIT_OUTPUT_STREAM_H
int writeBits(bitstream_t* stream, uint16_t nbits, uint32_t bits);
/* flush output */
int flush(bitstream_t* stream);
#endif
#ifdef __cplusplus
}
#endif

View file

@ -0,0 +1,83 @@
/*
* 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 <http://www.gnu.org/licenses/>.
*/
/*******************************************************************
*
* @author Daniel.Peintner.EXT@siemens.com
* @version 0.3.1
* @contact Joerg.Heuer@siemens.com
*
********************************************************************/
#define _CRT_SECURE_NO_DEPRECATE 1
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <stdint.h>
#include <stdio.h>
#include "EXITypes.h"
#ifndef BYTE_STREAM_C
#define BYTE_STREAM_C
int readBytesFromFile(const char * filename, uint8_t* data, uint16_t size, uint16_t pos) {
FILE* f;
int character;
f = fopen(filename, "rb");
if (f == NULL) {
printf("\n[Error] no valid file handle !\n");
return -1;
} else {
/* read bytes */
while ((character = getc(f)) != EOF) {
if (pos >= size) {
return -1;
}
data[pos++] = (uint8_t) character;
/* printf("%u \n", character); */
}
fclose(f);
}
return pos;
}
int writeBytesToFile(uint8_t* data, uint16_t len, const char * filename) {
uint16_t rlen;
FILE* f = fopen(filename, "wb+");
if (f == NULL) {
return -1;
} else {
rlen = fwrite(data, sizeof(uint8_t), len, f);
fflush(f);
fclose(f);
if(rlen == len) {
return 0;
} else {
return -1;
}
}
}
#endif

View file

@ -0,0 +1,46 @@
/*
* 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 <http://www.gnu.org/licenses/>.
*/
/*******************************************************************
*
* @author Daniel.Peintner.EXT@siemens.com
* @version 0.3.1
* @contact Joerg.Heuer@siemens.com
*
********************************************************************/
#ifdef __cplusplus
extern "C" {
#endif
#include <stdio.h>
#include "EXITypes.h"
#ifndef BYTE_STREAM_H
#define BYTE_STREAM_H
int writeBytesToFile(uint8_t* data, uint16_t len, const char * filename);
int readBytesFromFile(const char * filename, uint8_t* data, uint16_t size, uint16_t pos);
#endif
#ifdef __cplusplus
}
#endif

View file

@ -0,0 +1,70 @@
/*
* 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 <http://www.gnu.org/licenses/>.
*/
/*******************************************************************
*
* @author Daniel.Peintner.EXT@siemens.com
* @version 0.3.1
* @contact Joerg.Heuer@siemens.com
*
********************************************************************/
#ifndef EXI_CODER_C
#define EXI_CODER_C
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <stdlib.h>
#include "EXITypes.h"
#include "BitInputStream.h"
#include "BitDecoderChannel.h"
#include "assert.h"
#include "EXICoder.h"
/*
uint16_t exiGetCurrentState(struct exiState* state) {
return state->grammarStates[state->currentStack];
// return 0;
}
*/
int exiPushStack(exi_state_t* state, uint16_t newState, eqname_t* eqn) {
if ((state->stackIndex + 1) < EXI_ELEMENT_STACK_SIZE) {
state->grammarStack[++state->stackIndex] = newState;
/* copy qname */
state->elementStack[state->stackIndex].localPart = eqn->localPart;
state->elementStack[state->stackIndex].namespaceURI = eqn->namespaceURI;
return 0;
} else {
return EXI_ERROR_OUT_OF_BOUNDS;
}
}
int exiPopStack(exi_state_t* state) {
if (state->stackIndex >= 1) {
state->stackIndex--;
return 0;
} else {
return EXI_ERROR_OUT_OF_BOUNDS;
}
}
#endif

View file

@ -0,0 +1,51 @@
/*
* 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 <http://www.gnu.org/licenses/>.
*/
/*******************************************************************
*
* @author Daniel.Peintner.EXT@siemens.com
* @version 0.3.1
* @contact Joerg.Heuer@siemens.com
*
********************************************************************/
#ifdef __cplusplus
extern "C" {
#endif
#ifndef EXI_CODER_H
#define EXI_CODER_H
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include "EXITypes.h"
/* uint16_t exiGetCurrentState(struct exiState* state); */
int exiPushStack(exi_state_t* state, uint16_t newState, eqname_t* eqn);
int exiPopStack(exi_state_t* state);
#endif
#ifdef __cplusplus
}
#endif

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,64 @@
/*
* 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 <http://www.gnu.org/licenses/>.
*/
/*******************************************************************
*
* @author Daniel.Peintner.EXT@siemens.com
* @version 0.3.1
* @contact Joerg.Heuer@siemens.com
*
********************************************************************/
#ifdef __cplusplus
extern "C" {
#endif
#ifndef EXI_DECODER_H
#define EXI_DECODER_H
#include "EXITypes.h"
int exiInitDecoder(bitstream_t* stream, exi_state_t* state);
int exiDecodeNextEvent(bitstream_t* stream, exi_state_t* state,
exi_event_t* nextEvent);
int exiDecodeStartDocument(bitstream_t* stream, exi_state_t* state);
int exiDecodeEndDocument(bitstream_t* stream, exi_state_t* state);
int exiDecodeStartElement(bitstream_t* stream, exi_state_t* state,
eqname_t* se);
int exiDecodeStartElementGeneric(bitstream_t* stream, exi_state_t* state,
eqname_t* se);
int exiDecodeEndElement(bitstream_t* stream, exi_state_t* state,
eqname_t* ee);
int exiDecodeCharacters(bitstream_t* stream, exi_state_t* state,
exi_value_t* val);
int exiDecodeAttribute(bitstream_t* stream, exi_state_t* state,
eqname_t* at, exi_value_t* val);
#endif
#ifdef __cplusplus
}
#endif

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,61 @@
/*
* 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 <http://www.gnu.org/licenses/>.
*/
/*******************************************************************
*
* @author Daniel.Peintner.EXT@siemens.com
* @version 0.3.1
* @contact Joerg.Heuer@siemens.com
*
********************************************************************/
#ifdef __cplusplus
extern "C" {
#endif
#ifndef EXI_ENCODER_H
#define EXI_ENCODER_H
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include "EXITypes.h"
int exiInitEncoder(bitstream_t* stream, exi_state_t* state);
int exiEncodeStartDocument(bitstream_t* stream, exi_state_t* state);
int exiEncodeEndDocument(bitstream_t* stream, exi_state_t* state);
int exiEncodeStartElement(bitstream_t* stream, exi_state_t* state,
eqname_t* se);
int exiEncodeEndElement(bitstream_t* stream, exi_state_t* state, eqname_t* ee);
int exiEncodeCharacters(bitstream_t* stream, exi_state_t* state,
exi_value_t* val);
int exiEncodeAttribute(bitstream_t* stream, exi_state_t* state, eqname_t* at,
exi_value_t* val);
#endif
#ifdef __cplusplus
}
#endif

View file

@ -0,0 +1,58 @@
/*
* 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 <http://www.gnu.org/licenses/>.
*/
/*******************************************************************
*
* @author Daniel.Peintner.EXT@siemens.com
* @version 0.3.1
* @contact Joerg.Heuer@siemens.com
*
********************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include "EXIHeaderDecoder.h"
#include "BitInputStream.h"
#include "BitDecoderChannel.h"
#ifndef EXI_HEADER_DECODER_C
#define EXI_HEADER_DECODER_C
int readEXIHeader(bitstream_t* stream) {
uint32_t header = 0;
int errn = readBits(stream, 8, &header);
if (errn < 0) {
return errn;
}
if(header == '$') {
/* we do not support "EXI Cookie" */
errn = -1;
} else if ( header & 0x20 ) {
/* we do not support "Presence Bit for EXI Options" */
errn = -2;
} else {
/* Yes, a *simple* header */
errn = 0;
}
return errn;
}
#endif

View file

@ -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 <http://www.gnu.org/licenses/>.
*/
/*******************************************************************
*
* @author Daniel.Peintner.EXT@siemens.com
* @version 0.3.1
* @contact Joerg.Heuer@siemens.com
*
********************************************************************/
#ifdef __cplusplus
extern "C" {
#endif
#include <stdio.h>
#include "EXITypes.h"
#ifndef EXI_HEADER_DECODER_H
#define EXI_HEADER_DECODER_H
int readEXIHeader(bitstream_t* stream);
#endif
#ifdef __cplusplus
}
#endif

View file

@ -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 <http://www.gnu.org/licenses/>.
*/
/*******************************************************************
*
* @author Daniel.Peintner.EXT@siemens.com
* @version 0.3.1
* @contact Joerg.Heuer@siemens.com
*
********************************************************************/
#include <stdio.h>
#include <stdlib.h>
#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

View file

@ -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 <http://www.gnu.org/licenses/>.
*/
/*******************************************************************
*
* @author Daniel.Peintner.EXT@siemens.com
* @version 0.3.1
* @contact Joerg.Heuer@siemens.com
*
********************************************************************/
#ifdef __cplusplus
extern "C" {
#endif
#include <stdio.h>
#include "EXITypes.h"
#ifndef EXI_HEADER_ENCODER_H
#define EXI_HEADER_ENCODER_H
int writeEXIHeader(bitstream_t* stream);
#endif
#ifdef __cplusplus
}
#endif

View file

@ -0,0 +1,187 @@
/*
* 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 <http://www.gnu.org/licenses/>.
*/
/*******************************************************************
*
* @author Daniel.Peintner.EXT@siemens.com
* @version 0.3.1
* @contact Joerg.Heuer@siemens.com
*
********************************************************************/
#ifdef __cplusplus
extern "C" {
#endif
#include <string.h>
#include <stdint.h>
#ifndef EXI_TYPES_H
#define EXI_TYPES_H
#define BITS_IN_BYTE 8
#define UINT_MAX_VALUE 65535
#define EXI_ELEMENT_STACK_SIZE 16
/* EXI automaton methods prefixes such as "inline" etc. */
#ifndef EXI_MPFX
#define EXI_MPFX
#endif
#define FLOAT_EXPONENT_SPECIAL_VALUES -16384
#define FLOAT_MANTISSA_INFINITY 1
#define FLOAT_MANTISSA_MINUS_INFINITY -1
#define FLOAT_MANTISSA_NOT_A_NUMBER 0
typedef struct {
/* Integer Array */
uint16_t size; /* array size */
uint8_t* data; /* int data array */
uint16_t* pos; /* next position in array */
/* Current byte buffer & its remaining bit capacity */
uint8_t buffer;
uint16_t capacity;
} bitstream_t;
typedef struct {
/* Bytes Size and array container */
uint16_t size;
uint8_t* data;
/* current length (len <= size) */
uint16_t len;
} bytes_t;
/* Universal Character Set (UCS) strings */
typedef struct {
/* UCS size and UCS character container*/
uint16_t size;
uint32_t* codepoints;
/* current length == number of code-points, (len <= size) */
uint16_t len;
} string_ucs_t;
typedef struct {
/* range of the mantissa is -(2^63) to 2^63-1 */
int64_t mantissa;
/* range of the exponent is - (2^14-1) to 2^14-1 */
int32_t exponent; /* base-10 */
} float_me_t;
typedef enum
{
/* Binary */
BINARY_BASE64, BINARY_HEX,
/* Boolean */
BOOLEAN,
/* Decimal */
DECIMAL,
/* Float */
FLOAT, DOUBLE,
/* N-Bit Integer */
NBIT_INTEGER_32, NBIT_INTEGER_64, NBIT_INTEGER_BIG,
/* Unsigned Integer */
UNSIGNED_INTEGER_16, UNSIGNED_INTEGER_32, UNSIGNED_INTEGER_64, UNSIGNED_INTEGER_BIG,
/* (Signed) Integer */
INTEGER_16, INTEGER_32, INTEGER_64, INTEGER_BIG,
/* Datetime */
DATETIME,
/* String */
STRING,
/* Enumeration */
ENUMERATION,
/* List */
LIST
} exi_datatype_t;
typedef enum
{
START_DOCUMENT,
END_DOCUMENT,
START_ELEMENT,
START_ELEMENT_GENERIC, /* not supported yet */
END_ELEMENT,
CHARACTERS,
CHARACTERS_GENERIC, /* not supported yet */
ATTRIBUTE,
ATTRIBUTE_GENERIC, /* not supported yet */
/* error state */
ERROR
} exi_event_t;
/* TODO list support */
typedef struct {
/* List container with memory size */
uint16_t size;
uint8_t* data;
/* list item type */
exi_datatype_t type;
/* number of items */
uint16_t len;
} list_t;
typedef struct {
uint16_t namespaceURI;
uint16_t localPart;
} eqname_t;
typedef struct {
/* stack of grammar states and elements */
uint16_t grammarStack [EXI_ELEMENT_STACK_SIZE];
eqname_t elementStack [EXI_ELEMENT_STACK_SIZE];
uint16_t stackIndex;
/* event-code */
uint32_t eventCode;
} exi_state_t;
typedef struct {
/* type of value */
exi_datatype_t type;
/* base types */
int boolean;
uint32_t uint32;
uint64_t uint64;
int32_t int32;
int64_t int64;
uint32_t enumeration;
/* Bytes, Strings and Lists are not native types anymore */
bytes_t binary;
string_ucs_t string;
float_me_t float_me;
list_t list;
} exi_value_t;
/*
* ERROR-Codes
*/
# define EXI_ERROR_OUT_OF_BOUNDS -100
# define EXI_ERROR_UNKOWN_EVENT_CODE -110
#endif
#ifdef __cplusplus
}
#endif

View file

@ -0,0 +1,109 @@
/*
* 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 <http://www.gnu.org/licenses/>.
*/
/*******************************************************************
*
* @author Daniel.Peintner.EXT@siemens.com
* @version 0.3.1
* @contact Joerg.Heuer@siemens.com
*
********************************************************************/
#ifndef STRING_TABLE_C
#define STRING_TABLE_C
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <stdlib.h>
#include "StringTable.h"
#include "StringTableEntries.h"
#include "assert.h"
int exiGetUri(uint16_t uriID, const char** uri) {
if ( uriID < stringTable.len ) {
*uri = stringTable.uris[uriID];
} else {
return EXI_ERROR_OUT_OF_BOUNDS;
}
return 0;
}
int exiGetUriLength(uint16_t* uriLength) {
*uriLength = stringTable.len;
return 0;
}
int exiGetUriID(const char* uri, uint16_t* uriID) {
unsigned int i;
for(i=0; i<stringTable.len; i++) {
if ( strcmp ( uri, stringTable.uris[i] ) == 0 ) {
*uriID = i;
return 0;
}
}
return -1;
}
int exiGetLocalName(uint16_t uriID, uint16_t localNameID, const char** localName) {
if ( uriID < stringTable.len ) {
if ( localNameID < stringTable.localNames[uriID].len ) {
*localName = stringTable.localNames[uriID].entries[localNameID];
} else {
return EXI_ERROR_OUT_OF_BOUNDS;
}
} else {
return EXI_ERROR_OUT_OF_BOUNDS;
}
return 0;
}
int exiGetLocalNameLength(uint16_t uriID, uint16_t* localNameLength) {
if ( uriID < stringTable.len ) {
*localNameLength = stringTable.localNames[uriID].len;
} else {
return EXI_ERROR_OUT_OF_BOUNDS;
}
return 0;
}
int exiGetLocalNameID(uint16_t uriID, const char* localName, uint16_t* localNameID) {
unsigned int i;
if ( uriID < stringTable.len ) {
/* TODO binary search */
for(i=0; i<stringTable.localNames[uriID].len; i++) {
if ( strcmp ( localName, stringTable.localNames[uriID].entries[i] ) == 0 ) {
*localNameID = i;
return 0;
}
}
} else {
return EXI_ERROR_OUT_OF_BOUNDS;
}
return -1;
}
#endif

View file

@ -0,0 +1,53 @@
/*
* 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 <http://www.gnu.org/licenses/>.
*/
/*******************************************************************
*
* @author Daniel.Peintner.EXT@siemens.com
* @version 0.3.1
* @contact Joerg.Heuer@siemens.com
*
********************************************************************/
#ifdef __cplusplus
extern "C" {
#endif
#ifndef STRING_TABLE_H
#define STRING_TABLE_H
#include "EXITypes.h"
int exiGetUri(uint16_t uriID, const char** uri);
int exiGetUriLength(uint16_t* uriLength);
int exiGetUriID(const char* uri, uint16_t* uriID);
int exiGetLocalName(uint16_t uriID, uint16_t localNameID, const char** localName);
int exiGetLocalNameLength(uint16_t uriID, uint16_t* localNameLength);
int exiGetLocalNameID(uint16_t uriID, const char* localName, uint16_t* localNameID);
#endif
#ifdef __cplusplus
}
#endif

View file

@ -0,0 +1,126 @@
/*
* 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 <http://www.gnu.org/licenses/>.
*/
/*******************************************************************
*
* @author Daniel.Peintner.EXT@siemens.com
* @version 0.3.1
* @contact Joerg.Heuer@siemens.com
*
********************************************************************/
#ifndef STRING_TABLE_ENTRIES_C
#define STRING_TABLE_ENTRIES_C
#include "StringTableEntries.h"
/* ==================================== */
/* String Table Population */
/* localName entries for URI id = 0 */
const char * localNames0[] = {
NULL
};
/* localName entries for URI id = 1 */
const char * localNames1[] = {
"base", "id", "lang", "space"
};
/* localName entries for URI id = 2 */
const char * localNames2[] = {
"nil", "type"
};
/* localName entries for URI id = 3 */
const char * localNames3[] = {
"ENTITIES", "ENTITY", "ID", "IDREF", "IDREFS",
"NCName", "NMTOKEN", "NMTOKENS", "NOTATION", "Name",
"QName", "anySimpleType", "anyType", "anyURI", "base64Binary",
"boolean", "byte", "date", "dateTime", "decimal",
"double", "duration", "float", "gDay", "gMonth",
"gMonthDay", "gYear", "gYearMonth", "hexBinary", "int",
"integer", "language", "long", "negativeInteger", "nonNegativeInteger",
"nonPositiveInteger", "normalizedString", "positiveInteger", "short", "string",
"time", "token", "unsignedByte", "unsignedInt", "unsignedLong",
"unsignedShort"
};
/* localName entries for URI id = 4 */
const char * localNames4[] = {
"ContractID", "EAmount", "EVSEID", "EVSEIMax", "EVSEMaxPhases",
"EVSEMaxPower", "EVSEStatus", "EVSEVoltage", "EnergyProvider", "EoC",
"LineLockReq", "LineLockReqType", "LineLockRes", "LineLockResType", "MeterInfo",
"MeteringReceiptReq", "MeteringReceiptReqType", "MeteringReceiptRes", "MeteringReceiptResType", "MeteringStatusReq",
"MeteringStatusReqType", "MeteringStatusRes", "MeteringStatusResType", "PCurrent", "PEVID",
"PEVMaxPhases", "PEVMaxPower", "PEVMaxVoltage", "PEVMinVoltage", "PEVStatus",
"PaymentDetailsReq", "PaymentDetailsReqType", "PaymentDetailsRes", "PaymentDetailsResType", "PowerDeliveryReq",
"PowerDeliveryReqType", "PowerDeliveryRes", "PowerDeliveryResType", "PowerDiscoveryReq", "PowerDiscoveryReqType",
"PowerDiscoveryRes", "PowerDiscoveryResType", "ReqLockStatus", "ReqSwitchStatus", "ResponseCode",
"ServiceDiscoveryReq", "ServiceDiscoveryReqType", "ServiceDiscoveryRes", "ServiceDiscoveryResType", "ServiceList",
"ServicePaymentSelectionReq", "ServicePaymentSelectionReqType", "ServicePaymentSelectionRes", "ServicePaymentSelectionResType", "ServiceScope",
"ServiceType", "SessionSetupReq", "SessionSetupReqType", "SessionSetupRes", "SessionSetupResType",
"TCurrent", "Tariff", "TariffTable"
};
/* localName entries for URI id = 5 */
const char * localNames5[] = {
"ChargerStandby", "ChargingProfileEntryMaxPower", "ChargingProfileEntryStart", "ChargingProfileType", "ConnectorLocked",
"Currency", "EPrice", "EVSEStandby", "EVSEStatusType", "Event",
"EventList", "EventListType", "FatalError", "FaultCode", "FaultMsg",
"FloatingValueType", "MeterID", "MeterInfoType", "MeterReading", "MeterStatus",
"Multiplier", "NotificationType", "PEVStatusType", "PowerSwitchClosed", "ProtocolVersion",
"RCD", "Service", "ServiceDescriptionType", "ServiceID", "ServiceListType",
"ServiceName", "ServiceScope", "ServiceSessionID", "ServiceType", "SessionID",
"SessionInformationType", "ShutDownTime", "TMeter", "Tariff", "TariffDescrType",
"TariffDescription", "TariffEntries", "TariffEntriesType", "TariffEntry", "TariffEntryType",
"TariffID", "TariffPMax", "TariffStart", "TariffTableType", "Unit",
"Value", "contractIDType", "currencyType", "energyProviderType", "eventEntryType",
"evseIDType", "fatalErrorType", "faultCodeType", "lockStatusType", "maxPhasesType",
"meterIDType", "meterStatusType", "paymentOptionListType", "paymentOptionType", "pevIDType",
"protocolVersionType", "pubKeyType", "rcdType", "responseCode_LineLockType", "responseCode_MeteringReceiptType",
"responseCode_MeteringStatusType", "responseCode_PaymentDetailsType", "responseCode_PowerDeliveryType", "responseCode_PowerDiscoveryType", "responseCode_ServiceDiscoveryType",
"responseCode_ServicePaymentSelectionType", "responseCode_SessionSetupType", "serviceDetailsType", "serviceIDType", "serviceNameType",
"serviceScopeType", "serviceTypeType", "sessionIDType", "standbyType", "switchStatusType",
"tariffDescriptionType", "tariffIDType", "tariffStartType", "timeType", "unitMultiplierType",
"unitSymbolType"
};
/* localName entries for URI id = 6 */
const char * localNames6[] = {
"Body", "BodyBaseType", "BodyElement", "BodyType", "Header",
"V2G_Message"
};
/* localName entries for URI id = 7 */
const char * localNames7[] = {
"HeaderType", "Notification", "SessionInformation"
};
struct exiPartition localNamePartitions[8] = {
{ 0, localNames0 },
{ 4, localNames1 },
{ 2, localNames2 },
{ 46, localNames3 },
{ 63, localNames4 },
{ 91, localNames5 },
{ 6, localNames6 },
{ 3, localNames7 }
};
const char * uris[] = {
"", "http://www.w3.org/XML/1998/namespace", "http://www.w3.org/2001/XMLSchema-instance", "http://www.w3.org/2001/XMLSchema", "urn:iso:15118:2:2010:eval1.0:MsgBody", "urn:iso:15118:2:2010:eval1.0:MsgDataTypes", "urn:iso:15118:2:2010:eval1.0:MsgDef", "urn:iso:15118:2:2010:eval1.0:MsgHeader"
};
struct exiStringTable stringTable = { 8, uris, localNamePartitions };
#endif

View file

@ -0,0 +1,60 @@
/*
* 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 <http://www.gnu.org/licenses/>.
*/
/*******************************************************************
*
* @author Daniel.Peintner.EXT@siemens.com
* @version 0.3.1
* @contact Joerg.Heuer@siemens.com
*
********************************************************************/
#ifndef STRING_TABLE_ENTRIES_H
#define STRING_TABLE_ENTRIES_H
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <stdlib.h>
/* ==================================== */
/* String Table Structures */
struct exiPartition {
/* length of array */
uint16_t len;
/* array of string entries */
const char** entries;
};
struct exiStringTable {
/* length of both arrays (uris & localNames) */
uint16_t len;
/* URI entries*/
const char** uris;
/* localName entries divided by URI */
struct exiPartition * localNames;
};
/* ==================================== */
/* String Table Population */
extern struct exiStringTable stringTable;
#endif

View file

@ -0,0 +1,64 @@
/*
* 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 <http://www.gnu.org/licenses/>.
*/
/*******************************************************************
*
* @author Daniel.Peintner.EXT@siemens.com
* @version 0.3.1
* @contact Joerg.Heuer@siemens.com
*
********************************************************************/
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <stdint.h>
#include "BitDecoderChannel.h"
#include "BitInputStream.h"
#include "EXITypes.h"
#ifndef UCS_STRING_C
#define UCS_STRING_C
int toUCSString(char* chars, string_ucs_t* s) {
unsigned int i;
s->len = strlen(chars);
if (s->len <= s->size) {
for(i=0; i<s->len; i++) {
s->codepoints[i] = chars[i];
}
return 0;
} else {
return -1;
}
}
/* Note: fails if string contains non ASCII characters */
int toASCIIString(string_ucs_t* string, char* outASCII) {
unsigned int i;
for(i=0; i<string->len; i++) {
outASCII[i] = (char)string->codepoints[i];
}
outASCII[string->len] = '\0';
return 0;
}
#endif

View file

@ -0,0 +1,48 @@
/*
* 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 <http://www.gnu.org/licenses/>.
*/
/*******************************************************************
*
* @author Daniel.Peintner.EXT@siemens.com
* @version 0.3.1
* @contact Joerg.Heuer@siemens.com
*
********************************************************************/
#ifdef __cplusplus
extern "C" {
#endif
#include "EXITypes.h"
/* TODO utf8/cstring//wchar_t/char16_t/char32_t methods */
#ifndef UCS_STRING_H
#define UCS_STRING_H
int toUCSString(char* chars, string_ucs_t* s);
/* Note: fails if string contains non ASCII characters */
int toASCIIString(string_ucs_t* string, char* outASCII);
#endif
#ifdef __cplusplus
}
#endif

View file

@ -0,0 +1,79 @@
/*
* 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 <http://www.gnu.org/licenses/>.
*/
/*******************************************************************
*
* @author Sebastian.Kaebisch.EXT@siemens.com
* @version 0.3.1
* @contact Joerg.Heuer@siemens.com
*
********************************************************************/
#ifdef __cplusplus
extern "C" {
#endif
#ifndef EXI_SERVICE_H_
#define EXI_SERVICE_H_
#include "v2g_serviceDataTypes.h"
#include "EXITypes.h"
struct uniqueIDPath
{
int id[10];
size_t pos;
};
struct EXIService
{
/* in-/ out-stream */
bitstream_t inStream;
bitstream_t outStream;
/* EXI */
exi_state_t stateDecode;
exi_state_t stateEncode;
exi_event_t event;
eqname_t eqn;
exi_value_t val;
/* v2g message data structure */
struct EXIDocumentType exiMsg;
/* unique id for ambiguous elements */
struct uniqueIDPath idPath;
/* error code */
uint8_t errorCode;
/* offset for transport header data */
uint16_t transportHeaderOffset;
};
/* define error codes (TODO: define precise error codes) */
#define EXI_NON_VALID_MESSAGE 0x01
#define EXI_SERIALIZATION_FAILED 0x02
#define EXI_UNKNOWN_ERROR 0xFF
#endif /* EXI_SERVICE_H_ */
#ifdef __cplusplus
}
#endif

View file

@ -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 <http://www.gnu.org/licenses/>.
*/
/*******************************************************************
*
* @author Sebastian.Kaebisch.EXT@siemens.com
* @version 0.3.1
* @contact Joerg.Heuer@siemens.com
*
********************************************************************/
#ifdef __cplusplus
extern "C" {
#endif
#ifndef V2G_SERVICECLIENTDATATRANSMITTER_H_
#define V2G_SERVICECLIENTDATATRANSMITTER_H_
#include "EXITypes.h"
/* This method has to be implemented!
* This method sends EXI stream (outStream) to the EVSE and receives response stream (inStream)*/
int serviceDataTransmitter(uint8_t* outStream, uint16_t outStreamLength, uint8_t* inStream);
#endif /* V2G_SERVICECLIENTDATATRANSMITTER_H_ */
#ifdef __cplusplus
}
#endif

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,158 @@
/*
* 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 <http://www.gnu.org/licenses/>.
*/
/*******************************************************************
*
* @author Sebastian.Kaebisch.EXT@siemens.com
* @version 0.3.1
* @contact Joerg.Heuer@siemens.com
*
********************************************************************/
#ifdef __cplusplus
extern "C" {
#endif
#ifndef SERVICECLIENTSTUBS_H
#define SERVICECLIENTSTUBS_H
#include "v2g_service.h"
#include "v2g_serviceDataTypes.h"
#include "v2g_serviceClientStubs.h"
/**
* \brief Calls the remote sessionSetup method
* \param service struct EXIService* Service data structure (has to be initialized before)
* \param header struct HeaderType* Header data structure
* \param params struct SessionSetupReqType* Request data for the server (has to be set up before)
* \param result struct SessionSetupResType* Contains the response data from the server
* \return 0 = 0K; -1 = ERROR */
int call_sessionSetup(struct EXIService* service, struct HeaderType* header, struct SessionSetupReqType* params, struct SessionSetupResType* result);
/**
* \brief Calls the remote serviceDiscovery method
* \param service struct EXIService* Service data structure (has to be initialized before)
* \param header struct HeaderType* Header data structure
* \param params struct ServiceDiscoveryReqType* Request data for the server (has to be set up before)
* \param result struct ServiceDiscoveryResType* Contains the response data from the server
* \return 0 = 0K; -1 = ERROR */
int call_serviceDiscovery(struct EXIService* service, struct HeaderType* header, struct ServiceDiscoveryReqType* params, struct ServiceDiscoveryResType* result);
/**
* \brief Calls the remote selectedServicePayment method
* \param service struct EXIService* Service data structure (has to be initialized before)
* \param header struct HeaderType* Header data structure
* \param params struct ServicePaymentSelectionReqType* Request data for the server (has to be set up before)
* \param result struct ServicePaymentSelectionResType* Contains the response data from the server
* \return 0 = 0K; -1 = ERROR */
int call_selectedServicePayment(struct EXIService* service, struct HeaderType* header, struct ServicePaymentSelectionReqType* params, struct ServicePaymentSelectionResType* result);
/**
* \brief Calls the remote paymentDetails method
* \param service struct EXIService* Service data structure (has to be initialized before)
* \param header struct HeaderType* Header data structure
* \param params struct PaymentDetailsReqType* Request data for the server (has to be set up before)
* \param result struct PaymentDetailsResType* Contains the response data from the server
* \return 0 = 0K; -1 = ERROR */
int call_paymentDetails(struct EXIService* service, struct HeaderType* header, struct PaymentDetailsReqType* params, struct PaymentDetailsResType* result);
/**
* \brief Calls the remote powerDiscovery method
* \param service struct EXIService* Service data structure (has to be initialized before)
* \param header struct HeaderType* Header data structure
* \param params struct PowerDiscoveryReqType* Request data for the server (has to be set up before)
* \param result struct PowerDiscoveryResType* Contains the response data from the server
* \return 0 = 0K; -1 = ERROR */
int call_powerDiscovery(struct EXIService* service, struct HeaderType* header, struct PowerDiscoveryReqType* params, struct PowerDiscoveryResType* result);
/**
* \brief Calls the remote lineLock method
* \param service struct EXIService* Service data structure (has to be initialized before)
* \param header struct HeaderType* Header data structure
* \param params struct LineLockReqType* Request data for the server (has to be set up before)
* \param result struct LineLockResType* Contains the response data from the server
* \return 0 = 0K; -1 = ERROR */
int call_lineLock(struct EXIService* service, struct HeaderType* header, struct LineLockReqType* params, struct LineLockResType* result);
/**
* \brief Calls the remote powerDelivery method
* \param service struct EXIService* Service data structure (has to be initialized before)
* \param header struct HeaderType* Header data structure
* \param params struct PowerDeliveryReqType* Request data for the server (has to be set up before)
* \param result struct PowerDeliveryResType* Contains the response data from the server
* \return 0 = 0K; -1 = ERROR */
int call_powerDelivery(struct EXIService* service, struct HeaderType* header, struct PowerDeliveryReqType* params, struct PowerDeliveryResType* result);
/**
* \brief Calls the remote meteringStatus method
* \param service struct EXIService* Service data structure (has to be initialized before)
* \param header struct HeaderType* Header data structure
* \param result struct MeteringStatusResType* Contains the response data from the server
* \return 0 = 0K; -1 = ERROR */
int call_meteringStatus(struct EXIService* service, struct HeaderType* header, struct MeteringStatusResType* result);
/**
* \brief Calls the remote meteringReceipt method
* \param service struct EXIService* Service data structure (has to be initialized before)
* \param header struct HeaderType* Header data structure
* \param params struct MeteringReceiptReqType* Request data for the server (has to be set up before)
* \param result struct MeteringReceiptResType* Contains the response data from the server
* \return 0 = 0K; -1 = ERROR */
int call_meteringReceipt(struct EXIService* service, struct HeaderType* header, struct MeteringReceiptReqType* params, struct MeteringReceiptResType* result);
/* Initialize the v2g client */
int init_v2gServiceClient(struct EXIService* service, bytes_t bytes, string_ucs_t string, uint8_t* inStream, size_t max_inStream_size, uint8_t* outStream, size_t max_outStream_size, uint16_t transportHeaderOffset);
#endif
#ifdef __cplusplus
}
#endif

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,357 @@
/*
* 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 <http://www.gnu.org/licenses/>.
*/
/*******************************************************************
*
* @author Sebastian.Kaebisch.EXT@siemens.com
* @version 0.3.1
* @contact Joerg.Heuer@siemens.com
*
********************************************************************/
#include "EXITypes.h"
#include "v2g_serviceDataTypes.h"
static void init_SessionInformationType_SessionID(struct SessionInformationType_SessionID* type)
{
type->arraylen.data=0;
}
static void init_SessionInformationType_ServiceSessionID(struct SessionInformationType_ServiceSessionID* type)
{
type->arraylen.data=0;
}
static void init_SessionInformationType_ProtocolVersion(struct SessionInformationType_ProtocolVersion* type)
{
type->arraylen.data=0;
}
static void init_SessionInformationType(struct SessionInformationType* type)
{
init_SessionInformationType_SessionID(&(type->SessionID));
init_SessionInformationType_ServiceSessionID(&(type->ServiceSessionID));
type->isused.ServiceSessionID=0;
init_SessionInformationType_ProtocolVersion(&(type->ProtocolVersion));
type->isused.ProtocolVersion=0;
}
static void init_NotificationType_FaultMsg(struct NotificationType_FaultMsg* type)
{
type->arraylen.data=0;
}
static void init_NotificationType(struct NotificationType* type)
{
type->isused.FaultCode=0;
init_NotificationType_FaultMsg(&(type->FaultMsg));
type->isused.FaultMsg=0;
type->isused.EventList=0;
}
static void init_HeaderType(struct HeaderType* type)
{
init_SessionInformationType(&(type->SessionInformation));
init_NotificationType(&(type->Notification));
type->isused.Notification=0;
}
static void init_SessionSetupReqType_PEVID(struct SessionSetupReqType_PEVID* type)
{
type->arraylen.data=0;
}
static void init_SessionSetupReqType(struct SessionSetupReqType* type)
{
init_SessionSetupReqType_PEVID(&(type->PEVID));
type->isused.PEVID=0;
}
static void init_SessionSetupResType_EVSEID(struct SessionSetupResType_EVSEID* type)
{
type->arraylen.data=0;
}
static void init_SessionSetupResType(struct SessionSetupResType* type)
{
init_SessionSetupResType_EVSEID(&(type->EVSEID));
}
static void init_ServiceDiscoveryReqType_ServiceScope(struct ServiceDiscoveryReqType_ServiceScope* type)
{
type->arraylen.data=0;
}
static void init_ServiceDiscoveryReqType(struct ServiceDiscoveryReqType* type)
{
type->isused.ServiceType=0;
init_ServiceDiscoveryReqType_ServiceScope(&(type->ServiceScope));
type->isused.ServiceScope=0;
}
static void init_ServiceDescriptionType_ServiceID(struct ServiceDescriptionType_ServiceID* type)
{
type->arraylen.data=0;
}
static void init_ServiceDescriptionType_ServiceName(struct ServiceDescriptionType_ServiceName* type)
{
type->arraylen.data=0;
}
static void init_ServiceDescriptionType_ServiceScope(struct ServiceDescriptionType_ServiceScope* type)
{
type->arraylen.data=0;
}
static void init_ServiceDescriptionType(struct ServiceDescriptionType* type)
{
init_ServiceDescriptionType_ServiceID(&(type->ServiceID));
init_ServiceDescriptionType_ServiceName(&(type->ServiceName));
type->isused.ServiceName=0;
type->isused.ServiceType=0;
init_ServiceDescriptionType_ServiceScope(&(type->ServiceScope));
type->isused.ServiceScope=0;
}
static void init_ServiceListType(struct ServiceListType* type)
{
int i_loop;
for(i_loop=0; i_loop<8;i_loop++)
{
init_ServiceDescriptionType(&(type->Service[i_loop]));
}
type->arraylen.Service=0;
}
static void init_ServiceDiscoveryResType(struct ServiceDiscoveryResType* type)
{
init_ServiceListType(&(type->ServiceList));
type->isused.ServiceList=0;
}
static void init_ServicePaymentSelectionReqType(struct ServicePaymentSelectionReqType* type)
{
init_ServiceListType(&(type->ServiceList));
}
static void init_PaymentDetailsReqType_ContractID(struct PaymentDetailsReqType_ContractID* type)
{
type->arraylen.data=0;
}
static void init_PaymentDetailsReqType(struct PaymentDetailsReqType* type)
{
init_PaymentDetailsReqType_ContractID(&(type->ContractID));
}
static void init_PowerDiscoveryReqType(struct PowerDiscoveryReqType* type)
{
}
static void init_PowerDiscoveryResType_EnergyProvider(struct PowerDiscoveryResType_EnergyProvider* type)
{
type->arraylen.data=0;
}
static void init_TariffTableType_Currency(struct TariffTableType_Currency* type)
{
type->arraylen.data=0;
}
static void init_TariffDescrType_TariffDescription(struct TariffDescrType_TariffDescription* type)
{
type->arraylen.data=0;
}
static void init_TariffEntryType(struct TariffEntryType* type)
{
type->isused.EPrice=0;
}
static void init_TariffEntriesType(struct TariffEntriesType* type)
{
int i_loop;
for(i_loop=0; i_loop<8;i_loop++)
{
init_TariffEntryType(&(type->TariffEntry[i_loop]));
}
type->arraylen.TariffEntry=0;
}
static void init_TariffDescrType(struct TariffDescrType* type)
{
init_TariffDescrType_TariffDescription(&(type->TariffDescription));
type->isused.TariffDescription=0;
init_TariffEntriesType(&(type->TariffEntries));
}
static void init_TariffTableType(struct TariffTableType* type)
{
int i_loop;
init_TariffTableType_Currency(&(type->Currency));
for(i_loop=0; i_loop<6;i_loop++)
{
init_TariffDescrType(&(type->Tariff[i_loop]));
}
type->arraylen.Tariff=0;
}
static void init_PowerDiscoveryResType(struct PowerDiscoveryResType* type)
{
init_PowerDiscoveryResType_EnergyProvider(&(type->EnergyProvider));
type->isused.EnergyProvider=0;
init_TariffTableType(&(type->TariffTable));
type->isused.TariffTable=0;
}
static void init_LineLockReqType(struct LineLockReqType* type)
{
}
static void init_LineLockResType(struct LineLockResType* type)
{
}
static void init_PowerDeliveryReqType(struct PowerDeliveryReqType* type)
{
type->isused.Tariff=0;
}
static void init_MeteringStatusResType_EVSEID(struct MeteringStatusResType_EVSEID* type)
{
type->arraylen.data=0;
}
static void init_MeterInfoType_MeterID(struct MeterInfoType_MeterID* type)
{
type->arraylen.data=0;
}
static void init_MeterInfoType(struct MeterInfoType* type)
{
init_MeterInfoType_MeterID(&(type->MeterID));
type->isused.MeterID=0;
type->isused.MeterReading=0;
type->isused.MeterStatus=0;
type->isused.TMeter=0;
}
static void init_MeteringStatusResType(struct MeteringStatusResType* type)
{
init_MeteringStatusResType_EVSEID(&(type->EVSEID));
type->isused.PCurrent=0;
init_MeterInfoType(&(type->MeterInfo));
type->isused.MeterInfo=0;
}
static void init_MeteringReceiptReqType_PEVID(struct MeteringReceiptReqType_PEVID* type)
{
type->arraylen.data=0;
}
static void init_MeteringReceiptReqType(struct MeteringReceiptReqType* type)
{
init_MeteringReceiptReqType_PEVID(&(type->PEVID));
type->isused.PEVID=0;
type->isused.TCurrent=0;
init_MeterInfoType(&(type->MeterInfo));
}
static void init_BodyType(struct BodyType* type)
{
type->isused.SessionSetupReq=0;
type->isused.SessionSetupRes=0;
type->isused.ServiceDiscoveryReq=0;
type->isused.ServiceDiscoveryRes=0;
type->isused.ServicePaymentSelectionReq=0;
type->isused.ServicePaymentSelectionRes=0;
type->isused.PaymentDetailsReq=0;
type->isused.PaymentDetailsRes=0;
type->isused.PowerDiscoveryReq=0;
type->isused.PowerDiscoveryRes=0;
type->isused.LineLockReq=0;
type->isused.LineLockRes=0;
type->isused.PowerDeliveryReq=0;
type->isused.PowerDeliveryRes=0;
type->isused.MeteringStatusReq=0;
type->isused.MeteringStatusRes=0;
type->isused.MeteringReceiptReq=0;
type->isused.MeteringReceiptRes=0;
}
static void init_AnonType_V2G_Message(struct AnonType_V2G_Message* type)
{
init_BodyType(&(type->Body));
}
static void init_EXIDocumentType(struct EXIDocumentType* type)
{
init_AnonType_V2G_Message(&(type->V2G_Message));
}

View file

@ -0,0 +1,924 @@
/*
* 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 <http://www.gnu.org/licenses/>.
*/
/*******************************************************************
*
* @author Sebastian.Kaebisch.EXT@siemens.com
* @version 0.3.1
* @contact Joerg.Heuer@siemens.com
*
********************************************************************/
#ifdef __cplusplus
extern "C" {
#endif
#ifndef SERVICEDATATYPES_H
#define SERVICEDATATYPES_H
#include "EXITypes.h"
enum faultCodeType
{
ParsingError_faultCodeType,
V2GProtocolVersionNotSupported_faultCodeType,
UnknownError_faultCodeType
};
enum eventEntryType
{
InitiateSessionSetup_eventEntryType,
InitiateServiceDiscovery_eventEntryType,
InitiatePowerDiscovery_eventEntryType,
InitiateLineLock_eventEntryType,
InitiatePowerDelivery_eventEntryType,
InitiateInitiateMeteringStatus_eventEntryType
};
enum responseCode_SessionSetupType
{
OK_SessionSetup_responseCode_SessionSetupType,
OK_NewSessionEstablished_responseCode_SessionSetupType,
OK_OldSessionJoined_responseCode_SessionSetupType,
FAILED_UnknownSession_responseCode_SessionSetupType,
FAILED_SessionEstablishmentError_responseCode_SessionSetupType,
FAILED_UnknownError_InSessionSetup_responseCode_SessionSetupType
};
enum serviceTypeType
{
PEV_Recharge_serviceTypeType,
Remote_Customer_Support_serviceTypeType,
Internet_serviceTypeType,
Other_serviceTypeType
};
enum responseCode_ServiceDiscoveryType
{
OK_ServiceDiscovery_responseCode_ServiceDiscoveryType,
FAILED_NoServicesOfThisType_responseCode_ServiceDiscoveryType,
FAILED_NoServicesInThisScope_responseCode_ServiceDiscoveryType,
FAILED_NoServicesOfThisTypeScope_responseCode_ServiceDiscoveryType,
FAILED_NoServicesFound_responseCode_ServiceDiscoveryType,
FAILED_UnknownError_InServiceDiscovery_responseCode_ServiceDiscoveryType
};
enum responseCode_ServicePaymentSelectionType
{
OK_ServicePaymentSelection_responseCode_ServicePaymentSelectionType,
FAILED_ServiceSelectionInvalid_responseCode_ServicePaymentSelectionType,
FAILED_PaymentSelectionInvalid_responseCode_ServicePaymentSelectionType,
FAILED_UnknownError_InServicePaymentSelection_responseCode_ServicePaymentSelectionType
};
enum responseCode_PaymentDetailsType
{
OK_PaymentDetails_responseCode_PaymentDetailsType,
FAILED_PaymentDetailsInvalid_responseCode_PaymentDetailsType,
FAILED_UnknownError_responseCode_PaymentDetailsType
};
enum unitMultiplierType
{
d_unitMultiplierType,
c_unitMultiplierType,
m_unitMultiplierType,
micro_unitMultiplierType,
n_unitMultiplierType,
p_unitMultiplierType,
k_unitMultiplierType,
M_unitMultiplierType,
G_unitMultiplierType,
T_unitMultiplierType,
none_unitMultiplierType
};
enum unitSymbolType
{
A_unitSymbolType,
deg_unitSymbolType,
F_unitSymbolType,
g_unitSymbolType,
h_unitSymbolType,
J_unitSymbolType,
J_s_unitSymbolType,
kg_J_unitSymbolType,
min_unitSymbolType,
N_unitSymbolType,
ohm_unitSymbolType,
s_unitSymbolType,
S_unitSymbolType,
s_1_unitSymbolType,
V_unitSymbolType,
V_VAr_unitSymbolType,
VA_unitSymbolType,
VAh_unitSymbolType,
VAr_unitSymbolType,
VArh_unitSymbolType,
W_unitSymbolType,
W_Hz_unitSymbolType,
W_s_unitSymbolType,
Wh_unitSymbolType,
Ah_unitSymbolType
};
enum responseCode_PowerDiscoveryType
{
OK_PowerDiscovery_responseCode_PowerDiscoveryType,
FAILED_UnknownError_InPowerDiscovery_responseCode_PowerDiscoveryType
};
enum tariffIDType
{
Standard_charge_tariffIDType,
Fast_charge_tariffIDType,
Green_charge_tariffIDType,
Grid_friendly_charge_tariffIDType,
Freely_parameterisable_charge_tariffIDType,
Charge_under_reserve_tariffIDType
};
enum responseCode_LineLockType
{
OK_LineLock_responseCode_LineLockType,
FAILED_LineLockNotApplied_responseCode_LineLockType,
FAILED_UnknownError_InLineLock_responseCode_LineLockType
};
enum responseCode_PowerDeliveryType
{
OK_PowerDelivery_responseCode_PowerDeliveryType,
FAILED_PowerDeliveryNotApplied_responseCode_PowerDeliveryType,
FAILED_TariffSelectionInvalid_responseCode_PowerDeliveryType,
FAILED_ChargingProfileInvalid_responseCode_PowerDeliveryType,
FAILED_UnknownError_InPowerDelivery_responseCode_PowerDeliveryType
};
enum responseCode_MeteringStatusType
{
OK_MeteringStatus_responseCode_MeteringStatusType,
FAILED_UnknownError_InMeteringStatus_responseCode_MeteringStatusType
};
enum responseCode_MeteringReceiptType
{
OK_MeteringReceipt_responseCode_MeteringReceiptType,
FAILED_UnknownError_MeteringReceipt_responseCode_MeteringReceiptType
};
struct arraylen_SessionInformationType_SessionID
{
size_t data;
};
struct SessionInformationType_SessionID
{
uint8_t data[8];
struct arraylen_SessionInformationType_SessionID arraylen;
};
struct arraylen_SessionInformationType_ServiceSessionID
{
size_t data;
};
struct SessionInformationType_ServiceSessionID
{
uint8_t data[8];
struct arraylen_SessionInformationType_ServiceSessionID arraylen;
};
struct selection_SessionInformationType
{
unsigned int ServiceSessionID:1;
unsigned int ProtocolVersion:1;
};
struct arraylen_SessionInformationType_ProtocolVersion
{
size_t data;
};
struct SessionInformationType_ProtocolVersion
{
uint32_t data[5];
struct arraylen_SessionInformationType_ProtocolVersion arraylen;
};
struct SessionInformationType
{
struct SessionInformationType_SessionID SessionID;
struct SessionInformationType_ServiceSessionID ServiceSessionID;
struct SessionInformationType_ProtocolVersion ProtocolVersion;
struct selection_SessionInformationType isused;
};
struct selection_NotificationType
{
unsigned int FaultCode:1;
unsigned int FaultMsg:1;
unsigned int EventList:1;
};
struct arraylen_NotificationType_FaultMsg
{
size_t data;
};
struct NotificationType_FaultMsg
{
uint32_t data[256];
struct arraylen_NotificationType_FaultMsg arraylen;
};
struct EventListType
{
enum eventEntryType Event;
};
struct NotificationType
{
enum faultCodeType FaultCode;
struct NotificationType_FaultMsg FaultMsg;
struct EventListType EventList;
struct selection_NotificationType isused;
};
struct selection_HeaderType
{
unsigned int Notification:1;
};
struct HeaderType
{
struct SessionInformationType SessionInformation;
struct NotificationType Notification;
struct selection_HeaderType isused;
};
struct arraylen_SessionSetupReqType_PEVID
{
size_t data;
};
struct SessionSetupReqType_PEVID
{
uint32_t data[32];
struct arraylen_SessionSetupReqType_PEVID arraylen;
};
struct selection_SessionSetupReqType
{
unsigned int PEVID:1;
};
struct PEVStatusType
{
int ConnectorLocked;
int ChargerStandby;
};
struct SessionSetupReqType
{
struct SessionSetupReqType_PEVID PEVID;
struct PEVStatusType PEVStatus;
struct selection_SessionSetupReqType isused;
};
struct selection_BodyType
{
unsigned int SessionSetupReq:1;
unsigned int SessionSetupRes:1;
unsigned int ServiceDiscoveryReq:1;
unsigned int ServiceDiscoveryRes:1;
unsigned int ServicePaymentSelectionReq:1;
unsigned int ServicePaymentSelectionRes:1;
unsigned int PaymentDetailsReq:1;
unsigned int PaymentDetailsRes:1;
unsigned int PowerDiscoveryReq:1;
unsigned int PowerDiscoveryRes:1;
unsigned int LineLockReq:1;
unsigned int LineLockRes:1;
unsigned int PowerDeliveryReq:1;
unsigned int PowerDeliveryRes:1;
unsigned int MeteringStatusReq:1;
unsigned int MeteringStatusRes:1;
unsigned int MeteringReceiptReq:1;
unsigned int MeteringReceiptRes:1;
};
struct arraylen_SessionSetupResType_EVSEID
{
size_t data;
};
struct SessionSetupResType_EVSEID
{
uint8_t data[32];
struct arraylen_SessionSetupResType_EVSEID arraylen;
};
struct EVSEStatusType
{
int FatalError;
int EVSEStandby;
int ConnectorLocked;
int PowerSwitchClosed;
int RCD;
int32_t ShutDownTime;
};
struct SessionSetupResType
{
enum responseCode_SessionSetupType ResponseCode;
struct SessionSetupResType_EVSEID EVSEID;
struct EVSEStatusType EVSEStatus;
int32_t TCurrent;
};
struct selection_ServiceDiscoveryReqType
{
unsigned int ServiceType:1;
unsigned int ServiceScope:1;
};
struct arraylen_ServiceDiscoveryReqType_ServiceScope
{
size_t data;
};
struct ServiceDiscoveryReqType_ServiceScope
{
uint32_t data[20];
struct arraylen_ServiceDiscoveryReqType_ServiceScope arraylen;
};
struct ServiceDiscoveryReqType
{
enum serviceTypeType ServiceType;
struct ServiceDiscoveryReqType_ServiceScope ServiceScope;
struct selection_ServiceDiscoveryReqType isused;
};
struct arraylen_ServiceDescriptionType_ServiceID
{
size_t data;
};
struct ServiceDescriptionType_ServiceID
{
uint8_t data[8];
struct arraylen_ServiceDescriptionType_ServiceID arraylen;
};
struct arraylen_ServiceDescriptionType_ServiceName
{
size_t data;
};
struct ServiceDescriptionType_ServiceName
{
uint32_t data[20];
struct arraylen_ServiceDescriptionType_ServiceName arraylen;
};
struct selection_ServiceDescriptionType
{
unsigned int ServiceName:1;
unsigned int ServiceType:1;
unsigned int ServiceScope:1;
};
struct arraylen_ServiceDescriptionType_ServiceScope
{
size_t data;
};
struct ServiceDescriptionType_ServiceScope
{
uint32_t data[20];
struct arraylen_ServiceDescriptionType_ServiceScope arraylen;
};
struct ServiceDescriptionType
{
struct ServiceDescriptionType_ServiceID ServiceID;
struct ServiceDescriptionType_ServiceName ServiceName;
enum serviceTypeType ServiceType;
struct ServiceDescriptionType_ServiceScope ServiceScope;
struct selection_ServiceDescriptionType isused;
};
struct arraylen_ServiceListType
{
size_t Service;
};
struct ServiceListType
{
struct ServiceDescriptionType Service[8];
struct arraylen_ServiceListType arraylen;
};
struct selection_ServiceDiscoveryResType
{
unsigned int ServiceList:1;
};
struct ServiceDiscoveryResType
{
enum responseCode_ServiceDiscoveryType ResponseCode;
struct ServiceListType ServiceList;
struct selection_ServiceDiscoveryResType isused;
};
struct ServicePaymentSelectionReqType
{
struct ServiceListType ServiceList;
};
struct ServicePaymentSelectionResType
{
enum responseCode_ServicePaymentSelectionType ResponseCode;
};
struct arraylen_PaymentDetailsReqType_ContractID
{
size_t data;
};
struct PaymentDetailsReqType_ContractID
{
uint32_t data[128];
struct arraylen_PaymentDetailsReqType_ContractID arraylen;
};
struct PaymentDetailsReqType
{
struct PaymentDetailsReqType_ContractID ContractID;
};
struct PaymentDetailsResType
{
enum responseCode_PaymentDetailsType ResponseCode;
};
struct FloatingValueType
{
enum unitMultiplierType Multiplier;
enum unitSymbolType Unit;
int32_t Value;
};
struct PowerDiscoveryReqType
{
struct PEVStatusType PEVStatus;
int32_t EoC;
struct FloatingValueType EAmount;
struct FloatingValueType PEVMaxPower;
int16_t PEVMaxPhases;
struct FloatingValueType PEVMaxVoltage;
struct FloatingValueType PEVMinVoltage;
};
struct arraylen_PowerDiscoveryResType_EnergyProvider
{
size_t data;
};
struct PowerDiscoveryResType_EnergyProvider
{
uint32_t data[20];
struct arraylen_PowerDiscoveryResType_EnergyProvider arraylen;
};
struct selection_PowerDiscoveryResType
{
unsigned int EnergyProvider:1;
unsigned int TariffTable:1;
};
struct arraylen_TariffTableType_Currency
{
size_t data;
};
struct TariffTableType_Currency
{
uint32_t data[3];
struct arraylen_TariffTableType_Currency arraylen;
};
struct arraylen_TariffDescrType_TariffDescription
{
size_t data;
};
struct TariffDescrType_TariffDescription
{
uint32_t data[32];
struct arraylen_TariffDescrType_TariffDescription arraylen;
};
struct selection_TariffDescrType
{
unsigned int TariffDescription:1;
};
struct selection_TariffEntryType
{
unsigned int EPrice:1;
};
struct TariffEntryType
{
uint32_t TariffStart;
struct FloatingValueType TariffPMax;
struct FloatingValueType EPrice;
struct selection_TariffEntryType isused;
};
struct arraylen_TariffEntriesType
{
size_t TariffEntry;
};
struct TariffEntriesType
{
struct TariffEntryType TariffEntry[8];
struct arraylen_TariffEntriesType arraylen;
};
struct TariffDescrType
{
enum tariffIDType TariffID;
struct TariffDescrType_TariffDescription TariffDescription;
struct TariffEntriesType TariffEntries;
struct selection_TariffDescrType isused;
};
struct arraylen_TariffTableType
{
size_t Tariff;
};
struct TariffTableType
{
struct TariffTableType_Currency Currency;
struct TariffDescrType Tariff[6];
struct arraylen_TariffTableType arraylen;
};
struct PowerDiscoveryResType
{
enum responseCode_PowerDiscoveryType ResponseCode;
struct EVSEStatusType EVSEStatus;
struct FloatingValueType EVSEVoltage;
struct FloatingValueType EVSEIMax;
int16_t EVSEMaxPhases;
struct PowerDiscoveryResType_EnergyProvider EnergyProvider;
struct TariffTableType TariffTable;
struct selection_PowerDiscoveryResType isused;
};
struct LineLockReqType
{
struct PEVStatusType PEVStatus;
int ReqLockStatus;
};
struct LineLockResType
{
enum responseCode_LineLockType ResponseCode;
struct EVSEStatusType EVSEStatus;
};
struct selection_PowerDeliveryReqType
{
unsigned int Tariff:1;
};
struct PowerDeliveryReqType
{
struct PEVStatusType PEVStatus;
int ReqSwitchStatus;
enum tariffIDType Tariff;
struct selection_PowerDeliveryReqType isused;
};
struct PowerDeliveryResType
{
enum responseCode_PowerDeliveryType ResponseCode;
};
struct MeteringStatusReqType
{
int NO_MEMBER:1;
};
struct arraylen_MeteringStatusResType_EVSEID
{
size_t data;
};
struct MeteringStatusResType_EVSEID
{
uint8_t data[32];
struct arraylen_MeteringStatusResType_EVSEID arraylen;
};
struct selection_MeteringStatusResType
{
unsigned int PCurrent:1;
unsigned int MeterInfo:1;
};
struct arraylen_MeterInfoType_MeterID
{
size_t data;
};
struct MeterInfoType_MeterID
{
uint32_t data[32];
struct arraylen_MeterInfoType_MeterID arraylen;
};
struct selection_MeterInfoType
{
unsigned int MeterID:1;
unsigned int MeterReading:1;
unsigned int MeterStatus:1;
unsigned int TMeter:1;
};
struct MeterInfoType
{
struct MeterInfoType_MeterID MeterID;
struct FloatingValueType MeterReading;
int16_t MeterStatus;
int32_t TMeter;
struct selection_MeterInfoType isused;
};
struct MeteringStatusResType
{
enum responseCode_MeteringStatusType ResponseCode;
struct MeteringStatusResType_EVSEID EVSEID;
struct EVSEStatusType EVSEStatus;
int32_t TCurrent;
struct FloatingValueType EVSEMaxPower;
struct FloatingValueType PCurrent;
struct MeterInfoType MeterInfo;
struct selection_MeteringStatusResType isused;
};
struct arraylen_MeteringReceiptReqType_PEVID
{
size_t data;
};
struct MeteringReceiptReqType_PEVID
{
uint32_t data[32];
struct arraylen_MeteringReceiptReqType_PEVID arraylen;
};
struct selection_MeteringReceiptReqType
{
unsigned int PEVID:1;
unsigned int TCurrent:1;
};
struct MeteringReceiptReqType
{
struct MeteringReceiptReqType_PEVID PEVID;
struct PEVStatusType PEVStatus;
int32_t TCurrent;
enum tariffIDType Tariff;
struct MeterInfoType MeterInfo;
struct selection_MeteringReceiptReqType isused;
};
struct MeteringReceiptResType
{
enum responseCode_MeteringReceiptType ResponseCode;
};
struct BodyType
{
struct SessionSetupReqType* SessionSetupReq;
struct SessionSetupResType* SessionSetupRes;
struct ServiceDiscoveryReqType* ServiceDiscoveryReq;
struct ServiceDiscoveryResType* ServiceDiscoveryRes;
struct ServicePaymentSelectionReqType* ServicePaymentSelectionReq;
struct ServicePaymentSelectionResType* ServicePaymentSelectionRes;
struct PaymentDetailsReqType* PaymentDetailsReq;
struct PaymentDetailsResType* PaymentDetailsRes;
struct PowerDiscoveryReqType* PowerDiscoveryReq;
struct PowerDiscoveryResType* PowerDiscoveryRes;
struct LineLockReqType* LineLockReq;
struct LineLockResType* LineLockRes;
struct PowerDeliveryReqType* PowerDeliveryReq;
struct PowerDeliveryResType* PowerDeliveryRes;
struct MeteringStatusReqType* MeteringStatusReq;
struct MeteringStatusResType* MeteringStatusRes;
struct MeteringReceiptReqType* MeteringReceiptReq;
struct MeteringReceiptResType* MeteringReceiptRes;
struct selection_BodyType isused;
};
struct AnonType_V2G_Message
{
struct HeaderType* Header;
struct BodyType Body;
};
struct EXIDocumentType
{
struct AnonType_V2G_Message V2G_Message;
};
#endif
#ifdef __cplusplus
}
#endif

File diff suppressed because it is too large Load diff

View file

@ -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 <http://www.gnu.org/licenses/>.
*/
/*******************************************************************
*
* @author Sebastian.Kaebisch.EXT@siemens.com
* @version 0.3.1
* @contact Joerg.Heuer@siemens.com
*
********************************************************************/
#ifdef __cplusplus
extern "C" {
#endif
#ifndef V2GSERVER_H_
#define V2GSERVER_H_
#include "v2g_serviceDataTypes.h"
int init_v2gservice(struct EXIService* service,bytes_t bytes, string_ucs_t string, uint16_t transportHeaderOffset);
int messageDispatcher(struct EXIService* service, uint8_t* inStream, uint16_t sizeInStream, uint8_t* outStream, uint16_t sizeOutStream, uint16_t* outPos);
#endif /* V2GSERVER_H_ */
#ifdef __cplusplus
}
#endif

View file

@ -0,0 +1,69 @@
/*
* 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 <http://www.gnu.org/licenses/>.
*/
/*******************************************************************
*
* @author Sebastian.Kaebisch.EXT@siemens.com
* @version 0.3.1
* @contact Joerg.Heuer@siemens.com
*
********************************************************************/
#ifdef __cplusplus
extern "C" {
#endif
#ifndef SERVICEMETHODS_H
#define SERVICEMETHODS_H
#include "v2g_serviceDataTypes.h"
#include "EXITypes.h"
/* This service methods has to be implemented by the EVSE server */
int sessionSetup(struct SessionSetupReqType* param, struct SessionSetupResType* result);
int serviceDiscovery(struct ServiceDiscoveryReqType* param, struct ServiceDiscoveryResType* result);
int selectedServicePayment(struct ServicePaymentSelectionReqType* param, struct ServicePaymentSelectionResType* result);
int paymentDetails(struct PaymentDetailsReqType* param, struct PaymentDetailsResType* result);
int powerDiscovery(struct PowerDiscoveryReqType* param, struct PowerDiscoveryResType* result);
int lineLock(struct LineLockReqType* param, struct LineLockResType* result);
int powerDelivery(struct PowerDeliveryReqType* param, struct PowerDeliveryResType* result);
int meteringStatus(struct MeteringStatusReqType* param, struct MeteringStatusResType* result);
int meteringReceipt(struct MeteringReceiptReqType* param, struct MeteringReceiptResType* result);
#endif
#ifdef __cplusplus
}
#endif

View file

@ -0,0 +1,42 @@
/*
* 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 <http://www.gnu.org/licenses/>.
*/
/*******************************************************************
*
* @author Daniel.Peintner.EXT@siemens.com
* @author Sebastian.Kaebisch.EXT@siemens.com
* @version 0.3.1
* @contact Joerg.Heuer@siemens.com
*
* <p>Switch for sample programs: EXI codec only or for entire V2G service</p>
*
********************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include "main.h"
int main(int argc, char *argv[]) {
/* EXI codec only */
/* return main_codec(argc, argv); */
/* V2G client / service example scenario */
return main_service(argc, argv);
}

View file

@ -0,0 +1,34 @@
/*
* 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 <http://www.gnu.org/licenses/>.
*/
/*******************************************************************
*
* @author Daniel.Peintner.EXT@siemens.com
* @author Sebastian.Kaebisch.EXT@siemens.com
* @version 0.3.1
* @contact Joerg.Heuer@siemens.com
*
*
********************************************************************/
#ifndef MAIN_H_
#define MAIN_H_
int main_codec(int argc, char *argv[]);
int main_service(int argc, char *argv[]);
#endif

View file

@ -0,0 +1,231 @@
/*
* 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 <http://www.gnu.org/licenses/>.
*/
/*******************************************************************
*
* @author Daniel.Peintner.EXT@siemens.com
* @version 0.1
* @contact Joerg.Heuer@siemens.com
*
* <p>Sample program to illustrate how to read an EXI stream and
* directly write it again to an output</p>
*
* <p>e.g., data/test/sessionSetupReq.xml.exi out/test/sessionSetupReq.xml.exi</p>
********************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include "EXIDecoder.h"
#include "StringTable.h"
#include "EXIEncoder.h"
#include "EXITypes.h"
#include "ByteStream.h"
#define BUFFER_SIZE 1000
#define ARRAY_SIZE_BYTES 100
#define ARRAY_SIZE_STRINGS 100
/* avoids warning: initializer element is not computable at load time */
uint8_t bufferIn[BUFFER_SIZE];
uint8_t bufferOut[BUFFER_SIZE];
uint8_t data[ARRAY_SIZE_BYTES];
uint32_t codepoints[ARRAY_SIZE_STRINGS];
int main_codec(int argc, char *argv[]) {
int errn = 0;
unsigned int i;
bitstream_t iStream, oStream;
uint16_t posDecode;
uint16_t posEncode;
/* EXI set-up */
exi_state_t stateDecode;
exi_state_t stateEncode;
exi_event_t event;
eqname_t eqn;
exi_value_t val;
/* BINARY memory setup */
bytes_t bytes = { ARRAY_SIZE_BYTES, data, 0 };
/* STRING memory setup */
string_ucs_t string = { ARRAY_SIZE_STRINGS, codepoints, 0 };
const char * localName;
const char * namespaceURI;
int noEndOfDocument = 1; /* true */
if (argc != 3) {
printf("Usage: %s exiInput exiOutput\n", argv[0]);
return -1;
}
/* input pos */
posDecode = 0;
/* parse EXI stream to internal byte structures */
readBytesFromFile(argv[1], bufferIn, BUFFER_SIZE, posDecode);
/* setup input stream */
iStream.size = BUFFER_SIZE;
iStream.data = bufferIn;
iStream.pos = &posDecode;
iStream.buffer = 0;
iStream.capacity = 0;
/* setup output stream */
posEncode = 0;
oStream.size = BUFFER_SIZE;
oStream.data = bufferOut;
oStream.pos = &posEncode;
oStream.buffer = 0;
oStream.capacity = 8;
val.binary = bytes;
val.string = string;
/* init decoder (read header, set initial state) */
exiInitDecoder(&iStream, &stateDecode);
/* init encoder (write header, set initial state) */
exiInitEncoder(&oStream, &stateEncode);
printf("[DECODE] >>> EXI >>> [ENCODE] \n");
do {
if (errn < 0) {
printf("[Encode-ERROR] %d \n", errn);
return errn;
}
errn = exiDecodeNextEvent(&iStream, &stateDecode, &event);
if (errn < 0) {
printf("[Decode-ERROR] %d \n", errn);
return errn;
}
switch (event) {
case START_DOCUMENT:
/* decode */
errn = exiDecodeStartDocument(&iStream, &stateDecode);
if (errn < 0) {
printf("[Decode-ERROR] %d \n", errn);
return errn;
}
printf(">> START_DOCUMENT \n");
/* encode */
errn = exiEncodeStartDocument(&oStream, &stateEncode);
break;
case END_DOCUMENT:
/* decode */
errn = exiDecodeEndDocument(&iStream, &stateDecode);
if (errn < 0) {
printf("[Decode-ERROR] %d \n", errn);
return errn;
}
printf(">> END_DOCUMENT \n");
/* encode */
errn = exiEncodeEndDocument(&oStream, &stateEncode);
/* signalize end of document */
noEndOfDocument = 0; /* false */
break;
case START_ELEMENT:
/* decode */
errn = exiDecodeStartElement(&iStream, &stateDecode, &eqn);
if (errn < 0) {
printf("[Decode-ERROR] %d \n", errn);
return errn;
}
exiGetLocalName(eqn.namespaceURI, eqn.localPart, &localName);
exiGetUri(eqn.namespaceURI, &namespaceURI);
printf(">> SE {%s}%s \n", namespaceURI, localName);
/* encode */
errn = exiEncodeStartElement(&oStream, &stateEncode, &eqn);
break;
case END_ELEMENT:
/* decode */
errn = exiDecodeEndElement(&iStream, &stateDecode, &eqn);
if (errn < 0) {
printf("[Decode-ERROR] %d \n", errn);
return errn;
}
exiGetLocalName(eqn.namespaceURI, eqn.localPart, &localName);
exiGetUri(eqn.namespaceURI, &namespaceURI);
printf("<< EE {%s}%s \n", namespaceURI, localName);
/* encode */
errn = exiEncodeEndElement(&oStream, &stateEncode, &eqn);
break;
case CHARACTERS:
/* decode */
errn = exiDecodeCharacters(&iStream, &stateDecode, &val);
if (errn < 0) {
printf("[Decode-ERROR] %d \n", errn);
return errn;
}
if (val.type == INTEGER_BIG) {
printf(" CH int64 : %ld \n", (long int)val.int64);
} else if (val.type == BINARY_BASE64 || val.type == BINARY_HEX) {
printf(" CH Binary (len == %d) : ", val.binary.len);
for(i=0; i<val.binary.len; i++) {
printf(" [%d]", val.binary.data[i]);
}
printf("\n");
} else if (val.type == BOOLEAN) {
printf(" CH Boolean : %d \n", val.boolean);
} else if (val.type == STRING) {
printf(" CH String (len==%d) : '", val.string.len);
for(i=0;i<val.string.len; i++) {
printf("%c", (char)val.string.codepoints[i]);
}
printf("'\n");
} else {
printf(" CH ?? \n");
}
/* encode */
errn = exiEncodeCharacters(&oStream, &stateEncode, &val);
break;
case ATTRIBUTE:
/* decode */
errn = exiDecodeAttribute(&iStream, &stateDecode, &eqn, &val);
if (errn < 0) {
printf("[Decode-ERROR] %d \n", errn);
return errn;
}
exiGetLocalName(eqn.namespaceURI, eqn.localPart, &localName);
exiGetUri(eqn.namespaceURI, &namespaceURI);
printf(" AT {%s}%s \n", namespaceURI, localName);
/* encode */
errn = exiEncodeAttribute(&oStream, &stateEncode, &eqn, &val);
break;
default:
/* ERROR */
return -1;
}
} while (noEndOfDocument);
/* write to file */
writeBytesToFile(oStream.data, posEncode, argv[2]);
return 0;
}

View file

@ -0,0 +1,142 @@
/*
* 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 <http://www.gnu.org/licenses/>.
*/
/*******************************************************************
*
* @author Sebastian.Kaebisch.EXT@siemens.com
* @version 0.3.1
* @contact Joerg.Heuer@siemens.com
*
********************************************************************/
#include "v2g_service.h"
#include "v2g_serviceDataTypes.h"
#include "v2g_serviceClientStubs.h"
#include "EXITypes.h"
#include "doIP.h"
#include <stdio.h>
#define MAX_BYTE_SIZE 128
#define MAX_STRING_SIZE 256
#define MAX_STREAM_SIZE 60
static void printErrorMessage(struct EXIService* service);
int main_service(int argc, char *argv[])
{
static uint8_t byte_array[MAX_BYTE_SIZE]; /* define MAX_BYTE_SIZE before*/
static uint32_t string_array[MAX_STRING_SIZE]; /* define MAX_STRING_SIZE before*/
/* define in and out byte stream */
uint8_t inStream[MAX_STREAM_SIZE]; /* define MAX_STREAM_SIZE before */
uint8_t outStream[MAX_STREAM_SIZE]; /* define MAX_STREAM_SIZE before */
/* define offset variable for transport header data */
uint16_t transportHeaderOffset;
/* service data structure */
struct EXIService service;
struct HeaderType v2gHeader;
struct SessionSetupReqType sessionSetup;
struct SessionSetupResType resultSessionSetup;
/*struct PowerDiscoveryReqType powerDiscovery;
struct PowerDiscoveryResType resultPowerDiscovery; */
/* BINARY memory setup */
bytes_t bytes = { MAX_BYTE_SIZE, byte_array, 0 };
/* STRING memory setup */
string_ucs_t string = { MAX_STRING_SIZE, string_array, 0 };
/* setup offset for DoIP header (otherwise set
* transportHeaderOffset=0 if no transfer protocol is used)*/
transportHeaderOffset = DOIP_HEADER_LENGTH;
printf("+++Start V2G Client / Service Example+++\n\n");
/*******************
* Init V2G Client *
*******************/
init_v2gServiceClient(&service,bytes,string,inStream,MAX_STREAM_SIZE, outStream, MAX_STREAM_SIZE, transportHeaderOffset);
/*******************************
* Setup data for sessionSetup *
*******************************/
/* setup header information */
v2gHeader.SessionInformation.SessionID.arraylen.data = 0; /* no session id in the initial message -> array length = 0*/
v2gHeader.SessionInformation.ProtocolVersion.data[0]='1'; /* assign protocol version number*/
v2gHeader.SessionInformation.ProtocolVersion.arraylen.data=1; /* array string length =1 of protocol version */
v2gHeader.SessionInformation.isused.ProtocolVersion = 1; /* important: signalize, protocol version is used */
v2gHeader.isused.Notification=0; /* no notification */
/* setup sessionSetup parameter */
sessionSetup.isused.PEVID=0; /* no PEVID is transported */
sessionSetup.PEVStatus.ChargerStandby=1; /* charger standby = true */
sessionSetup.PEVStatus.ConnectorLocked=0; /* connector locked = false */
printf("PEV: call EVSE sessionSetup\n");
/*********************
* Call sessionSetup *
*********************/
if(call_sessionSetup(&service,&v2gHeader,&sessionSetup,&resultSessionSetup))
{
printErrorMessage(&service);
}
else
{
/* show result of the answer message of EVSE sessionSetup*/
printf("PEV: received response message from EVSE\n");
printf("\tResponseCode=%d\n",resultSessionSetup.ResponseCode);
printf("\tEVSEID=%d\n", resultSessionSetup.EVSEID.data[0]);
printf("\tEVSEStatus:\n\t\tConnectorLocked=%d\n",resultSessionSetup.EVSEStatus.ConnectorLocked);
printf("\t\tEVSEStandby=%d\n",resultSessionSetup.EVSEStatus.EVSEStandby);
printf("\t\tFatalError=%d\n",resultSessionSetup.EVSEStatus.FatalError);
printf("\t\tPowerSwitchClosed=%d\n",resultSessionSetup.EVSEStatus.PowerSwitchClosed);
printf("\t\tRCD=%d\n",resultSessionSetup.EVSEStatus.RCD);
printf("\t\tShutDownTime=%d\n",resultSessionSetup.EVSEStatus.ShutDownTime);
printf("\tTCurrent=%d\n",resultSessionSetup.TCurrent);
}
printf("\n+++Terminate V2G Client / Service Example+++");
return 0;
}
static void printErrorMessage(struct EXIService* service)
{
if(service->errorCode==EXI_NON_VALID_MESSAGE)
{
printf("PEV did not send a valid V2G message!\n");
}
else if(service->errorCode==EXI_SERIALIZATION_FAILED)
{
printf("EVSE error: Could not serialize the response message\n");
}
}

View file

@ -0,0 +1,90 @@
/*
* 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 <http://www.gnu.org/licenses/>.
*/
/*******************************************************************
*
* @author Sebastian.Kaebisch.EXT@siemens.com
* @version 0.3.1
* @contact Joerg.Heuer@siemens.com
*
********************************************************************/
#include "v2g_server.h"
#include "v2g_service.h"
#include "v2g_serviceDispatcher.h"
#include "doIP.h"
#define MAX_BYTE_SIZE 128
#define MAX_STRING_SIZE 256
#define MAX_STREAM_SIZE 60
int testV2GService(uint8_t* inStream, uint16_t inStreamLength, uint8_t* outStream, uint16_t* outStreamLength)
{
static uint8_t byte_array[MAX_BYTE_SIZE]; /* define MAX_BYTE_SIZE before*/
static uint32_t string_array[MAX_STRING_SIZE]; /* define MAX_STRING_SIZE before*/
uint16_t exiMsgLength;
struct EXIService service;
/* BINARY memory setup */
bytes_t bytes = { MAX_BYTE_SIZE, byte_array, 0 };
/* STRING memory setup */
string_ucs_t string = { MAX_STRING_SIZE, string_array, 0 };
/**********************************************
* Init V2G server and initialize array types *
* for the EXI decoding as well as the offset *
* for the transportation header *
**********************************************/
init_v2gservice(&service, bytes, string, DOIP_HEADER_LENGTH);
/* check, if the DoIP header is correct and determine payload */
if(read_doIPHeader(inStream,inStreamLength, &exiMsgLength))
{
/* DoIP header not correct */
write_doIPNack(outStream, outStreamLength, service.errorCode);
return -1;
}
/****************************************************************************
* Pass the received EXI message stream (inStream + exiMsgLength) to the *
* v2g message dispatcher. The outStream contains the response message *
* stream. *
****************************************************************************/
if(messageDispatcher(&service, inStream, exiMsgLength, outStream, MAX_STREAM_SIZE, outStreamLength))
{
/* write DoIP failure */
write_doIPNack(outStream, outStreamLength, service.errorCode);
}
else
{
/* write DoIP header */
write_doIPHeader(outStream, outStreamLength, DOIP_EXI_TYPE);
}
return 0;
}

View file

@ -0,0 +1,33 @@
/*
* 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 <http://www.gnu.org/licenses/>.
*/
/*******************************************************************
*
* @author Sebastian.Kaebisch.EXT@siemens.com
* @version 0.3.1
* @contact Joerg.Heuer@siemens.com
*
********************************************************************/
#ifndef V2G_SERVER_H_
#define V2G_SERVER_H_
#include "EXITypes.h"
int testV2GService(uint8_t* inStream, uint16_t inStreamLength, uint8_t* outStream,uint16_t* outStreamLength);
#endif /* V2G_SERVER_H_ */

View file

@ -0,0 +1,47 @@
/*
* 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 <http://www.gnu.org/licenses/>.
*/
/*******************************************************************
*
* @author Sebastian.Kaebisch.EXT@siemens.com
* @version 0.3.1
* @contact Joerg.Heuer@siemens.com
*
********************************************************************/
#include "v2g_serviceClientDataTransmitter.h"
#include "v2g_server.h"
#include "doIP.h"
/* This method has to be implemented!
* Send EXI stream (outStream) to EVSE and receive response stream (inStream)*/
int serviceDataTransmitter(uint8_t* outStream, uint16_t outStreamLength, uint8_t* inStream)
{
/* send output stream to the underlying network to the EVSE and wait for response
* --> here provide data to the V2G server directly*/
uint16_t inStreamLength = 0;
uint16_t payloadLength = 0;
/* setup DoIP header information; outStreamLength==payloadLength*/
write_doIPHeader(outStream,&outStreamLength,DOIP_EXI_TYPE);
/* send data to EVSE server (add DoIP offset)*/
testV2GService(outStream, outStreamLength, inStream, &inStreamLength);
return read_doIPHeader(inStream,inStreamLength, &payloadLength);
}

View file

@ -0,0 +1,95 @@
/*
* 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 <http://www.gnu.org/licenses/>.
*/
/*******************************************************************
*
* @author Sebastian.Kaebisch.EXT@siemens.com
* @version 0.3.1
* @contact Joerg.Heuer@siemens.com
*
********************************************************************/
#include "v2g_serviceMethods.h"
#include "v2g_serviceDataTypes.h"
#include <stdio.h>
/* This service methods has to be implemented by the EVSE server */
int sessionSetup(struct SessionSetupReqType* param, struct SessionSetupResType* result)
{
printf("EVSE: sessionSetup called\n" );
printf("\tReceived data:\n");
printf("\t\t PEVStatus ChargerStandby=%d\n",param->PEVStatus.ChargerStandby);
printf("\t\t PEVStatus ConnectorLocked=%d\n", param->PEVStatus.ConnectorLocked);
/* Prepare data for PEV */
result->ResponseCode = OK_SessionSetup_responseCode_SessionSetupType;
result->EVSEID.data[0]='E';
result->EVSEID.arraylen.data=1;
result->EVSEStatus.ConnectorLocked=0;
result->EVSEStatus.EVSEStandby=1;
result->EVSEStatus.FatalError=0;
result->EVSEStatus.PowerSwitchClosed=1;
result->EVSEStatus.RCD=1;
result->EVSEStatus.ShutDownTime=12345678L;
result->TCurrent=12345678L;
return 0;
}
int serviceDiscovery(struct ServiceDiscoveryReqType* param, struct ServiceDiscoveryResType* result)
{
return 0;
}
int selectedServicePayment(struct ServicePaymentSelectionReqType* param, struct ServicePaymentSelectionResType* result)
{
return 0;
}
int paymentDetails(struct PaymentDetailsReqType* param, struct PaymentDetailsResType* result)
{
return 0;
}
int powerDiscovery(struct PowerDiscoveryReqType* param, struct PowerDiscoveryResType* result)
{
return 0;
}
int lineLock(struct LineLockReqType* param, struct LineLockResType* result)
{
return 0;
}
int powerDelivery(struct PowerDeliveryReqType* param, struct PowerDeliveryResType* result)
{
return 0;
}
int meteringStatus(struct MeteringStatusReqType* param, struct MeteringStatusResType* result)
{
return 0;
}
int meteringReceipt(struct MeteringReceiptReqType* param, struct MeteringReceiptResType* result)
{
return 0;
}

View file

@ -0,0 +1,117 @@
/*
* 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 <http://www.gnu.org/licenses/>.
*/
/*******************************************************************
*
* @author Sebastian.Kaebisch.EXT@siemens.com
* @version 0.3.1
* @contact Joerg.Heuer@siemens.com
*
********************************************************************/
/*
* This file implements the DoIP header writer and reader.
* Note: Not all functions are implemented yet.
*
*/
#include <stdint.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include "doIP.h"
int write_doIPNack(uint8_t* outStream, uint16_t* outStreamLength, uint8_t nackCode)
{
/* if(outStreamLength<DOIP_HEADER_LENGTH+1)
return -1;*/
/* payload length=1 and nack payload type*/
*outStreamLength = 1;
write_doIPHeader(outStream,outStreamLength, DOIP_NEGATIVE_ACKNOWLEDGE);
outStream[8]=nackCode;
return 0;
}
int write_doIPHeader(uint8_t* outStream, uint16_t* outStreamLength, uint16_t payloadType)
{
/* write DoIP version number 1=byte */
outStream[0]=DOIP_VERSION;
/* write inverse DoIP version */
outStream[1]=DOIP_VERSION_INV;
/* write payload type */
outStream[2] = (uint8_t)(payloadType & 0xFF);
outStream[3] = (uint8_t)(payloadType >> 8 & 0xFF);
/* write payload length */
outStream[4] = (uint8_t)(*outStreamLength & 0xFF);
outStream[5] = (uint8_t)(*outStreamLength>>8 & 0xFF);
outStream[6] = (uint8_t)(*outStreamLength>>16 & 0xFF);
outStream[7] = (uint8_t)(*outStreamLength>>24 & 0xFF);
/* here, the outStream length have to be resized by the DoIP offset*/
*outStreamLength += DOIP_HEADER_LENGTH;
return 0;
}
int read_doIPHeader(uint8_t* inStream, uint16_t inStreamLength, uint16_t* payloadLength)
{
uint16_t payloadType=0;
/* check, if we support this DoIP version */
if(inStream[0]!=DOIP_VERSION && inStream[1]!=DOIP_VERSION_INV)
return DOIP_INCORRECT_PATTERN_FORMAT;
/* check, if we support this payload type*/
payloadType = inStream[3];
payloadType = (payloadType << 8 | inStream[2]);
if(payloadType != DOIP_EXI_TYPE && payloadType != DOIP_NEGATIVE_ACKNOWLEDGE)
return DOIP_UNKNOWN_PAYLOAD_TYPE;
/* determine payload length*/
*payloadLength = inStream[7];
*payloadLength = (*payloadLength << 8 | inStream[6]);
*payloadLength = (*payloadLength << 16 | inStream[5]);
*payloadLength = (*payloadLength << 24 | inStream[4]);
if((*payloadLength+DOIP_HEADER_LENGTH)!=inStreamLength)
return DOIP_INVALID_PAYLOAD_LENGTH;
/* if payload is a NACK read its NACK code and return it*/
/* TODO: should be handled by an extra method */
if(payloadType == DOIP_NEGATIVE_ACKNOWLEDGE)
return inStream[8];
return 0;
}

View file

@ -0,0 +1,68 @@
/*
* 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 <http://www.gnu.org/licenses/>.
*/
/*******************************************************************
*
* @author Sebastian.Kaebisch.EXT@siemens.com
* @version 0.3.1
* @contact Joerg.Heuer@siemens.com
*
********************************************************************/
#ifdef __cplusplus
extern "C" {
#endif
#ifndef DOIP_H_
#define DOIP_H_
/* generic DoIP header length */
#define DOIP_HEADER_LENGTH 8
/* define DoIP Version */
#define DOIP_VERSION 0x01
#define DOIP_VERSION_INV 0xFE
/* define DoIP payload types*/
#define DOIP_NEGATIVE_ACKNOWLEDGE 0x0000
#define DOIP_EXI_TYPE 0xC350 /* == 50000 */
/* Generic DoIP Header NACK codes */
#define DOIP_INCORRECT_PATTERN_FORMAT 0x00
#define DOIP_UNKNOWN_PAYLOAD_TYPE 0x01
#define DOIP_MESSAGE_TOO_LARGE 0x02
#define DOIP_OUT_OF_MEMORY 0x03
#define DOIP_INVALID_PAYLOAD_LENGTH 0x04
/* EXI NACK code */
#define DOIP_INVALID_EXI_MESSAGE 0x05
/* DoIP methods */
int write_doIPNack(uint8_t* outStream, uint16_t* outStreamLength, uint8_t nackCode);
int write_doIPHeader(uint8_t* outStream, uint16_t* outStreamLength, uint16_t payloadType);
int read_doIPHeader(uint8_t* inStream, uint16_t inStreamLength, uint16_t* payloadLength);
#endif /* DOIP_H_ */
#ifdef __cplusplus
}
#endif

1112
tags/release_0.3/.cproject Normal file

File diff suppressed because it is too large Load diff

69
tags/release_0.3/.project Normal file
View file

@ -0,0 +1,69 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>OpenV2G</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
<triggers>clean,full,incremental,</triggers>
<arguments>
<dictionary>
<key>?name?</key>
<value></value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.append_environment</key>
<value>true</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.buildArguments</key>
<value></value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.buildCommand</key>
<value>make</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.buildLocation</key>
<value>${workspace_loc:/OpenV2G/Debug}</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.contents</key>
<value>org.eclipse.cdt.make.core.activeConfigSettings</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.enableAutoBuild</key>
<value>false</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.enableCleanBuild</key>
<value>true</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.enableFullBuild</key>
<value>true</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.stopOnError</key>
<value>true</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.useDefaultBuildCmd</key>
<value>true</value>
</dictionary>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.cdt.core.cnature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
</natures>
</projectDescription>

View file

@ -0,0 +1,165 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
This version of the GNU Lesser General Public License incorporates
the terms and conditions of version 3 of the GNU General Public
License, supplemented by the additional permissions listed below.
0. Additional Definitions.
As used herein, "this License" refers to version 3 of the GNU Lesser
General Public License, and the "GNU GPL" refers to version 3 of the GNU
General Public License.
"The Library" refers to a covered work governed by this License,
other than an Application or a Combined Work as defined below.
An "Application" is any work that makes use of an interface provided
by the Library, but which is not otherwise based on the Library.
Defining a subclass of a class defined by the Library is deemed a mode
of using an interface provided by the Library.
A "Combined Work" is a work produced by combining or linking an
Application with the Library. The particular version of the Library
with which the Combined Work was made is also called the "Linked
Version".
The "Minimal Corresponding Source" for a Combined Work means the
Corresponding Source for the Combined Work, excluding any source code
for portions of the Combined Work that, considered in isolation, are
based on the Application, and not on the Linked Version.
The "Corresponding Application Code" for a Combined Work means the
object code and/or source code for the Application, including any data
and utility programs needed for reproducing the Combined Work from the
Application, but excluding the System Libraries of the Combined Work.
1. Exception to Section 3 of the GNU GPL.
You may convey a covered work under sections 3 and 4 of this License
without being bound by section 3 of the GNU GPL.
2. Conveying Modified Versions.
If you modify a copy of the Library, and, in your modifications, a
facility refers to a function or data to be supplied by an Application
that uses the facility (other than as an argument passed when the
facility is invoked), then you may convey a copy of the modified
version:
a) under this License, provided that you make a good faith effort to
ensure that, in the event an Application does not supply the
function or data, the facility still operates, and performs
whatever part of its purpose remains meaningful, or
b) under the GNU GPL, with none of the additional permissions of
this License applicable to that copy.
3. Object Code Incorporating Material from Library Header Files.
The object code form of an Application may incorporate material from
a header file that is part of the Library. You may convey such object
code under terms of your choice, provided that, if the incorporated
material is not limited to numerical parameters, data structure
layouts and accessors, or small macros, inline functions and templates
(ten or fewer lines in length), you do both of the following:
a) Give prominent notice with each copy of the object code that the
Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the object code with a copy of the GNU GPL and this license
document.
4. Combined Works.
You may convey a Combined Work under terms of your choice that,
taken together, effectively do not restrict modification of the
portions of the Library contained in the Combined Work and reverse
engineering for debugging such modifications, if you also do each of
the following:
a) Give prominent notice with each copy of the Combined Work that
the Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the Combined Work with a copy of the GNU GPL and this license
document.
c) For a Combined Work that displays copyright notices during
execution, include the copyright notice for the Library among
these notices, as well as a reference directing the user to the
copies of the GNU GPL and this license document.
d) Do one of the following:
0) Convey the Minimal Corresponding Source under the terms of this
License, and the Corresponding Application Code in a form
suitable for, and under terms that permit, the user to
recombine or relink the Application with a modified version of
the Linked Version to produce a modified Combined Work, in the
manner specified by section 6 of the GNU GPL for conveying
Corresponding Source.
1) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (a) uses at run time
a copy of the Library already present on the user's computer
system, and (b) will operate properly with a modified version
of the Library that is interface-compatible with the Linked
Version.
e) Provide Installation Information, but only if you would otherwise
be required to provide such information under section 6 of the
GNU GPL, and only to the extent that such information is
necessary to install and execute a modified version of the
Combined Work produced by recombining or relinking the
Application with a modified version of the Linked Version. (If
you use option 4d0, the Installation Information must accompany
the Minimal Corresponding Source and Corresponding Application
Code. If you use option 4d1, you must provide the Installation
Information in the manner specified by section 6 of the GNU GPL
for conveying Corresponding Source.)
5. Combined Libraries.
You may place library facilities that are a work based on the
Library side by side in a single library together with other library
facilities that are not Applications and are not covered by this
License, and convey such a combined library under terms of your
choice, if you do both of the following:
a) Accompany the combined library with a copy of the same work based
on the Library, uncombined with any other library facilities,
conveyed under the terms of this License.
b) Give prominent notice with the combined library that part of it
is a work based on the Library, and explaining where to find the
accompanying uncombined form of the same work.
6. Revised Versions of the GNU Lesser General Public License.
The Free Software Foundation may publish revised and/or new versions
of the GNU Lesser General Public License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the
Library as you received it specifies that a certain numbered version
of the GNU Lesser General Public License "or any later version"
applies to it, you have the option of following the terms and
conditions either of that published version or of any later version
published by the Free Software Foundation. If the Library as you
received it does not specify a version number of the GNU Lesser
General Public License, you may choose any version of the GNU Lesser
General Public License ever published by the Free Software Foundation.
If the Library as you received it specifies that a proxy can decide
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.

View file

@ -0,0 +1,51 @@
-------------------------------------------------------------------------
OpenV2G - an open source project implementing the basic functionality of the ISO IEC 15118 vehicle to grid (V2G) communication interface
Version 0.3, released October 27, 2010
http://openv2g.sourceforge.net/
Please report bugs via the SourceForge bug tracking system at http://sourceforge.net/tracker/?group_id=350113.
Thank you.
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 <http://www.gnu.org/licenses/>.
-------------------------------------------------------------------------
CHANGES from version 0.2.2:
-------------------------------------------------------------------------
* Bug-fixes
* first DoIP implementation
* V2G message error handling
* adaption of V2G schema changes
* code optimizations
-------------------------------------------------------------------------
CHANGES from version 0.2.1:
-------------------------------------------------------------------------
* Bug-fixes
* adaption of V2G schema changes
* some code optimizations
-------------------------------------------------------------------------
CHANGES from version 0.2:
-------------------------------------------------------------------------
* Bug-fixes
* Fixed compiler warnings
-------------------------------------------------------------------------
CHANGES from version 0.1:
-------------------------------------------------------------------------
* Bug-fixes
* Service and Client added

View file

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<ns3:V2G_Message xmlns:ns1="urn:iso:15118:2:2010:MsgBody"
xmlns:ns2="urn:iso:15118:2:2010:MsgDataTypes"
xmlns:ns3="urn:iso:15118:2:2010:MsgDef"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:iso:15118:2:2010:MsgDef V2G_CI_MsgDef.xsd">
<ns3:Header>
<ns3:SessionInformation>
<ns2:SessionID>3031323334353637</ns2:SessionID>
<ns2:ProtocolVersion>1</ns2:ProtocolVersion>
</ns3:SessionInformation>
</ns3:Header>
<ns3:Body>
<ns1:SessionSetupReq>
<ns1:PEVStatus>
<ns2:ConnectorLocked>0</ns2:ConnectorLocked>
<ns2:ChargerStandby>1</ns2:ChargerStandby>
</ns1:PEVStatus>
</ns1:SessionSetupReq>
</ns3:Body>
</ns3:V2G_Message>

View file

@ -0,0 +1 @@
<EFBFBD>˜A<EFBFBD>™¡©±ºc<>

View file

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<v2gci_d:V2G_Message xmlns:v2gci_d="urn:iso:15118:2:2010:MsgDef"
xmlns:v2gci_t="urn:iso:15118:2:2010:MsgDataTypes"
xmlns:ns0="urn:iso:15118:2:2010:MsgBody"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:iso:15118:2:2010:MsgDef V2G_CI_MsgDef.xsd">
<v2gci_d:Header>
<v2gci_d:SessionInformation>
<v2gci_t:SessionID>0Fb80Fb80Fb80Fb8</v2gci_t:SessionID>
<v2gci_t:ProtocolVersion>1</v2gci_t:ProtocolVersion>
</v2gci_d:SessionInformation>
</v2gci_d:Header>
<v2gci_d:Body>
<ns0:SessionSetupRes>
<ns0:ResponseCode>OK_SessionSetup</ns0:ResponseCode>
<ns0:EVSEID>54</ns0:EVSEID>
<ns0:EVSEStatus>
<v2gci_t:FatalError>0</v2gci_t:FatalError>
<v2gci_t:EVSEStandby>1</v2gci_t:EVSEStandby>
<v2gci_t:ConnectorLocked>1</v2gci_t:ConnectorLocked>
<v2gci_t:PowerSwitchClosed>0</v2gci_t:PowerSwitchClosed>
<v2gci_t:RCD>1</v2gci_t:RCD>
<v2gci_t:ShutDownTime>123456789</v2gci_t:ShutDownTime>
</ns0:EVSEStatus>
<ns0:TCurrent>123456789</ns0:TCurrent>
</ns0:SessionSetupRes>
</v2gci_d:Body>
</v2gci_d:V2G_Message>

View file

@ -0,0 +1 @@
<EFBFBD>˜@}À}À}À}Âc<>TjVk¼é+5Þt

View file

@ -0,0 +1,257 @@
/*
* 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 <http://www.gnu.org/licenses/>.
*/
/*******************************************************************
*
* @author Daniel.Peintner.EXT@siemens.com
* @version 0.3
* @contact Joerg.Heuer@siemens.com
*
* Bit decoding functionalities
*
********************************************************************/
#include <stdlib.h>
#include <stdint.h>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include "BitDecoderChannel.h"
#include "BitInputStream.h"
#include "EXITypes.h"
#ifndef BIT_DECODER_CHANNEL_C
#define BIT_DECODER_CHANNEL_C
int decode(bitstream_t* stream, uint8_t* b) {
return readBits(stream, 8, b);
}
int decodeBoolean(bitstream_t* stream, int* b) {
uint8_t ub;
int errn = readBits(stream, 1, &ub);
*b = (ub == 0) ? 0 : 1;
return errn;
}
int decodeNBitUnsignedInteger(bitstream_t* stream, size_t nbits, uint8_t* uint8) {
if (nbits == 0) {
*uint8 = 0;
return 0;
} else {
return readBits(stream, nbits, uint8);
}
}
int decodeUnsignedInteger32(bitstream_t* stream, uint32_t* uint32) {
/* 0XXXXXXX ... 1XXXXXXX 1XXXXXXX */
unsigned int mShift = 0;
int errn = 0;
uint8_t b;
*uint32 = 0;
do {
/* 1. Read the next octet */
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
* the current value */
*uint32 += (b & 127) << mShift;
/* 3. Multiply the multiplier by 128 */
mShift += 7;
/* 4. If the most significant bit of the octet was 1, go back to step 1 */
} while (errn >= 0 && (b >> 7) == 1);
return errn;
}
/**
* Decode an arbitrary precision non negative integer using a sequence of
* octets. The most significant bit of the last octet is set to zero to
* indicate sequence termination. Only seven bits per octet are used to
* store the integer's value.
*/
int decodeUnsignedInteger64(bitstream_t* stream, uint64_t* uint64) {
unsigned int mShift = 0;
int errn = 0;
uint8_t b;
*uint64 = 0L;
do {
errn = decode(stream, &b);
*uint64 += ((uint64_t) (b & 127)) << mShift;
mShift += 7;
} while (errn >= 0 && (b >> 7) == 1);
return errn;
}
/**
* Decode an arbitrary precision integer using a sign bit followed by a
* sequence of octets. The most significant bit of the last octet is set to
* zero to indicate sequence termination. Only seven bits per octet are used
* to store the integer's value.
*/
int decodeInteger32(bitstream_t* stream, int32_t* int32) {
int b;
uint32_t uint32;
int errn = decodeBoolean(stream, &b);
if (errn < 0) {
return errn;
}
if (b) {
/* For negative values, the Unsigned Integer holds the
* magnitude of the value minus 1 */
errn = decodeUnsignedInteger32(stream, &uint32);
*int32 = -(uint32 + 1);
} else {
/* positive */
errn = decodeUnsignedInteger32(stream, &uint32);
*int32 = (int32_t)(uint32);
}
return errn;
}
/**
* Decode an arbitrary precision integer using a sign bit followed by a
* sequence of octets. The most significant bit of the last octet is set to
* zero to indicate sequence termination. Only seven bits per octet are used
* to store the integer's value.
*/
int decodeInteger64(bitstream_t* stream, int64_t* int64) {
int b;
uint64_t uint64;
int errn = decodeBoolean(stream, &b);
if (errn < 0) {
return errn;
}
if (b) {
/* For negative values, the Unsigned Integer holds the
* magnitude of the value minus 1 */
errn = decodeUnsignedInteger64(stream, &uint64);
*int64 = -(uint64 + 1);
} else {
/* positive */
errn = decodeUnsignedInteger64(stream, &uint64);
*int64 = (int64_t)(uint64);
}
return errn;
}
/**
* Decode a Float datatype as two consecutive Integers.
* The first Integer represents the mantissa of the floating point
* number and the second Integer represents the base-10 exponent
* of the floating point number.
*/
int decodeFloat(bitstream_t* stream, float_me_t* f) {
int errn = decodeInteger64(stream, &f->mantissa);
if (errn < 0) {
return errn;
}
return decodeInteger32(stream, &f->exponent);
}
/**
* Decode a sequence of characters for a given length.
*/
int decodeStringOnly(bitstream_t* stream, size_t len, string_ucs_t* s) {
decodeCharacters(stream, len, s->codepoints);
s->len = len;
return 0;
}
/**
* Decode a length prefixed sequence of characters.
*/
int decodeString(bitstream_t* stream, string_ucs_t* s) {
int errn = decodeUnsignedInteger32(stream, &s->len);
if (errn < 0) {
return errn;
}
return decodeStringOnly(stream, s->len, s);
}
int decodeStringValue(bitstream_t* stream, string_ucs_t* s) {
int errn = decodeUnsignedInteger32(stream, &s->len);
if (errn < 0) {
return errn;
}
switch (s->len) {
case 0:
/* local value partition */
printf("[ERROR] String local value partition hit not supported \n");
return -2;
case 1:
/* found in global value partition */
printf("[ERROR] String global value partition hit not supported \n");
return -3;
default:
/* not found in global value (and local value) partition
* ==> string literal is encoded as a String with the length
* incremented by two */
return decodeStringOnly(stream, ((s->len) - 2), s);
/* After encoding the string value, it is added to both the
* associated "local" value string table partition and the global
* value string table partition */
/* addValue(context, value); */
}
}
/**
* Decode a sequence of characters according to a given length.
* Each character is represented by its UCS [ISO/IEC 10646]
* code point encoded as an Unsigned Integer
*/
int decodeCharacters(bitstream_t* stream, size_t len, uint32_t* chars) {
unsigned int i;
int errn = 0;
for (i = 0; i < len && errn >= 0; i++) {
errn = decodeUnsignedInteger32(stream, &chars[i]);
}
return errn;
}
/**
* Decode a binary value as a length-prefixed sequence of octets.
*/
int decodeBinary(bitstream_t* stream, bytes_t* bytes) {
unsigned int i;
int errn = decodeUnsignedInteger32(stream, &bytes->len);
if (errn < 0) {
return errn;
}
for (i = 0; i < bytes->len && errn >= 0; i++) {
errn = decode(stream, &bytes->data[i]);
}
return errn;
}
#endif

View file

@ -0,0 +1,117 @@
/*
* 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 <http://www.gnu.org/licenses/>.
*/
/*******************************************************************
*
* @author Daniel.Peintner.EXT@siemens.com
* @version 0.3
* @contact Joerg.Heuer@siemens.com
*
********************************************************************/
#ifdef __cplusplus
extern "C" {
#endif
#include "EXITypes.h"
#ifndef BIT_DECODER_CHANNEL_H
#define BIT_DECODER_CHANNEL_H
/**
* Decode a single boolean value. The value false is represented by the bit
* 0, and the value true is represented by the bit 1.
*/
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);
/**
* Decode an arbitrary precision non negative integer using a sequence of
* octets. The most significant bit of the last octet is set to zero to
* indicate sequence termination. Only seven bits per octet are used to
* store the integer's value.
*/
int decodeUnsignedInteger32(bitstream_t* stream, uint32_t* uint32);
/**
* Decode an arbitrary precision non negative integer using a sequence of
* octets. The most significant bit of the last octet is set to zero to
* indicate sequence termination. Only seven bits per octet are used to
* store the integer's value.
*/
int decodeUnsignedInteger64(bitstream_t* stream, uint64_t* uint64);
/**
* Decode an arbitrary precision integer using a sign bit followed by a
* sequence of octets. The most significant bit of the last octet is set to
* zero to indicate sequence termination. Only seven bits per octet are used
* to store the integer's value.
*/
int decodeInteger32(bitstream_t* stream, int32_t* int32);
/**
* Decode an arbitrary precision integer using a sign bit followed by a
* sequence of octets. The most significant bit of the last octet is set to
* zero to indicate sequence termination. Only seven bits per octet are used
* to store the integer's value.
*/
int decodeInteger64(bitstream_t* stream, int64_t* int64);
/**
* Decode a Float datatype as two consecutive Integers.
* The first Integer represents the mantissa of the floating point
* number and the second Integer represents the base-10 exponent
* of the floating point number.
*/
int decodeFloat(bitstream_t* stream, float_me_t* f);
/**
* Decode a length prefixed sequence of characters.
*/
int decodeString(bitstream_t* stream, string_ucs_t* s);
/**
* Decode a length prefixed sequence of characters in the sense of string tables.
* length == 0, local value partition hit
* length == 1, global value partition hit
* --> string literal is encoded as a String with the length incremented by two
*/
int decodeStringValue(bitstream_t* stream, string_ucs_t* s);
/**
* Decode a sequence of characters according to a given length.
*/
int decodeCharacters(bitstream_t* stream, size_t len, uint32_t* chars);
/**
* Decode a binary value as a length-prefixed sequence of octets.
*/
int decodeBinary(bitstream_t* stream, bytes_t* bytes);
#endif
#ifdef __cplusplus
}
#endif

View file

@ -0,0 +1,298 @@
/*
* 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 <http://www.gnu.org/licenses/>.
*/
/*******************************************************************
*
* @author Daniel.Peintner.EXT@siemens.com
* @version 0.3
* @contact Joerg.Heuer@siemens.com
*
********************************************************************/
#include <stdio.h>
#include <string.h>
#include <stdint.h>
#include "BitEncoderChannel.h"
#include "BitOutputStream.h"
#include "EXITypes.h"
#ifndef BIT_ENCODER_CHANNEL_C
#define BIT_ENCODER_CHANNEL_C
/**
* Returns the least number of 7 bit-blocks that is needed to represent the
* int <param>n</param>. Returns 1 if <param>n</param> is 0.
*
* @param n
* integer value
*
*/
uint8_t numberOf7BitBlocksToRepresent(int n) {
/* assert (n >= 0); */
/* 7 bits */
if (n < 128) {
return 1;
}
/* 14 bits */
else if (n < 16384) {
return 2;
}
/* 21 bits */
else if (n < 2097152) {
return 3;
}
/* 28 bits */
else if (n < 268435456) {
return 4;
}
/* 35 bits */
else {
/* int, 32 bits */
return 5;
}
}
int encode(bitstream_t* stream, uint8_t b) {
return writeBits(stream, 8, b);
}
/**
* Encode a single boolean value. A false value is encoded as bit 0 and true
* value is encode as bit 1.
*/
int encodeBoolean(bitstream_t* stream, int b) {
uint8_t val = b ? 1 : 0;
return writeBits(stream, 1, val);
}
/**
* 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, size_t nbits, uint8_t val) {
return writeBits(stream, nbits, val);
}
/**
* Encode an arbitrary precision non negative integer using a sequence of
* octets. The most significant bit of the last octet is set to zero to
* indicate sequence termination. Only seven bits per octet are used to
* store the integer's value.
*/
int encodeUnsignedInteger32(bitstream_t* stream, uint32_t n) {
int errn = 0;
if (n < 128) {
/* write byte as is */
errn = encode(stream, (uint8_t)n);
} else {
uint8_t n7BitBlocks = numberOf7BitBlocksToRepresent(n);
switch (n7BitBlocks) {
case 5:
errn = encode(stream, (uint8_t)(128 | n));
n = n >> 7;
if (errn < 0) {
break;
}
case 4:
errn = encode(stream, (uint8_t)(128 | n));
n = n >> 7;
if (errn < 0) {
break;
}
case 3:
errn = encode(stream, (uint8_t)(128 | n));
n = n >> 7;
if (errn < 0) {
break;
}
case 2:
errn = encode(stream, (uint8_t)(128 | n));
n = n >> 7;
if (errn < 0) {
break;
}
case 1:
/* 0 .. 7 (last byte) */
errn = encode(stream, (uint8_t)(0 | n));
}
}
return errn;
}
/**
* Encode an arbitrary precision non negative integer using a sequence of
* octets. The most significant bit of the last octet is set to zero to
* indicate sequence termination. Only seven bits per octet are used to
* store the integer's value.
*/
int encodeUnsignedInteger64(bitstream_t* stream, uint64_t n) {
int errn = 0;
uint8_t lastEncode = (uint8_t) n;
n >>= 7;
while (n != 0) {
errn = encode(stream, lastEncode | 128);
if (errn < 0) {
return errn;
}
lastEncode = (uint8_t) n;
n >>= 7;
}
return encode(stream, lastEncode);
}
/**
* Encode an arbitrary precision integer using a sign bit followed by a
* sequence of octets. The most significant bit of the last octet is set to
* zero to indicate sequence termination. Only seven bits per octet are used
* to store the integer's value.
*/
int encodeInteger32(bitstream_t* stream, int32_t n) {
int errn;
/* signalize sign */
if (n < 0) {
errn = encodeBoolean(stream, 1);
/* For negative values, the Unsigned Integer holds the
* magnitude of the value minus 1 */
n = (-n) - 1;
} else {
errn = encodeBoolean(stream, 0);
}
if (errn < 0) {
return errn;
}
return encodeUnsignedInteger32(stream, n);
}
/**
* Encode an arbitrary precision integer using a sign bit followed by a
* sequence of octets. The most significant bit of the last octet is set to
* zero to indicate sequence termination. Only seven bits per octet are used
* to store the integer's value.
*/
int encodeInteger64(bitstream_t* stream, int64_t n) {
int errn;
/* signalize sign */
if (n < 0) {
errn = encodeBoolean(stream, 1);
/* For negative values, the Unsigned Integer holds the
* magnitude of the value minus 1 */
n = (-n) - 1;
} else {
errn = encodeBoolean(stream, 0);
}
if (errn < 0) {
return errn;
}
return encodeUnsignedInteger64(stream, n);
}
/**
* The Float datatype representation is two consecutive Integers.
* The first Integer represents the mantissa of the floating point
* number and the second Integer represents the base-10 exponent
* of the floating point number.
*/
int encodeFloat(bitstream_t* stream, float_me_t* f) {
int errn = encodeInteger64(stream, f->mantissa);
if (errn >= 0) {
errn = encodeInteger32(stream, f->exponent);
}
return errn;
}
/**
* Encode a length prefixed sequence of characters.
*/
int encodeString(bitstream_t* stream, string_ucs_t* string) {
int errn = encodeUnsignedInteger32(stream, string->len);
if (errn >= 0) {
errn = encodeCharacters(stream, string->codepoints, string->len);
}
return errn;
}
int encodeStringValue(bitstream_t* stream, string_ucs_t* string) {
/* encode string as string table miss */
int errn = encodeUnsignedInteger32(stream, string->len+2);
if (errn >= 0) {
errn = encodeCharacters(stream, string->codepoints, string->len);
}
return errn;
}
/**
* Encode a sequence of characters according to a given length.
* Each character is represented by its UCS [ISO/IEC 10646]
* code point encoded as an Unsigned Integer
*/
int encodeCharacters(bitstream_t* stream, uint32_t* chars, size_t len) {
unsigned int i;
int errn = 0;
for(i=0; i<len && errn>=0; i++) {
errn = encodeUnsignedInteger32(stream, chars[i]);
}
return errn;
}
/**
* Encode a binary value as a length-prefixed sequence of octets.
*/
int encodeBinary(bitstream_t* stream, bytes_t* bytes) {
unsigned int i;
int errn = encodeUnsignedInteger32(stream, bytes->len);
for(i=0; i<bytes->len && errn>=0; i++) {
errn = encode(stream, bytes->data[i]);
}
return errn;
}
/**
* Flush underlying bit output stream.
*/
int encodeFinish(bitstream_t* stream) {
return flush(stream);
}
#endif

View file

@ -0,0 +1,133 @@
/*
* 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 <http://www.gnu.org/licenses/>.
*/
/*******************************************************************
*
* @author Daniel.Peintner.EXT@siemens.com
* @version 0.3
* @contact Joerg.Heuer@siemens.com
*
********************************************************************/
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include "EXITypes.h"
#ifndef BIT_ENCODER_CHANNEL_H
#define BIT_ENCODER_CHANNEL_H
/**
* Encode a single boolean value. A false value is encoded as bit 0 and true
* value is encode as bit 1.
*/
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, size_t nbits, uint8_t val);
/**
* Encode an arbitrary precision non negative integer using a sequence of
* octets. The most significant bit of the last octet is set to zero to
* indicate sequence termination. Only seven bits per octet are used to
* store the integer's value.
*/
int encodeUnsignedInteger32(bitstream_t* stream, uint32_t n);
/**
* Encode an arbitrary precision non negative integer using a sequence of
* octets. The most significant bit of the last octet is set to zero to
* indicate sequence termination. Only seven bits per octet are used to
* store the integer's value.
*/
int encodeUnsignedInteger64(bitstream_t* stream, uint64_t n);
/**
* Encode an arbitrary precision integer using a sign bit followed by a
* sequence of octets. The most significant bit of the last octet is set to
* zero to indicate sequence termination. Only seven bits per octet are used
* to store the integer's value.
*/
int encodeInteger32(bitstream_t* stream, int32_t n);
/**
* Encode an arbitrary precision integer using a sign bit followed by a
* sequence of octets. The most significant bit of the last octet is set to
* zero to indicate sequence termination. Only seven bits per octet are used
* to store the integer's value.
*/
int encodeInteger64(bitstream_t* stream, int64_t n);
/**
* Encode a Float datatype as two consecutive Integers.
* The first Integer represents the mantissa of the floating point
* number and the second Integer represents the base-10 exponent
* of the floating point number.
*/
int encodeFloat(bitstream_t* stream, float_me_t* f);
/**
* Encode a length prefixed sequence of characters.
*/
int encodeString(bitstream_t* stream, string_ucs_t* string);
/**
* Encode a length prefixed sequence of characters in the sense of string tables
*/
int encodeStringValue(bitstream_t* stream, string_ucs_t* string);
/**
* Encode a sequence of characters according to a given length.
* Each character is represented by its UCS [ISO/IEC 10646]
* code point encoded as an Unsigned Integer
*/
int encodeCharacters(bitstream_t* stream, uint32_t* chars, size_t len);
/**
* Encode a binary value as a length-prefixed sequence of octets.
*/
int encodeBinary(bitstream_t* stream, bytes_t* bytes);
/**
* Flush underlying bit output stream
*/
int encodeFinish(bitstream_t* stream);
#endif
#ifdef __cplusplus
}
#endif

View file

@ -0,0 +1,100 @@
/*
* 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 <http://www.gnu.org/licenses/>.
*/
/*******************************************************************
*
* @author Daniel.Peintner.EXT@siemens.com
* @version 0.3
* @contact Joerg.Heuer@siemens.com
*
********************************************************************/
#include <stdio.h>
#include <string.h>
#include <stdint.h>
#include "EXITypes.h"
#include "BitInputStream.h"
#ifndef BIT_INPUT_STREAM_C
#define BIT_INPUT_STREAM_C
/* internal method to (re)fill buffer */
int readBuffer(bitstream_t* stream)
{
int errn = 0;
if(stream->capacity==0)
{
if ( (*stream->pos) < stream->size ) {
stream->buffer = stream->data[(*stream->pos)++];
stream->capacity = BITS_IN_BYTE;
} else {
errn = -1;
}
}
return errn;
}
int readBits(bitstream_t* stream, size_t num_bits, uint8_t* b)
{
int errn = readBuffer(stream);
if (errn < 0) {
return errn;
}
/* read the bits in one step */
if(num_bits <= stream->capacity)
{
stream->capacity -= num_bits;
*b = (stream->buffer >> stream->capacity) & (0xff >> (BITS_IN_BYTE - num_bits));
}
else
{
/* read bits as much as possible */
*b = stream->buffer & (0xff >> (BITS_IN_BYTE - stream->capacity));
num_bits -= stream->capacity;
stream->capacity = 0;
/* read whole bytes */
while(num_bits >= 8)
{
errn = readBuffer(stream);
if (errn < 0) {
return errn;
}
*b = ((*b) << BITS_IN_BYTE) | stream->buffer;
num_bits -= BITS_IN_BYTE;
stream->capacity = 0;
}
/* read the spare bits in the buffer */
if(num_bits>0)
{
errn = readBuffer(stream);
if (errn < 0) {
return errn;
}
*b = ((*b) << num_bits) | (stream->buffer >> (BITS_IN_BYTE - num_bits));
stream->capacity = BITS_IN_BYTE - num_bits;
}
}
return errn;
}
#endif

View file

@ -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 <http://www.gnu.org/licenses/>.
*/
/*******************************************************************
*
* @author Daniel.Peintner.EXT@siemens.com
* @version 0.3
* @contact Joerg.Heuer@siemens.com
*
********************************************************************/
#ifdef __cplusplus
extern "C" {
#endif
#include "EXITypes.h"
#ifndef BIT_INPUT_STREAM_H
#define BIT_INPUT_STREAM_H
int readBits(bitstream_t* stream, size_t num_bits, uint8_t* b);
int flush();
#endif
#ifdef __cplusplus
}
#endif

View file

@ -0,0 +1,95 @@
/*
* 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 <http://www.gnu.org/licenses/>.
*/
/*******************************************************************
*
* @author Daniel.Peintner.EXT@siemens.com
* @version 0.3
* @contact Joerg.Heuer@siemens.com
*
********************************************************************/
#include <string.h>
#include "EXITypes.h"
#include "BitOutputStream.h"
#ifndef BIT_OUTPUT_STREAM_C
#define BIT_OUTPUT_STREAM_C
/* NOTE: nbits <= 8 */
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 */
stream->buffer = (stream->buffer << (nbits)) | (val & (0xff
>> (BITS_IN_BYTE - nbits)));
stream->capacity -= nbits;
/* if the buffer is full write it into the data */
if (stream->capacity == 0) {
if ((*stream->pos) >= stream->size) {
return -1;
}
stream->data[(*stream->pos)++] = 0xFF & stream->buffer;
stream->capacity = BITS_IN_BYTE;
stream->buffer = 0;
}
} else {
/* the buffer is not enough
* fill the buffer */
stream->buffer = (stream->buffer << stream->capacity) | ((val >> (nbits
- stream->capacity)) & (0xff >> (BITS_IN_BYTE
- stream->capacity)));
nbits -= stream->capacity;
if ((*stream->pos) >= stream->size) {
return -1;
}
stream->data[(*stream->pos)++] = 0xFF & stream->buffer;
stream->buffer = 0;
/* write whole bytes */
while (nbits >= BITS_IN_BYTE) {
nbits -= BITS_IN_BYTE;
if ((*stream->pos) >= stream->size) {
return -1;
}
stream->data[(*stream->pos)++] = 0xFF & (val >> (nbits));
}
/* spared bits are kept in the buffer */
stream->buffer = val; /* Note: the high bits will be shifted out during further filling */
stream->capacity = BITS_IN_BYTE - (nbits);
}
return 0;
}
/**
* Flush output
*/
int flush(bitstream_t* stream) {
if (stream->capacity == BITS_IN_BYTE) {
/* nothing to do, no bits in buffer */
return 0;
} else {
return writeBits(stream, stream->capacity, 0);
}
}
#endif

View file

@ -0,0 +1,48 @@
/*
* 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 <http://www.gnu.org/licenses/>.
*/
/*******************************************************************
*
* @author Daniel.Peintner.EXT@siemens.com
* @version 0.3
* @contact Joerg.Heuer@siemens.com
*
********************************************************************/
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include "EXITypes.h"
#ifndef BIT_OUTPUT_STREAM_H
#define BIT_OUTPUT_STREAM_H
int writeBits(bitstream_t* stream, size_t nbits, uint8_t bits);
/* flush output */
int flush(bitstream_t* stream);
#endif
#ifdef __cplusplus
}
#endif

View file

@ -0,0 +1,83 @@
/*
* 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 <http://www.gnu.org/licenses/>.
*/
/*******************************************************************
*
* @author Daniel.Peintner.EXT@siemens.com
* @version 0.3
* @contact Joerg.Heuer@siemens.com
*
********************************************************************/
#define _CRT_SECURE_NO_DEPRECATE 1
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <stdint.h>
#include <stdio.h>
#include "EXITypes.h"
#ifndef BYTE_STREAM_C
#define BYTE_STREAM_C
int readBytesFromFile(const char * filename, uint8_t* data, size_t size, size_t pos) {
FILE* f;
int character;
f = fopen(filename, "rb");
if (f == NULL) {
printf("\n[Error] no valid file handle !\n");
return -1;
} else {
/* read bytes */
while ((character = getc(f)) != EOF) {
if (pos >= size) {
return -1;
}
data[pos++] = (uint8_t) character;
/* printf("%u \n", character); */
}
fclose(f);
}
return pos;
}
int writeBytesToFile(uint8_t* data, size_t len, const char * filename) {
size_t rlen;
FILE* f = fopen(filename, "wb+");
if (f == NULL) {
return -1;
} else {
rlen = fwrite(data, sizeof(uint8_t), len, f);
fflush(f);
fclose(f);
if(rlen == len) {
return 0;
} else {
return -1;
}
}
}
#endif

View file

@ -0,0 +1,46 @@
/*
* 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 <http://www.gnu.org/licenses/>.
*/
/*******************************************************************
*
* @author Daniel.Peintner.EXT@siemens.com
* @version 0.3
* @contact Joerg.Heuer@siemens.com
*
********************************************************************/
#ifdef __cplusplus
extern "C" {
#endif
#include <stdio.h>
#include "EXITypes.h"
#ifndef BYTE_STREAM_H
#define BYTE_STREAM_H
int writeBytesToFile(uint8_t* data, size_t len, const char * filename);
int readBytesFromFile(const char * filename, uint8_t* data, size_t size, size_t pos);
#endif
#ifdef __cplusplus
}
#endif

View file

@ -0,0 +1,70 @@
/*
* 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 <http://www.gnu.org/licenses/>.
*/
/*******************************************************************
*
* @author Daniel.Peintner.EXT@siemens.com
* @version 0.3
* @contact Joerg.Heuer@siemens.com
*
********************************************************************/
#ifndef EXI_CODER_C
#define EXI_CODER_C
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <stdlib.h>
#include "EXITypes.h"
#include "BitInputStream.h"
#include "BitDecoderChannel.h"
#include "assert.h"
#include "EXICoder.h"
/*
size_t exiGetCurrentState(struct exiState* state) {
return state->grammarStates[state->currentStack];
// return 0;
}
*/
int exiPushStack(exi_state_t* state, size_t newState, eqname_t* eqn) {
if ((state->stackIndex + 1) < EXI_ELEMENT_STACK_SIZE) {
state->grammarStack[++state->stackIndex] = newState;
/* copy qname */
state->elementStack[state->stackIndex].localPart = eqn->localPart;
state->elementStack[state->stackIndex].namespaceURI = eqn->namespaceURI;
return 0;
} else {
return EXI_ERROR_OUT_OF_BOUNDS;
}
}
int exiPopStack(exi_state_t* state) {
if (state->stackIndex >= 1) {
state->stackIndex--;
return 0;
} else {
return EXI_ERROR_OUT_OF_BOUNDS;
}
}
#endif

View file

@ -0,0 +1,51 @@
/*
* 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 <http://www.gnu.org/licenses/>.
*/
/*******************************************************************
*
* @author Daniel.Peintner.EXT@siemens.com
* @version 0.3
* @contact Joerg.Heuer@siemens.com
*
********************************************************************/
#ifdef __cplusplus
extern "C" {
#endif
#ifndef EXI_CODER_H
#define EXI_CODER_H
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include "EXITypes.h"
/* size_t exiGetCurrentState(struct exiState* state); */
int exiPushStack(exi_state_t* state, size_t newState, eqname_t* eqn);
int exiPopStack(exi_state_t* state);
#endif
#ifdef __cplusplus
}
#endif

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,61 @@
/*
* 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 <http://www.gnu.org/licenses/>.
*/
/*******************************************************************
*
* @author Daniel.Peintner.EXT@siemens.com
* @version 0.3
* @contact Joerg.Heuer@siemens.com
*
********************************************************************/
#ifdef __cplusplus
extern "C" {
#endif
#ifndef EXI_DECODER_H
#define EXI_DECODER_H
#include "EXITypes.h"
int exiInitDecoder(bitstream_t* stream, exi_state_t* state);
int exiDecodeNextEvent(bitstream_t* stream, exi_state_t* state,
exi_event_t* nextEvent);
int exiDecodeStartDocument(bitstream_t* stream, exi_state_t* state);
int exiDecodeEndDocument(bitstream_t* stream, exi_state_t* state);
int exiDecodeStartElement(bitstream_t* stream, exi_state_t* state,
eqname_t* se);
int exiDecodeEndElement(bitstream_t* stream, exi_state_t* state,
eqname_t* ee);
int exiDecodeCharacters(bitstream_t* stream, exi_state_t* state,
exi_value_t* val);
int exiDecodeAttribute(bitstream_t* stream, exi_state_t* state,
eqname_t* at, exi_value_t* val);
#endif
#ifdef __cplusplus
}
#endif

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,61 @@
/*
* 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 <http://www.gnu.org/licenses/>.
*/
/*******************************************************************
*
* @author Daniel.Peintner.EXT@siemens.com
* @version 0.3
* @contact Joerg.Heuer@siemens.com
*
********************************************************************/
#ifdef __cplusplus
extern "C" {
#endif
#ifndef EXI_ENCODER_H
#define EXI_ENCODER_H
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include "EXITypes.h"
int exiInitEncoder(bitstream_t* stream, exi_state_t* state);
int exiEncodeStartDocument(bitstream_t* stream, exi_state_t* state);
int exiEncodeEndDocument(bitstream_t* stream, exi_state_t* state);
int exiEncodeStartElement(bitstream_t* stream, exi_state_t* state,
eqname_t* se);
int exiEncodeEndElement(bitstream_t* stream, exi_state_t* state, eqname_t* ee);
int exiEncodeCharacters(bitstream_t* stream, exi_state_t* state,
exi_value_t* val);
int exiEncodeAttribute(bitstream_t* stream, exi_state_t* state, eqname_t* at,
exi_value_t* val);
#endif
#ifdef __cplusplus
}
#endif

View file

@ -0,0 +1,58 @@
/*
* 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 <http://www.gnu.org/licenses/>.
*/
/*******************************************************************
*
* @author Daniel.Peintner.EXT@siemens.com
* @version 0.3
* @contact Joerg.Heuer@siemens.com
*
********************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include "EXIHeaderDecoder.h"
#include "BitInputStream.h"
#include "BitDecoderChannel.h"
#ifndef EXI_HEADER_DECODER_C
#define EXI_HEADER_DECODER_C
int readEXIHeader(bitstream_t* stream) {
uint8_t header;
int errn = readBits(stream, 8, &header);
if (errn < 0) {
return errn;
}
if(header == '$') {
/* we do not support "EXI Cookie" */
errn = -1;
} else if ( header & 0x20 ) {
/* we do not support "Presence Bit for EXI Options" */
errn = -2;
} else {
/* Yes, a *simple* header */
errn = 0;
}
return errn;
}
#endif

View file

@ -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 <http://www.gnu.org/licenses/>.
*/
/*******************************************************************
*
* @author Daniel.Peintner.EXT@siemens.com
* @version 0.3
* @contact Joerg.Heuer@siemens.com
*
********************************************************************/
#ifdef __cplusplus
extern "C" {
#endif
#include <stdio.h>
#include "EXITypes.h"
#ifndef EXI_HEADER_DECODER_H
#define EXI_HEADER_DECODER_H
int readEXIHeader(bitstream_t* stream);
#endif
#ifdef __cplusplus
}
#endif

View file

@ -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 <http://www.gnu.org/licenses/>.
*/
/*******************************************************************
*
* @author Daniel.Peintner.EXT@siemens.com
* @version 0.3
* @contact Joerg.Heuer@siemens.com
*
********************************************************************/
#include <stdio.h>
#include <stdlib.h>
#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

View file

@ -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 <http://www.gnu.org/licenses/>.
*/
/*******************************************************************
*
* @author Daniel.Peintner.EXT@siemens.com
* @version 0.3
* @contact Joerg.Heuer@siemens.com
*
********************************************************************/
#ifdef __cplusplus
extern "C" {
#endif
#include <stdio.h>
#include "EXITypes.h"
#ifndef EXI_HEADER_ENCODER_H
#define EXI_HEADER_ENCODER_H
int writeEXIHeader(bitstream_t* stream);
#endif
#ifdef __cplusplus
}
#endif

View file

@ -0,0 +1,185 @@
/*
* 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 <http://www.gnu.org/licenses/>.
*/
/*******************************************************************
*
* @author Daniel.Peintner.EXT@siemens.com
* @version 0.3
* @contact Joerg.Heuer@siemens.com
*
********************************************************************/
#ifdef __cplusplus
extern "C" {
#endif
#include <string.h>
#include <stdint.h>
#ifndef EXI_TYPES_H
#define EXI_TYPES_H
#define BITS_IN_BYTE 8
#define EXI_ELEMENT_STACK_SIZE 16
/* EXI automaton methods prefixes such as "inline" etc. */
#ifndef EXI_MPFX
#define EXI_MPFX
#endif
#define FLOAT_EXPONENT_SPECIAL_VALUES -16384
#define FLOAT_MANTISSA_INFINITY 1
#define FLOAT_MANTISSA_MINUS_INFINITY -1
#define FLOAT_MANTISSA_NOT_A_NUMBER 0
typedef struct {
/* Integer Array */
size_t size; /* array size */
uint8_t* data; /* int data array */
size_t* pos; /* next position in array */
/* Current byte buffer & its remaining bit capacity */
uint8_t buffer;
size_t capacity;
} bitstream_t;
typedef struct {
/* Bytes Size and array container */
size_t size;
uint8_t* data;
/* current length (len <= size) */
size_t len;
} bytes_t;
/* Universal Character Set (UCS) strings */
typedef struct {
/* UCS size and UCS character container*/
size_t size;
uint32_t* codepoints;
/* current length == number of code-points, (len <= size) */
size_t len;
} string_ucs_t;
typedef struct {
/* range of the mantissa is -(2^63) to 2^63-1 */
int64_t mantissa;
/* range of the exponent is - (2^14-1) to 2^14-1 */
int32_t exponent; /* base-10 */
} float_me_t;
typedef enum
{
/* Binary */
BINARY_BASE64, BINARY_HEX,
/* Boolean */
BOOLEAN,
/* Decimal */
DECIMAL,
/* Float */
FLOAT, DOUBLE,
/* N-Bit Integer */
NBIT_INTEGER_32, NBIT_INTEGER_64, NBIT_INTEGER_BIG,
/* Unsigned Integer */
UNSIGNED_INTEGER_16, UNSIGNED_INTEGER_32, UNSIGNED_INTEGER_64, UNSIGNED_INTEGER_BIG,
/* (Signed) Integer */
INTEGER_16, INTEGER_32, INTEGER_64, INTEGER_BIG,
/* Datetime */
DATETIME,
/* String */
STRING,
/* Enumeration */
ENUMERATION,
/* List */
LIST
} exi_datatype_t;
typedef enum
{
START_DOCUMENT,
END_DOCUMENT,
START_ELEMENT,
START_ELEMENT_GENERIC, /* not supported yet */
END_ELEMENT,
CHARACTERS,
CHARACTERS_GENERIC, /* not supported yet */
ATTRIBUTE,
ATTRIBUTE_GENERIC, /* not supported yet */
/* error state */
ERROR
} exi_event_t;
/* TODO list support */
typedef struct {
/* List container with memory size */
size_t size;
uint8_t* data;
/* list item type */
exi_datatype_t type;
/* number of items */
size_t len;
} list_t;
typedef struct {
unsigned int namespaceURI;
unsigned int localPart;
} eqname_t;
typedef struct {
/* stack of grammar states and elements */
size_t grammarStack [EXI_ELEMENT_STACK_SIZE];
eqname_t elementStack [EXI_ELEMENT_STACK_SIZE];
size_t stackIndex;
/* event-code */
uint8_t eventCode;
} exi_state_t;
typedef struct {
/* type of value */
exi_datatype_t type;
/* base types */
int boolean;
int8_t int8;
uint8_t uint8;
uint32_t uint32;
int32_t int32;
int64_t int64;
uint8_t enumeration;
/* Bytes, Strings and Lists are not native types anymore */
bytes_t binary;
string_ucs_t string;
list_t list;
} exi_value_t;
/*
* ERROR-Codes
*/
# define EXI_ERROR_OUT_OF_BOUNDS -100
# define EXI_ERROR_UNKOWN_EVENT_CODE -110
#endif
#ifdef __cplusplus
}
#endif

View file

@ -0,0 +1,112 @@
/*
* 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 <http://www.gnu.org/licenses/>.
*/
/*******************************************************************
*
* @author Daniel.Peintner.EXT@siemens.com
* @version 0.3
* @contact Joerg.Heuer@siemens.com
*
********************************************************************/
#ifndef STRING_TABLE_C
#define STRING_TABLE_C
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <stdlib.h>
#include "StringTable.h"
#include "EXITypes.h"
#include "BitInputStream.h"
#include "BitDecoderChannel.h"
#include "StringTableEntries.h"
#include "assert.h"
int exiGetUri(size_t uriID, const char** uri) {
if ( uriID < stringTable.len ) {
*uri = stringTable.uris[uriID];
} else {
return EXI_ERROR_OUT_OF_BOUNDS;
}
return 0;
}
int exiGetUriLength(size_t* uriLength) {
*uriLength = stringTable.len;
return 0;
}
int exiGetUriID(const char* uri, size_t* uriID) {
unsigned int i;
for(i=0; i<stringTable.len; i++) {
if ( strcmp ( uri, stringTable.uris[i] ) == 0 ) {
*uriID = i;
return 0;
}
}
return -1;
}
int exiGetLocalName(size_t uriID, size_t localNameID, const char** localName) {
if ( uriID < stringTable.len ) {
if ( localNameID < stringTable.localNames[uriID].len ) {
*localName = stringTable.localNames[uriID].entries[localNameID];
} else {
return EXI_ERROR_OUT_OF_BOUNDS;
}
} else {
return EXI_ERROR_OUT_OF_BOUNDS;
}
return 0;
}
int exiGetLocalNameLength(size_t uriID, size_t* localNameLength) {
if ( uriID < stringTable.len ) {
*localNameLength = stringTable.localNames[uriID].len;
} else {
return EXI_ERROR_OUT_OF_BOUNDS;
}
return 0;
}
int exiGetLocalNameID(size_t uriID, const char* localName, size_t* localNameID) {
unsigned int i;
if ( uriID < stringTable.len ) {
/* TODO binary search */
for(i=0; i<stringTable.localNames[uriID].len; i++) {
if ( strcmp ( localName, stringTable.localNames[uriID].entries[i] ) == 0 ) {
*localNameID = i;
return 0;
}
}
} else {
return EXI_ERROR_OUT_OF_BOUNDS;
}
return -1;
}
#endif

View file

@ -0,0 +1,53 @@
/*
* 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 <http://www.gnu.org/licenses/>.
*/
/*******************************************************************
*
* @author Daniel.Peintner.EXT@siemens.com
* @version 0.3
* @contact Joerg.Heuer@siemens.com
*
********************************************************************/
#ifdef __cplusplus
extern "C" {
#endif
#ifndef STRING_TABLE_H
#define STRING_TABLE_H
#include "EXITypes.h"
int exiGetUri(size_t uriID, const char** uri);
int exiGetUriLength(size_t* uriLength);
int exiGetUriID(const char* uri, size_t* uriID);
int exiGetLocalName(size_t uriID, size_t localNameID, const char** localName);
int exiGetLocalNameLength(size_t uriID, size_t* localNameLength);
int exiGetLocalNameID(size_t uriID, const char* localName, size_t* localNameID);
#endif
#ifdef __cplusplus
}
#endif

View file

@ -0,0 +1,122 @@
/*
* 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 <http://www.gnu.org/licenses/>.
*/
/*******************************************************************
*
* @author Daniel.Peintner.EXT@siemens.com
* @version 0.3
* @contact Joerg.Heuer@siemens.com
*
********************************************************************/
#ifndef STRING_TABLE_ENTRIES_C
#define STRING_TABLE_ENTRIES_C
#include "StringTableEntries.h"
/* ==================================== */
/* String Table Population */
/* localName entries for URI id = 0 */
const char * localNames0[] = {
NULL
};
/* localName entries for URI id = 1 */
const char * localNames1[] = {
"base", "id", "lang", "space"
};
/* localName entries for URI id = 2 */
const char * localNames2[] = {
"nil", "type"
};
/* localName entries for URI id = 3 */
const char * localNames3[] = {
"ENTITIES", "ENTITY", "ID", "IDREF", "IDREFS",
"NCName", "NMTOKEN", "NMTOKENS", "NOTATION", "Name",
"QName", "anySimpleType", "anyType", "anyURI", "base64Binary",
"boolean", "byte", "date", "dateTime", "decimal",
"double", "duration", "float", "gDay", "gMonth",
"gMonthDay", "gYear", "gYearMonth", "hexBinary", "int",
"integer", "language", "long", "negativeInteger", "nonNegativeInteger",
"nonPositiveInteger", "normalizedString", "positiveInteger", "short", "string",
"time", "token", "unsignedByte", "unsignedInt", "unsignedLong",
"unsignedShort"
};
/* localName entries for URI id = 4 */
const char * localNames4[] = {
"ChargingProfile", "ContractID", "EAmount", "EVSEID", "EVSEIMax",
"EVSEMaxPhases", "EVSEMaxPower", "EVSEStatus", "EVSEVoltage", "EnergyProvider",
"EoC", "LineLockReq", "LineLockReqType", "LineLockRes", "LineLockResType",
"MeterInfo", "MeteringAuthPubKey", "MeteringReceiptReq", "MeteringReceiptReqType", "MeteringReceiptRes",
"MeteringReceiptResType", "MeteringStatusReq", "MeteringStatusReqType", "MeteringStatusRes", "MeteringStatusResType",
"PCurrent", "PEVID", "PEVMaxPhases", "PEVMaxPower", "PEVMaxVoltage",
"PEVMinVoltage", "PEVPubKey", "PEVStatus", "PaymentDetailsReq", "PaymentDetailsReqType",
"PaymentDetailsRes", "PaymentDetailsResType", "PowerDeliveryReq", "PowerDeliveryReqType", "PowerDeliveryRes",
"PowerDeliveryResType", "PowerDiscoveryReq", "PowerDiscoveryReqType", "PowerDiscoveryRes", "PowerDiscoveryResType",
"ReqLockStatus", "ReqSwitchStatus", "ResponseCode", "ServiceDiscoveryReq", "ServiceDiscoveryReqType",
"ServiceDiscoveryRes", "ServiceDiscoveryResType", "ServiceList", "ServicePaymentSelectionReq", "ServicePaymentSelectionReqType",
"ServicePaymentSelectionRes", "ServicePaymentSelectionResType", "ServiceScope", "ServiceType", "SessionSetupReq",
"SessionSetupReqType", "SessionSetupRes", "SessionSetupResType", "TCurrent", "Tariff",
"TariffTable"
};
/* localName entries for URI id = 5 */
const char * localNames5[] = {
"ChargerStandby", "ChargingProfileEntryMaxPower", "ChargingProfileEntryStart", "ChargingProfileType", "ConnectorLocked",
"Currency", "EPrice", "EVSEStandby", "EVSEStatusType", "Event",
"EventList", "EventListType", "FatalError", "FaultCode", "FaultMsg",
"FloatingValueType", "MeterID", "MeterInfoType", "MeterReading", "MeterStatus",
"Multiplier", "NotificationType", "PEVStatusType", "PowerSwitchClosed", "ProtocolVersion",
"RCD", "Service", "ServiceDescriptionType", "ServiceID", "ServiceListType",
"ServiceName", "ServiceScope", "ServiceSessionID", "ServiceType", "SessionID",
"SessionInformationType", "ShutDownTime", "TMeter", "Tariff", "TariffDescrType",
"TariffDescription", "TariffEntries", "TariffEntriesType", "TariffEntry", "TariffEntryType",
"TariffID", "TariffPMax", "TariffStart", "TariffTableType", "Unit",
"Value", "contractIDType", "currencyType", "energyProviderType", "eventEntryType",
"evseIDType", "fatalErrorType", "faultCodeType", "lockStatusType", "maxPhasesType",
"meterIDType", "meterStatusType", "paymentOptionListType", "paymentOptionType", "pevIDType",
"protocolVersionType", "pubKeyType", "rcdType", "responseCode_LineLockType", "responseCode_MeteringReceiptType",
"responseCode_MeteringStatusType", "responseCode_PaymentDetailsType", "responseCode_PowerDeliveryType", "responseCode_PowerDiscoveryType", "responseCode_ServiceDiscoveryType",
"responseCode_ServicePaymentSelectionType", "responseCode_SessionSetupType", "serviceDetailsType", "serviceIDType", "serviceNameType",
"serviceScopeType", "serviceTypeType", "sessionIDType", "standbyType", "switchStatusType",
"tariffDescriptionType", "tariffIDType", "tariffStartType", "timeType", "unitMultiplierType",
"unitSymbolType"
};
/* localName entries for URI id = 6 */
const char * localNames6[] = {
"Body", "BodyBaseType", "BodyElement", "BodyType", "Header",
"HeaderType", "Notification", "SessionInformation", "V2G_Message"
};
struct exiPartition localNamePartitions[7] = {
{ 0, localNames0 },
{ 4, localNames1 },
{ 2, localNames2 },
{ 46, localNames3 },
{ 66, localNames4 },
{ 91, localNames5 },
{ 9, localNames6 }
};
const char * uris[] = {
"", "http://www.w3.org/XML/1998/namespace", "http://www.w3.org/2001/XMLSchema-instance", "http://www.w3.org/2001/XMLSchema", "urn:iso:15118:2:2010:MsgBody", "urn:iso:15118:2:2010:MsgDataTypes", "urn:iso:15118:2:2010:MsgDef"
};
struct exiStringTable stringTable = { 7, uris, localNamePartitions };
#endif

View file

@ -0,0 +1,60 @@
/*
* 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 <http://www.gnu.org/licenses/>.
*/
/*******************************************************************
*
* @author Daniel.Peintner.EXT@siemens.com
* @version 0.3
* @contact Joerg.Heuer@siemens.com
*
********************************************************************/
#ifndef STRING_TABLE_ENTRIES_H
#define STRING_TABLE_ENTRIES_H
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <stdlib.h>
/* ==================================== */
/* String Table Structures */
struct exiPartition {
/* length of array */
size_t len;
/* array of string entries */
const char** entries;
};
struct exiStringTable {
/* length of both arrays (uris & localNames) */
size_t len;
/* URI entries*/
const char** uris;
/* localName entries divided by URI */
struct exiPartition * localNames;
};
/* ==================================== */
/* String Table Population */
extern struct exiStringTable stringTable;
#endif

View file

@ -0,0 +1,64 @@
/*
* 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 <http://www.gnu.org/licenses/>.
*/
/*******************************************************************
*
* @author Daniel.Peintner.EXT@siemens.com
* @version 0.3
* @contact Joerg.Heuer@siemens.com
*
********************************************************************/
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <stdint.h>
#include "BitDecoderChannel.h"
#include "BitInputStream.h"
#include "EXITypes.h"
#ifndef UCS_STRING_C
#define UCS_STRING_C
int toUCSString(char* chars, string_ucs_t* s) {
unsigned int i;
s->len = strlen(chars);
if (s->len <= s->size) {
for(i=0; i<s->len; i++) {
s->codepoints[i] = chars[i];
}
return 0;
} else {
return -1;
}
}
/* Note: fails if string contains non ASCII characters */
int toASCIIString(string_ucs_t* string, char* outASCII) {
unsigned int i;
for(i=0; i<string->len; i++) {
outASCII[i] = (char)string->codepoints[i];
}
outASCII[string->len] = '\0';
return 0;
}
#endif

View file

@ -0,0 +1,48 @@
/*
* 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 <http://www.gnu.org/licenses/>.
*/
/*******************************************************************
*
* @author Daniel.Peintner.EXT@siemens.com
* @version 0.3
* @contact Joerg.Heuer@siemens.com
*
********************************************************************/
#ifdef __cplusplus
extern "C" {
#endif
#include "EXITypes.h"
/* TODO utf8/cstring//wchar_t/char16_t/char32_t methods */
#ifndef UCS_STRING_H
#define UCS_STRING_H
int toUCSString(char* chars, string_ucs_t* s);
/* Note: fails if string contains non ASCII characters */
int toASCIIString(string_ucs_t* string, char* outASCII);
#endif
#ifdef __cplusplus
}
#endif

View file

@ -0,0 +1,79 @@
/*
* 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 <http://www.gnu.org/licenses/>.
*/
/*******************************************************************
*
* @author Sebastian.Kaebisch.EXT@siemens.com
* @version 0.3
* @contact Joerg.Heuer@siemens.com
*
********************************************************************/
#ifdef __cplusplus
extern "C" {
#endif
#ifndef V2G_SERVICE_H_
#define V2G_SERVICE_H_
#include "v2g_serviceDataTypes.h"
#include "EXITypes.h"
struct uniqueIDPath
{
int id[10];
size_t pos;
};
struct v2gService
{
/* in-/ out-stream */
bitstream_t inStream;
bitstream_t outStream;
/* EXI */
exi_state_t stateDecode;
exi_state_t stateEncode;
exi_event_t event;
eqname_t eqn;
exi_value_t val;
/* v2g message data structure */
struct AnonType_V2G_Message v2gMsg;
/* unique id for ambiguous elements */
struct uniqueIDPath idPath;
/* error code */
uint8_t errorCode;
/* offset for transport header data */
uint16_t transportHeaderOffset;
};
/* define error codes (TODO: define precise error codes) */
#define V2G_NON_VALID_MESSAGE 0x01
#define V2G_SERIALIZATION_FAILED 0x02
#define V2G_UNKNOWN_ERROR 0xFF
#endif /* V2G_SERVICE_H_ */
#ifdef __cplusplus
}
#endif

View file

@ -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 <http://www.gnu.org/licenses/>.
*/
/*******************************************************************
*
* @author Sebastian.Kaebisch.EXT@siemens.com
* @version 0.3
* @contact Joerg.Heuer@siemens.com
*
********************************************************************/
#ifdef __cplusplus
extern "C" {
#endif
#ifndef V2G_SERVICECLIENTDATATRANSMITTER_H_
#define V2G_SERVICECLIENTDATATRANSMITTER_H_
#include "EXITypes.h"
/* This method has to be implemented!
* This method sends EXI stream (outStream) to the EVSE and receives response stream (inStream)*/
int serviceDataTransmitter(uint8_t* outStream, size_t outStreamLength, uint8_t* inStream);
#endif /* V2G_SERVICECLIENTDATATRANSMITTER_H_ */
#ifdef __cplusplus
}
#endif

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,105 @@
/*
* 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 <http://www.gnu.org/licenses/>.
*/
/*******************************************************************
*
* @author Sebastian.Kaebisch.EXT@siemens.com
* @version 0.3
* @contact Joerg.Heuer@siemens.com
*
********************************************************************/
#ifdef __cplusplus
extern "C" {
#endif
#ifndef SERVICECLIENTSTUBS_H
#define SERVICECLIENTSTUBS_H
#include "v2g_service.h"
#include "v2g_serviceDataTypes.h"
#include "v2g_serviceClientStubs.h"
/* call sessionSetup */
int call_sessionSetup(struct v2gService* service, struct HeaderType* header, struct SessionSetupReqType* params, struct SessionSetupResType* result);
/* call serviceDiscovery */
int call_serviceDiscovery(struct v2gService* service, struct HeaderType* header, struct ServiceDiscoveryReqType* params, struct ServiceDiscoveryResType* result);
/* call selectedServicePayment */
int call_selectedServicePayment(struct v2gService* service, struct HeaderType* header, struct ServicePaymentSelectionReqType* params, struct ServicePaymentSelectionResType* result);
/* call paymentDetails */
int call_paymentDetails(struct v2gService* service, struct HeaderType* header, struct PaymentDetailsReqType* params, struct PaymentDetailsResType* result);
/* call powerDiscovery */
int call_powerDiscovery(struct v2gService* service, struct HeaderType* header, struct PowerDiscoveryReqType* params, struct PowerDiscoveryResType* result);
/* call lineLock */
int call_lineLock(struct v2gService* service, struct HeaderType* header, struct LineLockReqType* params, struct LineLockResType* result);
/* call powerDelivery */
int call_powerDelivery(struct v2gService* service, struct HeaderType* header, struct PowerDeliveryReqType* params, struct PowerDeliveryResType* result);
/* call meteringStatus */
int call_meteringStatus(struct v2gService* service, struct HeaderType* header, struct MeteringStatusResType* result);
/* call meteringReceipt */
int call_meteringReceipt(struct v2gService* service, struct HeaderType* header, struct MeteringReceiptReqType* params, struct MeteringReceiptResType* result);
/* Initialize the v2g client */
int init_v2gServiceClient(struct v2gService* service, bytes_t bytes, string_ucs_t string, uint8_t* inStream, size_t max_inStream_size, uint8_t* outStream, size_t max_outStream_size, uint16_t transportHeaderOffset);
#endif
#ifdef __cplusplus
}
#endif

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,42 @@
/*
* 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 <http://www.gnu.org/licenses/>.
*/
/*******************************************************************
*
* @author Sebastian.Kaebisch.EXT@siemens.com
* @version 0.3
* @contact Joerg.Heuer@siemens.com
*
********************************************************************/
#ifdef __cplusplus
extern "C" {
#endif
#ifndef V2GSERVICEDATASERIAL_H_
#define V2GSERVICEDATASERIAL_H_
#include "v2g_service.h"
int serialize_message(struct v2gService* service);
#endif /* V2GSERVICEDATASERIAL_H_ */
#ifdef __cplusplus
}
#endif

View file

@ -0,0 +1,392 @@
/*
* 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 <http://www.gnu.org/licenses/>.
*/
/*******************************************************************
*
* @author Sebastian.Kaebisch.EXT@siemens.com
* @version 0.3
* @contact Joerg.Heuer@siemens.com
*
********************************************************************/
#include "EXITypes.h"
#include "v2g_serviceDataTypes.h"
static void init_SessionInformationType_SessionID(struct SessionInformationType_SessionID* type)
{
type->arraylen.data=0;
}
static void init_SessionInformationType_ServiceSessionID(struct SessionInformationType_ServiceSessionID* type)
{
type->arraylen.data=0;
}
static void init_SessionInformationType_ProtocolVersion(struct SessionInformationType_ProtocolVersion* type)
{
type->arraylen.data=0;
}
static void init_SessionInformationType(struct SessionInformationType* type)
{
init_SessionInformationType_SessionID(&(type->SessionID));
init_SessionInformationType_ServiceSessionID(&(type->ServiceSessionID));
type->isused.ServiceSessionID=0;
init_SessionInformationType_ProtocolVersion(&(type->ProtocolVersion));
type->isused.ProtocolVersion=0;
}
static void init_NotificationType_FaultMsg(struct NotificationType_FaultMsg* type)
{
type->arraylen.data=0;
}
static void init_NotificationType(struct NotificationType* type)
{
type->isused.FaultCode=0;
init_NotificationType_FaultMsg(&(type->FaultMsg));
type->isused.FaultMsg=0;
type->isused.EventList=0;
}
static void init_HeaderType(struct HeaderType* type)
{
init_SessionInformationType(&(type->SessionInformation));
init_NotificationType(&(type->Notification));
type->isused.Notification=0;
}
static void init_SessionSetupReqType_PEVID(struct SessionSetupReqType_PEVID* type)
{
type->arraylen.data=0;
}
static void init_SessionSetupReqType(struct SessionSetupReqType* type)
{
init_SessionSetupReqType_PEVID(&(type->PEVID));
type->isused.PEVID=0;
}
static void init_SessionSetupResType_EVSEID(struct SessionSetupResType_EVSEID* type)
{
type->arraylen.data=0;
}
static void init_SessionSetupResType(struct SessionSetupResType* type)
{
init_SessionSetupResType_EVSEID(&(type->EVSEID));
}
static void init_ServiceDiscoveryReqType_ServiceScope(struct ServiceDiscoveryReqType_ServiceScope* type)
{
type->arraylen.data=0;
}
static void init_ServiceDiscoveryReqType(struct ServiceDiscoveryReqType* type)
{
type->isused.ServiceType=0;
init_ServiceDiscoveryReqType_ServiceScope(&(type->ServiceScope));
type->isused.ServiceScope=0;
}
static void init_ServiceDescriptionType_ServiceID(struct ServiceDescriptionType_ServiceID* type)
{
type->arraylen.data=0;
}
static void init_ServiceDescriptionType_ServiceName(struct ServiceDescriptionType_ServiceName* type)
{
type->arraylen.data=0;
}
static void init_ServiceDescriptionType_ServiceScope(struct ServiceDescriptionType_ServiceScope* type)
{
type->arraylen.data=0;
}
static void init_ServiceDescriptionType(struct ServiceDescriptionType* type)
{
init_ServiceDescriptionType_ServiceID(&(type->ServiceID));
init_ServiceDescriptionType_ServiceName(&(type->ServiceName));
type->isused.ServiceName=0;
type->isused.ServiceType=0;
init_ServiceDescriptionType_ServiceScope(&(type->ServiceScope));
type->isused.ServiceScope=0;
}
static void init_ServiceListType(struct ServiceListType* type)
{
int i_loop;
for(i_loop=0; i_loop<8;i_loop++)
{
init_ServiceDescriptionType(&(type->Service[i_loop]));
}
type->arraylen.Service=0;
}
static void init_ServiceDiscoveryResType(struct ServiceDiscoveryResType* type)
{
init_ServiceListType(&(type->ServiceList));
type->isused.ServiceList=0;
}
static void init_ServicePaymentSelectionReqType_PEVPubKey(struct ServicePaymentSelectionReqType_PEVPubKey* type)
{
type->arraylen.data=0;
}
static void init_ServicePaymentSelectionReqType(struct ServicePaymentSelectionReqType* type)
{
init_ServiceListType(&(type->ServiceList));
init_ServicePaymentSelectionReqType_PEVPubKey(&(type->PEVPubKey));
}
static void init_ServicePaymentSelectionResType_MeteringAuthPubKey(struct ServicePaymentSelectionResType_MeteringAuthPubKey* type)
{
type->arraylen.data=0;
}
static void init_ServicePaymentSelectionResType(struct ServicePaymentSelectionResType* type)
{
init_ServicePaymentSelectionResType_MeteringAuthPubKey(&(type->MeteringAuthPubKey));
type->isused.MeteringAuthPubKey=0;
}
static void init_PaymentDetailsReqType_ContractID(struct PaymentDetailsReqType_ContractID* type)
{
type->arraylen.data=0;
}
static void init_PaymentDetailsReqType(struct PaymentDetailsReqType* type)
{
init_PaymentDetailsReqType_ContractID(&(type->ContractID));
}
static void init_PowerDiscoveryReqType(struct PowerDiscoveryReqType* type)
{
}
static void init_PowerDiscoveryResType_EnergyProvider(struct PowerDiscoveryResType_EnergyProvider* type)
{
type->arraylen.data=0;
}
static void init_TariffTableType_Currency(struct TariffTableType_Currency* type)
{
type->arraylen.data=0;
}
static void init_TariffDescrType_TariffDescription(struct TariffDescrType_TariffDescription* type)
{
type->arraylen.data=0;
}
static void init_TariffEntryType(struct TariffEntryType* type)
{
type->isused.EPrice=0;
}
static void init_TariffEntriesType(struct TariffEntriesType* type)
{
int i_loop;
for(i_loop=0; i_loop<8;i_loop++)
{
init_TariffEntryType(&(type->TariffEntry[i_loop]));
}
type->arraylen.TariffEntry=0;
}
static void init_TariffDescrType(struct TariffDescrType* type)
{
init_TariffDescrType_TariffDescription(&(type->TariffDescription));
type->isused.TariffDescription=0;
init_TariffEntriesType(&(type->TariffEntries));
}
static void init_TariffTableType(struct TariffTableType* type)
{
int i_loop;
init_TariffTableType_Currency(&(type->Currency));
for(i_loop=0; i_loop<6;i_loop++)
{
init_TariffDescrType(&(type->Tariff[i_loop]));
}
type->arraylen.Tariff=0;
}
static void init_PowerDiscoveryResType(struct PowerDiscoveryResType* type)
{
init_PowerDiscoveryResType_EnergyProvider(&(type->EnergyProvider));
type->isused.EnergyProvider=0;
init_TariffTableType(&(type->TariffTable));
type->isused.TariffTable=0;
}
static void init_LineLockReqType(struct LineLockReqType* type)
{
}
static void init_LineLockResType(struct LineLockResType* type)
{
}
static void init_ChargingProfileType(struct ChargingProfileType* type)
{
}
static void init_PowerDeliveryReqType(struct PowerDeliveryReqType* type)
{
type->isused.Tariff=0;
init_ChargingProfileType(&(type->ChargingProfile));
type->isused.ChargingProfile=0;
}
static void init_MeteringStatusResType_EVSEID(struct MeteringStatusResType_EVSEID* type)
{
type->arraylen.data=0;
}
static void init_MeterInfoType_MeterID(struct MeterInfoType_MeterID* type)
{
type->arraylen.data=0;
}
static void init_MeterInfoType(struct MeterInfoType* type)
{
init_MeterInfoType_MeterID(&(type->MeterID));
type->isused.MeterID=0;
type->isused.MeterReading=0;
type->isused.MeterStatus=0;
type->isused.TMeter=0;
}
static void init_MeteringStatusResType(struct MeteringStatusResType* type)
{
init_MeteringStatusResType_EVSEID(&(type->EVSEID));
type->isused.PCurrent=0;
init_MeterInfoType(&(type->MeterInfo));
type->isused.MeterInfo=0;
}
static void init_MeteringReceiptReqType_PEVID(struct MeteringReceiptReqType_PEVID* type)
{
type->arraylen.data=0;
}
static void init_MeteringReceiptReqType(struct MeteringReceiptReqType* type)
{
init_MeteringReceiptReqType_PEVID(&(type->PEVID));
type->isused.PEVID=0;
type->isused.TCurrent=0;
init_MeterInfoType(&(type->MeterInfo));
}
static void init_BodyType(struct BodyType* type)
{
init_SessionSetupReqType(&(type->SessionSetupReq));
type->isused.SessionSetupReq=0;
init_SessionSetupResType(&(type->SessionSetupRes));
type->isused.SessionSetupRes=0;
init_ServiceDiscoveryReqType(&(type->ServiceDiscoveryReq));
type->isused.ServiceDiscoveryReq=0;
init_ServiceDiscoveryResType(&(type->ServiceDiscoveryRes));
type->isused.ServiceDiscoveryRes=0;
init_ServicePaymentSelectionReqType(&(type->ServicePaymentSelectionReq));
type->isused.ServicePaymentSelectionReq=0;
init_ServicePaymentSelectionResType(&(type->ServicePaymentSelectionRes));
type->isused.ServicePaymentSelectionRes=0;
init_PaymentDetailsReqType(&(type->PaymentDetailsReq));
type->isused.PaymentDetailsReq=0;
type->isused.PaymentDetailsRes=0;
init_PowerDiscoveryReqType(&(type->PowerDiscoveryReq));
type->isused.PowerDiscoveryReq=0;
init_PowerDiscoveryResType(&(type->PowerDiscoveryRes));
type->isused.PowerDiscoveryRes=0;
init_LineLockReqType(&(type->LineLockReq));
type->isused.LineLockReq=0;
init_LineLockResType(&(type->LineLockRes));
type->isused.LineLockRes=0;
init_PowerDeliveryReqType(&(type->PowerDeliveryReq));
type->isused.PowerDeliveryReq=0;
type->isused.PowerDeliveryRes=0;
type->isused.MeteringStatusReq=0;
init_MeteringStatusResType(&(type->MeteringStatusRes));
type->isused.MeteringStatusRes=0;
init_MeteringReceiptReqType(&(type->MeteringReceiptReq));
type->isused.MeteringReceiptReq=0;
type->isused.MeteringReceiptRes=0;
}
void init_AnonType_V2G_Message(struct AnonType_V2G_Message* type)
{
init_HeaderType(&(type->Header));
init_BodyType(&(type->Body));
}

View file

@ -0,0 +1,969 @@
/*
* 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 <http://www.gnu.org/licenses/>.
*/
/*******************************************************************
*
* @author Sebastian.Kaebisch.EXT@siemens.com
* @version 0.3
* @contact Joerg.Heuer@siemens.com
*
********************************************************************/
#ifdef __cplusplus
extern "C" {
#endif
#ifndef SERVICEDATATYPES_H
#define SERVICEDATATYPES_H
#include "EXITypes.h"
enum faultCodeType
{
ParsingError,
V2GProtocolVersionNotSupported,
UnknownError
};
enum eventEntryType
{
InitiateSessionSetup,
InitiateServiceDiscovery,
InitiatePowerDiscovery,
InitiateLineLock,
InitiatePowerDelivery,
InitiateInitiateMeteringStatus
};
enum responseCode_SessionSetupType
{
OK_SessionSetup,
OK_NewSessionEstablished,
OK_OldSessionJoined,
FAILED_UnknownSession,
FAILED_SessionEstablishmentError,
FAILED_UnknownError_InSessionSetup
};
enum serviceTypeType
{
PEV_Recharge,
Remote_Customer_Support,
Internet,
Other
};
enum responseCode_ServiceDiscoveryType
{
OK_ServiceDiscovery,
FAILED_NoServicesOfThisType,
FAILED_NoServicesInThisScope,
FAILED_NoServicesOfThisTypeScope,
FAILED_NoServicesFound,
FAILED_UnknownError_InServiceDiscovery
};
enum responseCode_ServicePaymentSelectionType
{
OK_ServicePaymentSelection,
FAILED_ServiceSelectionInvalid,
FAILED_PaymentSelectionInvalid,
FAILED_UnknownError_InServicePaymentSelection
};
enum responseCode_PaymentDetailsType
{
OK_PaymentDetails,
FAILED_PaymentDetailsInvalid,
FAILED_UnknownError
};
enum unitMultiplierType
{
d,
c,
m,
micro,
n,
p,
k,
M,
G,
T,
none
};
enum unitSymbolType
{
A,
deg,
F,
g,
h,
J,
J_s,
kg_J,
min,
N,
ohm,
s,
S,
s_1,
V,
V_VAr,
VA,
VAh,
VAr,
VArh,
W,
W_Hz,
W_s,
Wh,
Ah
};
enum responseCode_PowerDiscoveryType
{
OK_PowerDiscovery,
FAILED_UnknownError_InPowerDiscovery
};
enum tariffIDType
{
Standard_charge,
Fast_charge,
Green_charge,
Grid_friendly_charge,
Freely_parameterisable_charge,
Charge_under_reserve
};
enum responseCode_LineLockType
{
OK_LineLock,
FAILED_LineLockNotApplied,
FAILED_UnknownError_InLineLock
};
enum responseCode_PowerDeliveryType
{
OK_PowerDelivery,
FAILED_PowerDeliveryNotApplied,
FAILED_TariffSelectionInvalid,
FAILED_ChargingProfileInvalid,
FAILED_UnknownError_InPowerDelivery
};
enum responseCode_MeteringStatusType
{
OK_MeteringStatus,
FAILED_UnknownError_InMeteringStatus
};
enum responseCode_MeteringReceiptType
{
OK_MeteringReceipt,
FAILED_UnknownError_MeteringReceipt
};
struct arraylen_SessionInformationType_SessionID
{
size_t data;
};
struct SessionInformationType_SessionID
{
uint8_t data[8];
struct arraylen_SessionInformationType_SessionID arraylen;
};
struct arraylen_SessionInformationType_ServiceSessionID
{
size_t data;
};
struct SessionInformationType_ServiceSessionID
{
uint8_t data[8];
struct arraylen_SessionInformationType_ServiceSessionID arraylen;
};
struct selection_SessionInformationType
{
unsigned int ServiceSessionID:1;
unsigned int ProtocolVersion:1;
};
struct arraylen_SessionInformationType_ProtocolVersion
{
size_t data;
};
struct SessionInformationType_ProtocolVersion
{
uint32_t data[256];
struct arraylen_SessionInformationType_ProtocolVersion arraylen;
};
struct SessionInformationType
{
struct SessionInformationType_SessionID SessionID;
struct SessionInformationType_ServiceSessionID ServiceSessionID;
struct SessionInformationType_ProtocolVersion ProtocolVersion;
struct selection_SessionInformationType isused;
};
struct selection_NotificationType
{
unsigned int FaultCode:1;
unsigned int FaultMsg:1;
unsigned int EventList:1;
};
struct arraylen_NotificationType_FaultMsg
{
size_t data;
};
struct NotificationType_FaultMsg
{
uint32_t data[256];
struct arraylen_NotificationType_FaultMsg arraylen;
};
struct EventListType
{
enum eventEntryType Event;
};
struct NotificationType
{
enum faultCodeType FaultCode;
struct NotificationType_FaultMsg FaultMsg;
struct EventListType EventList;
struct selection_NotificationType isused;
};
struct selection_HeaderType
{
unsigned int Notification:1;
};
struct HeaderType
{
struct SessionInformationType SessionInformation;
struct NotificationType Notification;
struct selection_HeaderType isused;
};
struct arraylen_SessionSetupReqType_PEVID
{
size_t data;
};
struct SessionSetupReqType_PEVID
{
uint32_t data[32];
struct arraylen_SessionSetupReqType_PEVID arraylen;
};
struct selection_SessionSetupReqType
{
unsigned int PEVID:1;
};
struct PEVStatusType
{
int ConnectorLocked;
int ChargerStandby;
};
struct SessionSetupReqType
{
struct SessionSetupReqType_PEVID PEVID;
struct PEVStatusType PEVStatus;
struct selection_SessionSetupReqType isused;
};
struct selection_BodyType
{
unsigned int SessionSetupReq:1;
unsigned int SessionSetupRes:1;
unsigned int ServiceDiscoveryReq:1;
unsigned int ServiceDiscoveryRes:1;
unsigned int ServicePaymentSelectionReq:1;
unsigned int ServicePaymentSelectionRes:1;
unsigned int PaymentDetailsReq:1;
unsigned int PaymentDetailsRes:1;
unsigned int PowerDiscoveryReq:1;
unsigned int PowerDiscoveryRes:1;
unsigned int LineLockReq:1;
unsigned int LineLockRes:1;
unsigned int PowerDeliveryReq:1;
unsigned int PowerDeliveryRes:1;
unsigned int MeteringStatusReq:1;
unsigned int MeteringStatusRes:1;
unsigned int MeteringReceiptReq:1;
unsigned int MeteringReceiptRes:1;
};
struct arraylen_SessionSetupResType_EVSEID
{
size_t data;
};
struct SessionSetupResType_EVSEID
{
uint8_t data[32];
struct arraylen_SessionSetupResType_EVSEID arraylen;
};
struct EVSEStatusType
{
int FatalError;
int EVSEStandby;
int ConnectorLocked;
int PowerSwitchClosed;
int RCD;
int32_t ShutDownTime;
};
struct SessionSetupResType
{
enum responseCode_SessionSetupType ResponseCode;
struct SessionSetupResType_EVSEID EVSEID;
struct EVSEStatusType EVSEStatus;
int32_t TCurrent;
};
struct selection_ServiceDiscoveryReqType
{
unsigned int ServiceType:1;
unsigned int ServiceScope:1;
};
struct arraylen_ServiceDiscoveryReqType_ServiceScope
{
size_t data;
};
struct ServiceDiscoveryReqType_ServiceScope
{
uint32_t data[255];
struct arraylen_ServiceDiscoveryReqType_ServiceScope arraylen;
};
struct ServiceDiscoveryReqType
{
enum serviceTypeType ServiceType;
struct ServiceDiscoveryReqType_ServiceScope ServiceScope;
struct selection_ServiceDiscoveryReqType isused;
};
struct arraylen_ServiceDescriptionType_ServiceID
{
size_t data;
};
struct ServiceDescriptionType_ServiceID
{
uint8_t data[8];
struct arraylen_ServiceDescriptionType_ServiceID arraylen;
};
struct arraylen_ServiceDescriptionType_ServiceName
{
size_t data;
};
struct ServiceDescriptionType_ServiceName
{
uint32_t data[64];
struct arraylen_ServiceDescriptionType_ServiceName arraylen;
};
struct selection_ServiceDescriptionType
{
unsigned int ServiceName:1;
unsigned int ServiceType:1;
unsigned int ServiceScope:1;
};
struct arraylen_ServiceDescriptionType_ServiceScope
{
size_t data;
};
struct ServiceDescriptionType_ServiceScope
{
uint32_t data[255];
struct arraylen_ServiceDescriptionType_ServiceScope arraylen;
};
struct ServiceDescriptionType
{
struct ServiceDescriptionType_ServiceID ServiceID;
struct ServiceDescriptionType_ServiceName ServiceName;
enum serviceTypeType ServiceType;
struct ServiceDescriptionType_ServiceScope ServiceScope;
struct selection_ServiceDescriptionType isused;
};
struct arraylen_ServiceListType
{
size_t Service;
};
struct ServiceListType
{
struct ServiceDescriptionType Service[8];
struct arraylen_ServiceListType arraylen;
};
struct selection_ServiceDiscoveryResType
{
unsigned int ServiceList:1;
};
struct ServiceDiscoveryResType
{
enum responseCode_ServiceDiscoveryType ResponseCode;
struct ServiceListType ServiceList;
struct selection_ServiceDiscoveryResType isused;
};
struct arraylen_ServicePaymentSelectionReqType_PEVPubKey
{
size_t data;
};
struct ServicePaymentSelectionReqType_PEVPubKey
{
uint8_t data[64];
struct arraylen_ServicePaymentSelectionReqType_PEVPubKey arraylen;
};
struct ServicePaymentSelectionReqType
{
struct ServiceListType ServiceList;
struct ServicePaymentSelectionReqType_PEVPubKey PEVPubKey;
};
struct arraylen_ServicePaymentSelectionResType_MeteringAuthPubKey
{
size_t data;
};
struct ServicePaymentSelectionResType_MeteringAuthPubKey
{
uint8_t data[64];
struct arraylen_ServicePaymentSelectionResType_MeteringAuthPubKey arraylen;
};
struct selection_ServicePaymentSelectionResType
{
unsigned int MeteringAuthPubKey:1;
};
struct ServicePaymentSelectionResType
{
enum responseCode_ServicePaymentSelectionType ResponseCode;
struct ServicePaymentSelectionResType_MeteringAuthPubKey MeteringAuthPubKey;
struct selection_ServicePaymentSelectionResType isused;
};
struct arraylen_PaymentDetailsReqType_ContractID
{
size_t data;
};
struct PaymentDetailsReqType_ContractID
{
uint32_t data[128];
struct arraylen_PaymentDetailsReqType_ContractID arraylen;
};
struct PaymentDetailsReqType
{
struct PaymentDetailsReqType_ContractID ContractID;
};
struct PaymentDetailsResType
{
enum responseCode_PaymentDetailsType ResponseCode;
};
struct FloatingValueType
{
enum unitMultiplierType Multiplier;
enum unitSymbolType Unit;
int32_t Value;
};
struct PowerDiscoveryReqType
{
struct PEVStatusType PEVStatus;
int32_t EoC;
struct FloatingValueType EAmount;
struct FloatingValueType PEVMaxPower;
int16_t PEVMaxPhases;
struct FloatingValueType PEVMaxVoltage;
struct FloatingValueType PEVMinVoltage;
};
struct arraylen_PowerDiscoveryResType_EnergyProvider
{
size_t data;
};
struct PowerDiscoveryResType_EnergyProvider
{
uint32_t data[256];
struct arraylen_PowerDiscoveryResType_EnergyProvider arraylen;
};
struct selection_PowerDiscoveryResType
{
unsigned int EnergyProvider:1;
unsigned int TariffTable:1;
};
struct arraylen_TariffTableType_Currency
{
size_t data;
};
struct TariffTableType_Currency
{
uint32_t data[3];
struct arraylen_TariffTableType_Currency arraylen;
};
struct arraylen_TariffDescrType_TariffDescription
{
size_t data;
};
struct TariffDescrType_TariffDescription
{
uint32_t data[32];
struct arraylen_TariffDescrType_TariffDescription arraylen;
};
struct selection_TariffDescrType
{
unsigned int TariffDescription:1;
};
struct selection_TariffEntryType
{
unsigned int EPrice:1;
};
struct TariffEntryType
{
uint32_t TariffStart;
struct FloatingValueType TariffPMax;
struct FloatingValueType EPrice;
struct selection_TariffEntryType isused;
};
struct arraylen_TariffEntriesType
{
size_t TariffEntry;
};
struct TariffEntriesType
{
struct TariffEntryType TariffEntry[8];
struct arraylen_TariffEntriesType arraylen;
};
struct TariffDescrType
{
enum tariffIDType TariffID;
struct TariffDescrType_TariffDescription TariffDescription;
struct TariffEntriesType TariffEntries;
struct selection_TariffDescrType isused;
};
struct arraylen_TariffTableType
{
size_t Tariff;
};
struct TariffTableType
{
struct TariffTableType_Currency Currency;
struct TariffDescrType Tariff[6];
struct arraylen_TariffTableType arraylen;
};
struct PowerDiscoveryResType
{
enum responseCode_PowerDiscoveryType ResponseCode;
struct EVSEStatusType EVSEStatus;
struct FloatingValueType EVSEVoltage;
struct FloatingValueType EVSEIMax;
int16_t EVSEMaxPhases;
struct PowerDiscoveryResType_EnergyProvider EnergyProvider;
struct TariffTableType TariffTable;
struct selection_PowerDiscoveryResType isused;
};
struct LineLockReqType
{
struct PEVStatusType PEVStatus;
int ReqLockStatus;
};
struct LineLockResType
{
enum responseCode_LineLockType ResponseCode;
struct EVSEStatusType EVSEStatus;
};
struct selection_PowerDeliveryReqType
{
unsigned int Tariff:1;
unsigned int ChargingProfile:1;
};
struct ChargingProfileType
{
int32_t ChargingProfileEntryStart;
struct FloatingValueType ChargingProfileEntryMaxPower;
};
struct PowerDeliveryReqType
{
struct PEVStatusType PEVStatus;
int ReqSwitchStatus;
enum tariffIDType Tariff;
struct ChargingProfileType ChargingProfile;
struct selection_PowerDeliveryReqType isused;
};
struct PowerDeliveryResType
{
enum responseCode_PowerDeliveryType ResponseCode;
};
struct MeteringStatusReqType
{
int NO_MEMBER:1;
};
struct arraylen_MeteringStatusResType_EVSEID
{
size_t data;
};
struct MeteringStatusResType_EVSEID
{
uint8_t data[32];
struct arraylen_MeteringStatusResType_EVSEID arraylen;
};
struct selection_MeteringStatusResType
{
unsigned int PCurrent:1;
unsigned int MeterInfo:1;
};
struct arraylen_MeterInfoType_MeterID
{
size_t data;
};
struct MeterInfoType_MeterID
{
uint32_t data[32];
struct arraylen_MeterInfoType_MeterID arraylen;
};
struct selection_MeterInfoType
{
unsigned int MeterID:1;
unsigned int MeterReading:1;
unsigned int MeterStatus:1;
unsigned int TMeter:1;
};
struct MeterInfoType
{
struct MeterInfoType_MeterID MeterID;
struct FloatingValueType MeterReading;
int16_t MeterStatus;
int32_t TMeter;
struct selection_MeterInfoType isused;
};
struct MeteringStatusResType
{
enum responseCode_MeteringStatusType ResponseCode;
struct MeteringStatusResType_EVSEID EVSEID;
struct EVSEStatusType EVSEStatus;
int32_t TCurrent;
struct FloatingValueType EVSEMaxPower;
struct FloatingValueType PCurrent;
struct MeterInfoType MeterInfo;
struct selection_MeteringStatusResType isused;
};
struct arraylen_MeteringReceiptReqType_PEVID
{
size_t data;
};
struct MeteringReceiptReqType_PEVID
{
uint32_t data[32];
struct arraylen_MeteringReceiptReqType_PEVID arraylen;
};
struct selection_MeteringReceiptReqType
{
unsigned int PEVID:1;
unsigned int TCurrent:1;
};
struct MeteringReceiptReqType
{
struct MeteringReceiptReqType_PEVID PEVID;
struct PEVStatusType PEVStatus;
int32_t TCurrent;
enum tariffIDType Tariff;
struct MeterInfoType MeterInfo;
struct selection_MeteringReceiptReqType isused;
};
struct MeteringReceiptResType
{
enum responseCode_MeteringReceiptType ResponseCode;
};
struct BodyType
{
struct SessionSetupReqType SessionSetupReq;
struct SessionSetupResType SessionSetupRes;
struct ServiceDiscoveryReqType ServiceDiscoveryReq;
struct ServiceDiscoveryResType ServiceDiscoveryRes;
struct ServicePaymentSelectionReqType ServicePaymentSelectionReq;
struct ServicePaymentSelectionResType ServicePaymentSelectionRes;
struct PaymentDetailsReqType PaymentDetailsReq;
struct PaymentDetailsResType PaymentDetailsRes;
struct PowerDiscoveryReqType PowerDiscoveryReq;
struct PowerDiscoveryResType PowerDiscoveryRes;
struct LineLockReqType LineLockReq;
struct LineLockResType LineLockRes;
struct PowerDeliveryReqType PowerDeliveryReq;
struct PowerDeliveryResType PowerDeliveryRes;
struct MeteringStatusReqType MeteringStatusReq;
struct MeteringStatusResType MeteringStatusRes;
struct MeteringReceiptReqType MeteringReceiptReq;
struct MeteringReceiptResType MeteringReceiptRes;
struct selection_BodyType isused;
};
struct AnonType_V2G_Message
{
struct HeaderType Header;
struct BodyType Body;
};
/* init method of the V2G message */
void init_AnonType_V2G_Message(struct AnonType_V2G_Message* v2gMsg);
#endif
#ifdef __cplusplus
}
#endif

File diff suppressed because it is too large Load diff

View file

@ -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 <http://www.gnu.org/licenses/>.
*/
/*******************************************************************
*
* @author Sebastian.Kaebisch.EXT@siemens.com
* @version 0.3
* @contact Joerg.Heuer@siemens.com
*
********************************************************************/
#ifdef __cplusplus
extern "C" {
#endif
#ifndef V2GSERVER_H_
#define V2GSERVER_H_
#include "v2g_serviceDataTypes.h"
int init_v2gservice(struct v2gService* service,bytes_t bytes, string_ucs_t string, uint16_t transportHeaderOffset);
int messageDispatcher(struct v2gService* service, uint8_t* inStream, size_t sizeInStream, uint8_t* outStream, size_t sizeOutStream, size_t* outPos);
#endif /* V2GSERVER_H_ */
#ifdef __cplusplus
}
#endif

Some files were not shown because too many files have changed in this diff Show more