mirror of
https://github.com/Martin-P/OpenV2G.git
synced 2024-11-18 12:53:58 +00:00
delete old files (DoIP and main_service, main_service, etc)
git-svn-id: https://svn.code.sf.net/p/openv2g/code/trunk@38 d9f2db14-54d0-4bde-b00c-16405c910529
This commit is contained in:
parent
7799eeb24a
commit
8849f662b5
10 changed files with 0 additions and 1748 deletions
|
@ -1,43 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (C) 2007-2011 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.4
|
|
||||||
* @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);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,34 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (C) 2007-2011 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.4
|
|
||||||
* @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
|
|
|
@ -1,231 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (C) 2007-2011 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.4
|
|
||||||
* @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;
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,708 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (C) 2007-2011 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.4
|
|
||||||
* @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 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*/
|
|
||||||
|
|
||||||
static void printEVSEStatus(struct EVSEStatusType* status);
|
|
||||||
static void printErrorMessage(struct EXIService* service);
|
|
||||||
|
|
||||||
static int ac_charging()
|
|
||||||
{
|
|
||||||
/* 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 ChargeParameterDiscoveryReqType powerDiscovery;
|
|
||||||
struct ChargeParameterDiscoveryResType resultPowerDiscovery;
|
|
||||||
struct LineLockReqType lineLock;
|
|
||||||
struct LineLockResType resultLineLock;
|
|
||||||
struct PowerDeliveryReqType powerDelivery;
|
|
||||||
struct PowerDeliveryResType resultPowerDelivery;
|
|
||||||
struct MeteringStatusResType resultMeteringStatus;
|
|
||||||
struct MeteringReceiptReqType meteringReceipt;
|
|
||||||
struct MeteringReceiptResType resultMeteringReceipt;
|
|
||||||
|
|
||||||
|
|
||||||
struct FloatingValueType float_type; /* test float type*/
|
|
||||||
|
|
||||||
|
|
||||||
/* 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;
|
|
||||||
|
|
||||||
/*******************
|
|
||||||
* 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: optional elements have to be set used (=1) or not used (=0) */
|
|
||||||
v2gHeader.SessionInformation.isused.ServiceSessionID = 0; /* service session is not used */
|
|
||||||
v2gHeader.isused.Notification=0; /* no notification */
|
|
||||||
|
|
||||||
/* setup sessionSetup parameter */
|
|
||||||
sessionSetup.isused.PEVID=1; /* PEVID is transported */
|
|
||||||
sessionSetup.PEVID.arraylen.data=1;
|
|
||||||
sessionSetup.PEVID.data[0]=10;
|
|
||||||
sessionSetup.PEVStatus.ChargerStandby=0; /* charger standby = true */
|
|
||||||
sessionSetup.PEVStatus.ConnectorLocked=0; /* connector locked = false */
|
|
||||||
sessionSetup.PEVStatus.ReadyToCharge=0; /* ReadyToCharge = 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 (OK)\n",resultSessionSetup.ResponseCode);
|
|
||||||
printf("\tEVSEID=%d\n", resultSessionSetup.EVSEID.data[0]);
|
|
||||||
printEVSEStatus(&resultSessionSetup.EVSEStatus);
|
|
||||||
printf("\tTCurrent=%d\n",resultSessionSetup.TCurrent);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*******************************************
|
|
||||||
* Setup data for chargeParameterDiscovery *
|
|
||||||
*******************************************/
|
|
||||||
|
|
||||||
powerDiscovery.PEVStatus.ChargerStandby = 1;
|
|
||||||
powerDiscovery.PEVStatus.ConnectorLocked = 0;
|
|
||||||
powerDiscovery.PEVStatus.ReadyToCharge=0;
|
|
||||||
powerDiscovery.ChargingMode = AC_charging_chargingModeType;
|
|
||||||
powerDiscovery.EoC = 12345678;
|
|
||||||
|
|
||||||
float_type.Multiplier = 0;
|
|
||||||
float_type.Unit = J_unitSymbolType;
|
|
||||||
float_type.Value = 100;
|
|
||||||
|
|
||||||
powerDiscovery.EAmount = float_type;
|
|
||||||
powerDiscovery.PEVMaxPhases = 3;
|
|
||||||
|
|
||||||
float_type.Unit = W_unitSymbolType;
|
|
||||||
float_type.Value = 600;
|
|
||||||
powerDiscovery.PEVMaxPower = float_type;
|
|
||||||
|
|
||||||
float_type.Unit = V_unitSymbolType;
|
|
||||||
float_type.Value = 1000;
|
|
||||||
powerDiscovery.PEVMaxVoltage = float_type;
|
|
||||||
float_type.Value = 200;
|
|
||||||
powerDiscovery.PEVMinVoltage = float_type;
|
|
||||||
|
|
||||||
/* only required for DC */
|
|
||||||
float_type.Unit = A_unitSymbolType;
|
|
||||||
float_type.Value = 200;
|
|
||||||
powerDiscovery.PEVMaxCurrent = float_type;
|
|
||||||
powerDiscovery.PEVMinCurrent = float_type;
|
|
||||||
|
|
||||||
|
|
||||||
/*********************************
|
|
||||||
* Call chargeParameterDiscovery *
|
|
||||||
*********************************/
|
|
||||||
printf("\nPEV: call EVSE chargeParameterDiscovery\n");
|
|
||||||
|
|
||||||
if(call_chargeParameterDiscovery(&service,&v2gHeader,&powerDiscovery,&resultPowerDiscovery))
|
|
||||||
{
|
|
||||||
printErrorMessage(&service);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
|
|
||||||
/* show result of the answer message of EVSE sessionSetup*/
|
|
||||||
printf("PEV: received response message from EVSE\n");
|
|
||||||
printf("\tResponseCode=%d\n",resultPowerDiscovery.ResponseCode);
|
|
||||||
printEVSEStatus(&resultPowerDiscovery.EVSEStatus);
|
|
||||||
printf("\tEVSEMaxVoltage=%d\n",resultPowerDiscovery.EVSEMaxVoltage.Value);
|
|
||||||
/*printf("\tEVSEMaxCurrent=%d\n",resultPowerDiscovery.EVSEMaxCurrent.Value);*/
|
|
||||||
printf("\tEVSEMaxPhases=%d\n",resultPowerDiscovery.EVSEMaxPhases);
|
|
||||||
|
|
||||||
/*printf("\tEnergyProvider=%d\n",resultPowerDiscovery.EnergyProvider.data[0]);*/
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*********************************
|
|
||||||
* Setup data for lineLock *
|
|
||||||
*********************************/
|
|
||||||
|
|
||||||
lineLock.PEVStatus.ChargerStandby = 1;
|
|
||||||
lineLock.PEVStatus.ConnectorLocked = 1;
|
|
||||||
lineLock.PEVStatus.ReadyToCharge = 1;
|
|
||||||
lineLock.ReqLockStatus = 1;
|
|
||||||
|
|
||||||
/***********************
|
|
||||||
* Call lineLock *
|
|
||||||
***********************/
|
|
||||||
printf("\nPEV: call EVSE lineLock\n");
|
|
||||||
|
|
||||||
if(call_lineLock(&service,&v2gHeader,&lineLock,&resultLineLock))
|
|
||||||
{
|
|
||||||
printErrorMessage(&service);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
|
|
||||||
/* show result of the answer message of EVSE sessionSetup*/
|
|
||||||
printf("PEV: received response message from EVSE\n");
|
|
||||||
printf("\tResponseCode=%d\n",resultLineLock.ResponseCode);
|
|
||||||
printEVSEStatus(&resultLineLock.EVSEStatus);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*********************************
|
|
||||||
* Setup data for powerDelivery *
|
|
||||||
*********************************/
|
|
||||||
|
|
||||||
powerDelivery.PEVStatus = lineLock.PEVStatus; /* PEV status, taken from lineLock */
|
|
||||||
/*powerDelivery.isused.Tariff = 0;
|
|
||||||
powerDelivery.Tariff = Green_charge_tariffIDType;*/
|
|
||||||
|
|
||||||
/***********************
|
|
||||||
* Call powerDelivery *
|
|
||||||
***********************/
|
|
||||||
printf("\nPEV: call EVSE powerDelivery\n");
|
|
||||||
|
|
||||||
if(call_powerDelivery(&service,&v2gHeader,&powerDelivery,&resultPowerDelivery))
|
|
||||||
{
|
|
||||||
printErrorMessage(&service);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
|
|
||||||
/* show result of the answer message of EVSE sessionSetup*/
|
|
||||||
printf("PEV: received response message from EVSE\n");
|
|
||||||
printf("\tResponseCode=%d\n",resultPowerDelivery.ResponseCode);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/********************
|
|
||||||
* Call meterStatus *
|
|
||||||
********************/
|
|
||||||
|
|
||||||
printf("\nPEV: call EVSE meterStatus\n");
|
|
||||||
|
|
||||||
if(call_meteringStatus(&service,&v2gHeader,&resultMeteringStatus))
|
|
||||||
{
|
|
||||||
printErrorMessage(&service);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
|
|
||||||
printf("PEV: received response message from EVSE\n");
|
|
||||||
printf("\tResponseCode=%d\n",resultPowerDiscovery.ResponseCode);
|
|
||||||
printEVSEStatus(&resultPowerDiscovery.EVSEStatus);
|
|
||||||
printf("\tEVSEID=%d\n",resultMeteringStatus.EVSEID.data[0]);
|
|
||||||
printf("\tEVSEMaxPower=%d\n",resultMeteringStatus.EVSEMaxPower.Value);
|
|
||||||
printf("\tisused.MeterInfo=%d\n", resultMeteringStatus.isused.MeterInfo);
|
|
||||||
printf("\t\tMeterInfo.MeterID=%d\n", resultMeteringStatus.MeterInfo.MeterID.data[0]);
|
|
||||||
printf("\t\tMeterInfo.MeterReading.Value=%d\n", resultMeteringStatus.MeterInfo.MeterReading.Value);
|
|
||||||
printf("\t\tMeterInfo.MeterStatus=%d\n", resultMeteringStatus.MeterInfo.MeterStatus);
|
|
||||||
/* printf("\t\tMeterInfo.TMeter=%d\n", resultMeteringStatus.MeterInfo.TMeter);*/
|
|
||||||
/* printf("\t\tisused.PCurrent=%d\n", resultMeteringStatus.isused.PCurrent);
|
|
||||||
printf("\t\tPCurrent=%d\n", resultMeteringStatus.PCurrent.Value);*/
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*********************************
|
|
||||||
* Setup data for meteringReceipt *
|
|
||||||
*********************************/
|
|
||||||
|
|
||||||
meteringReceipt.PEVID.arraylen.data=1;
|
|
||||||
meteringReceipt.PEVID.data[0]=10;
|
|
||||||
meteringReceipt.isused.PEVID=1;
|
|
||||||
|
|
||||||
meteringReceipt.PEVStatus = powerDelivery.PEVStatus; /* PEV status, taken from sessionSetup */
|
|
||||||
|
|
||||||
meteringReceipt.TCurrent = 12345;
|
|
||||||
meteringReceipt.isused.TCurrent = 1;
|
|
||||||
meteringReceipt.Tariff = Green_charge_tariffIDType;
|
|
||||||
meteringReceipt.MeterInfo.MeterStatus = 2;
|
|
||||||
meteringReceipt.MeterInfo.isused.MeterStatus = 1;
|
|
||||||
|
|
||||||
|
|
||||||
meteringReceipt.MeterInfo.MeterID.arraylen.data=1;
|
|
||||||
meteringReceipt.MeterInfo.MeterID.data[0]=3;
|
|
||||||
meteringReceipt.MeterInfo.isused.MeterID = 1;
|
|
||||||
|
|
||||||
meteringReceipt.MeterInfo.MeterReading.Multiplier = 0;
|
|
||||||
meteringReceipt.MeterInfo.MeterReading.Unit = A_unitSymbolType;
|
|
||||||
meteringReceipt.MeterInfo.MeterReading.Value = 500;
|
|
||||||
meteringReceipt.MeterInfo.isused.MeterReading = 1;
|
|
||||||
|
|
||||||
meteringReceipt.MeterInfo.TMeter =123456789;
|
|
||||||
meteringReceipt.MeterInfo.isused.TMeter = 1;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/***********************
|
|
||||||
* Call meteringReceipt *
|
|
||||||
***********************/
|
|
||||||
printf("\nPEV: call EVSE meteringReceipt\n");
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if(call_meteringReceipt(&service,&v2gHeader,&meteringReceipt,&resultMeteringReceipt))
|
|
||||||
{
|
|
||||||
printErrorMessage(&service);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* show result of the answer message of EVSE sessionSetup*/
|
|
||||||
printf("PEV: received response message from EVSE\n");
|
|
||||||
printf("\tResponseCode=%d\n",resultMeteringReceipt.ResponseCode);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
static int dc_charging()
|
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
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 ChargeParameterDiscoveryReqType powerDiscovery;
|
|
||||||
struct ChargeParameterDiscoveryResType resultPowerDiscovery;
|
|
||||||
struct CableCheckReqType cableCheck;
|
|
||||||
struct CableCheckResType resultCableCheck;
|
|
||||||
struct PowerDeliveryReqType powerDelivery;
|
|
||||||
struct PowerDeliveryResType resultPowerDelivery;
|
|
||||||
struct PreChargeReqType preCharge;
|
|
||||||
struct PreChargeResType resultPreCharge;
|
|
||||||
struct CurrentDemandReqType currentDemand;
|
|
||||||
struct CurrentDemandResType resultCurrentDemand;
|
|
||||||
struct WeldingDetectionReqType weldingDetection;
|
|
||||||
struct WeldingDetectionResType resultWeldingDetection;
|
|
||||||
struct TerminateChargingReqType terminateCharging;
|
|
||||||
struct TerminateChargingResType resultTerminateCharging;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
struct FloatingValueType float_type; /* test float type*/
|
|
||||||
|
|
||||||
|
|
||||||
/* 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;
|
|
||||||
|
|
||||||
|
|
||||||
/*******************
|
|
||||||
* 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: optional elements have to be set used (=1) or not used (=0) */
|
|
||||||
v2gHeader.SessionInformation.isused.ServiceSessionID = 0; /* service session is not used */
|
|
||||||
v2gHeader.isused.Notification=0; /* no notification */
|
|
||||||
|
|
||||||
/* setup sessionSetup parameter */
|
|
||||||
sessionSetup.isused.PEVID=1; /* no PEVID is transported */
|
|
||||||
sessionSetup.PEVID.arraylen.data=1;
|
|
||||||
sessionSetup.PEVID.data[0]=10;
|
|
||||||
sessionSetup.PEVStatus.ChargerStandby=0; /* 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]);
|
|
||||||
printEVSEStatus(&resultSessionSetup.EVSEStatus);
|
|
||||||
printf("\tTCurrent=%d\n",resultSessionSetup.TCurrent);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*******************************************
|
|
||||||
* Setup data for chargeParameterDiscovery *
|
|
||||||
*******************************************/
|
|
||||||
|
|
||||||
powerDiscovery.PEVStatus = sessionSetup.PEVStatus; /* PEV status, taken from sessionSetup */
|
|
||||||
powerDiscovery.EoC = 4321;
|
|
||||||
powerDiscovery.ChargingMode = DC_charging_chargingModeType;
|
|
||||||
|
|
||||||
float_type.Multiplier = 2;
|
|
||||||
float_type.Unit = A_unitSymbolType;
|
|
||||||
float_type.Value = 700;
|
|
||||||
|
|
||||||
float_type.Multiplier = 0;
|
|
||||||
float_type.Unit = J_unitSymbolType;
|
|
||||||
float_type.Value = 100;
|
|
||||||
|
|
||||||
powerDiscovery.EAmount = float_type;
|
|
||||||
powerDiscovery.PEVMaxPhases = 3;
|
|
||||||
|
|
||||||
float_type.Unit = W_unitSymbolType;
|
|
||||||
float_type.Value = 600;
|
|
||||||
powerDiscovery.PEVMaxPower = float_type;
|
|
||||||
|
|
||||||
float_type.Unit = V_unitSymbolType;
|
|
||||||
float_type.Value = 1000;
|
|
||||||
powerDiscovery.PEVMaxVoltage = float_type;
|
|
||||||
float_type.Value = 200;
|
|
||||||
powerDiscovery.PEVMinVoltage = float_type;
|
|
||||||
|
|
||||||
float_type.Unit = A_unitSymbolType;
|
|
||||||
float_type.Value = 800;
|
|
||||||
powerDiscovery.PEVMaxCurrent = float_type;
|
|
||||||
float_type.Value = 150;
|
|
||||||
powerDiscovery.PEVMinCurrent = float_type;
|
|
||||||
|
|
||||||
|
|
||||||
/*********************************
|
|
||||||
* Call chargeParameterDiscovery *
|
|
||||||
*********************************/
|
|
||||||
printf("\nPEV: call EVSE chargeParameterDiscovery\n");
|
|
||||||
|
|
||||||
if(call_chargeParameterDiscovery(&service,&v2gHeader,&powerDiscovery,&resultPowerDiscovery))
|
|
||||||
{
|
|
||||||
printErrorMessage(&service);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
|
|
||||||
/* show result of the answer message of EVSE sessionSetup*/
|
|
||||||
printf("PEV: received response message from EVSE\n");
|
|
||||||
printf("\tResponseCode=%d\n",resultPowerDiscovery.ResponseCode);
|
|
||||||
printEVSEStatus(&resultPowerDiscovery.EVSEStatus);
|
|
||||||
printf("\tEVSEMaxVoltage=%d\n",resultPowerDiscovery.EVSEMaxVoltage.Value);
|
|
||||||
printf("\tEVSEMaxCurrent=%d\n",resultPowerDiscovery.EVSEMaxCurrent.Value);
|
|
||||||
printf("\tEVSEMinCurrent=%d\n",resultPowerDiscovery.EVSEMinCurrent.Value);
|
|
||||||
printf("\tEVSEMaxPhases=%d\n",resultPowerDiscovery.EVSEMaxPhases);
|
|
||||||
|
|
||||||
/*printf("\tEnergyProvider=%d\n",resultPowerDiscovery.EnergyProvider.data[0]);*/
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/***********************
|
|
||||||
* Call cableCheck *
|
|
||||||
***********************/
|
|
||||||
printf("\nPEV: call EVSE cableCheck\n");
|
|
||||||
|
|
||||||
cableCheck.PEVStatus.ChargerStandby = 1;
|
|
||||||
cableCheck.PEVStatus.ConnectorLocked = 1;
|
|
||||||
cableCheck.PEVStatus.ReadyToCharge = 1;
|
|
||||||
|
|
||||||
|
|
||||||
if(call_cableCheck(&service,&v2gHeader,&cableCheck,&resultCableCheck))
|
|
||||||
{
|
|
||||||
printErrorMessage(&service);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
|
|
||||||
/* show result of the answer message of EVSE powerDiscovery*/
|
|
||||||
printf("PEV: received response message from EVSE\n");
|
|
||||||
printf("\tResponseCode=%d\n",resultCableCheck.ResponseCode);
|
|
||||||
printEVSEStatus(&resultCableCheck.EVSEStatus);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*********************************
|
|
||||||
* Setup data for powerDelivery *
|
|
||||||
*********************************/
|
|
||||||
|
|
||||||
powerDelivery.PEVStatus = cableCheck.PEVStatus; /* PEV status, taken from sessionSetup */
|
|
||||||
powerDelivery.isused.Tariff = 0;
|
|
||||||
/*powerDelivery.Tariff = Green_charge_tariffIDType;*/
|
|
||||||
|
|
||||||
/***********************
|
|
||||||
* Call powerDelivery *
|
|
||||||
***********************/
|
|
||||||
printf("\nPEV: call EVSE powerDelivery\n");
|
|
||||||
|
|
||||||
if(call_powerDelivery(&service,&v2gHeader,&powerDelivery,&resultPowerDelivery))
|
|
||||||
{
|
|
||||||
printErrorMessage(&service);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
|
|
||||||
/* show result of the answer message of EVSE sessionSetup*/
|
|
||||||
printf("PEV: received response message from EVSE\n");
|
|
||||||
printf("\tResponseCode=%d\n",resultPowerDelivery.ResponseCode);
|
|
||||||
printEVSEStatus(&resultPowerDelivery.EVSEStatus);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/***********************
|
|
||||||
* Call preCharge *
|
|
||||||
***********************/
|
|
||||||
printf("\nPEV: call EVSE preCharge\n");
|
|
||||||
|
|
||||||
preCharge.PEVStatus = cableCheck.PEVStatus;
|
|
||||||
float_type.Unit = A_unitSymbolType;
|
|
||||||
float_type.Value = 400;
|
|
||||||
preCharge.PEVDemandCurrent = float_type;
|
|
||||||
|
|
||||||
float_type.Unit = V_unitSymbolType;
|
|
||||||
float_type.Value = 700;
|
|
||||||
preCharge.PEVTargetVoltage = float_type;
|
|
||||||
float_type.Value = 300;
|
|
||||||
preCharge.VoltageDifferential = float_type;
|
|
||||||
|
|
||||||
if(call_preCharge(&service,&v2gHeader,&preCharge,&resultPreCharge))
|
|
||||||
{
|
|
||||||
printErrorMessage(&service);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
|
|
||||||
/* show result of the answer message of EVSE powerDiscovery*/
|
|
||||||
printf("PEV: received response message from EVSE\n");
|
|
||||||
printf("\tResponseCode=%d\n",resultPreCharge.ResponseCode);
|
|
||||||
printEVSEStatus(&resultPreCharge.EVSEStatus);
|
|
||||||
printf("\tEVSEPresentVoltage=%d\n",resultPreCharge.EVSEPresentVoltage.Value);
|
|
||||||
}
|
|
||||||
|
|
||||||
/***********************
|
|
||||||
* Call currentDemand *
|
|
||||||
***********************/
|
|
||||||
printf("\nPEV: call EVSE currentDemand\n");
|
|
||||||
|
|
||||||
currentDemand.PEVStatus = powerDelivery.PEVStatus;
|
|
||||||
|
|
||||||
float_type.Unit = A_unitSymbolType;
|
|
||||||
float_type.Value = 44;
|
|
||||||
currentDemand.CurrentDifferential = float_type;
|
|
||||||
|
|
||||||
float_type.Value = 40;
|
|
||||||
currentDemand.PEVDemandCurrent = float_type;
|
|
||||||
|
|
||||||
float_type.Unit = V_unitSymbolType;
|
|
||||||
float_type.Value = 300;
|
|
||||||
currentDemand.VoltageDifferential = float_type;
|
|
||||||
|
|
||||||
float_type.Value = 700;
|
|
||||||
preCharge.PEVTargetVoltage = float_type;
|
|
||||||
currentDemand.PEVTargetVoltage = float_type;
|
|
||||||
|
|
||||||
if(call_currentDemand(&service,&v2gHeader,¤tDemand,&resultCurrentDemand))
|
|
||||||
{
|
|
||||||
printErrorMessage(&service);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
|
|
||||||
/* show result of the answer message of EVSE powerDiscovery*/
|
|
||||||
printf("PEV: received response message from EVSE\n");
|
|
||||||
printf("\tResponseCode=%d\n",resultCurrentDemand.ResponseCode);
|
|
||||||
printEVSEStatus(&resultCurrentDemand.EVSEStatus);
|
|
||||||
printf("\tEVSEPresentVoltage.Value=%d\n",resultCurrentDemand.EVSEPresentVoltage.Value);
|
|
||||||
printf("\tEVSEPresentCurrent.Value=%d\n",resultCurrentDemand.EVSEPresentCurrent.Value);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/***********************
|
|
||||||
* Call weldingDetection *
|
|
||||||
***********************/
|
|
||||||
printf("\nPEV: call EVSE weldingDetection\n");
|
|
||||||
weldingDetection.PEVStatus = powerDelivery.PEVStatus;
|
|
||||||
|
|
||||||
if(call_weldingDetection(&service,&v2gHeader,&weldingDetection,&resultWeldingDetection))
|
|
||||||
{
|
|
||||||
printErrorMessage(&service);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
|
|
||||||
/* show result of the answer message of EVSE powerDiscovery*/
|
|
||||||
printf("PEV: received response message from EVSE\n");
|
|
||||||
printf("\tResponseCode=%d\n",resultWeldingDetection.ResponseCode);
|
|
||||||
printEVSEStatus(&resultWeldingDetection.EVSEStatus);
|
|
||||||
printf("\tEVSEPresentVoltage=%d\n",resultWeldingDetection.EVSEPresentVoltage.Value);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*************************
|
|
||||||
* Call terminateCharging*
|
|
||||||
*************************/
|
|
||||||
printf("\nPEV: call EVSE terminateCharging\n");
|
|
||||||
terminateCharging.PEVStatus = sessionSetup.PEVStatus;
|
|
||||||
|
|
||||||
if(call_terminateCharging(&service,&v2gHeader,&terminateCharging,&resultTerminateCharging))
|
|
||||||
{
|
|
||||||
printErrorMessage(&service);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
|
|
||||||
/* show result of the answer message of EVSE powerDiscovery*/
|
|
||||||
printf("PEV: received response message from EVSE\n");
|
|
||||||
printf("\tResponseCode=%d\n",resultTerminateCharging.ResponseCode);
|
|
||||||
printEVSEStatus(&resultWeldingDetection.EVSEStatus);
|
|
||||||
printf("\tEVSEPresentVoltage.Value=%d\n",resultTerminateCharging.EVSEPresentVoltage.Value);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int main_service()
|
|
||||||
{
|
|
||||||
printf("+++ Start V2G client / service example for AC charging +++\n\n");
|
|
||||||
|
|
||||||
ac_charging();
|
|
||||||
|
|
||||||
printf("\n+++Terminate V2G Client / Service example for AC charging +++\n");
|
|
||||||
printf("Please press enter for DC charging!\n");
|
|
||||||
fflush(stdout);
|
|
||||||
getchar();
|
|
||||||
|
|
||||||
printf("+++ Start V2G client / service example for DC charging +++\n\n");
|
|
||||||
|
|
||||||
dc_charging();
|
|
||||||
|
|
||||||
printf("\n+++Terminate V2G client / service example for DC charging +++");
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void printEVSEStatus(struct EVSEStatusType* status)
|
|
||||||
{
|
|
||||||
printf("\tEVSEStatus:\n\t\tConnectorLocked=%d\n",status->ConnectorLocked);
|
|
||||||
printf("\t\tEVSEStandby=%d\n",status->EVSEStandby);
|
|
||||||
printf("\t\tFatalError=%d\n",status->FatalError);
|
|
||||||
printf("\t\tPowerSwitchClosed=%d\n",status->PowerSwitchClosed);
|
|
||||||
printf("\t\tRCD=%d\n",status->RCD);
|
|
||||||
printf("\t\tChargerStandby=%d\n",status->ChargerStandby);
|
|
||||||
printf("\t\tEVSEMalfunction=%d\n",status->EVSEMalfunction);
|
|
||||||
printf("\t\tShutDownTime=%d\n",status->ShutDownTime);
|
|
||||||
}
|
|
||||||
|
|
||||||
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");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,90 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (C) 2007-2011 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.4
|
|
||||||
* @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;
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,33 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (C) 2007-2011 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.4
|
|
||||||
* @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_ */
|
|
|
@ -1,47 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (C) 2007-2011 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.4
|
|
||||||
* @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);
|
|
||||||
}
|
|
|
@ -1,377 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (C) 2007-2011 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.4
|
|
||||||
* @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:\n\t\t\t ChargerStandby=%d\n",param->PEVStatus.ChargerStandby);
|
|
||||||
printf("\t\t\t ConnectorLocked=%d\n", param->PEVStatus.ConnectorLocked);
|
|
||||||
printf("\t\t\t ReadyToCharge=%d\n", param->PEVStatus.ReadyToCharge);
|
|
||||||
|
|
||||||
/* Prepare data for PEV */
|
|
||||||
result->ResponseCode = OK_SessionSetup_responseCode_SessionSetupType;
|
|
||||||
result->EVSEID.data[0]=1;
|
|
||||||
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=12345678;
|
|
||||||
result->EVSEStatus.ChargerStandby = 1;
|
|
||||||
result->EVSEStatus.EVSEMalfunction = 0;
|
|
||||||
result->TCurrent=12345678;
|
|
||||||
|
|
||||||
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 chargeParameterDiscovery(struct ChargeParameterDiscoveryReqType* param, struct ChargeParameterDiscoveryResType* result)
|
|
||||||
{
|
|
||||||
printf("EVSE: chargeParameterDiscovery called\n" );
|
|
||||||
printf("\tReceived data:\n");
|
|
||||||
printf("\t\t PEVStatus:\n\t\t\t ChargerStandby=%d\n",param->PEVStatus.ChargerStandby);
|
|
||||||
printf("\t\t\t ConnectorLocked=%d\n", param->PEVStatus.ConnectorLocked);
|
|
||||||
printf("\t\t\t ReadyToCharge=%d\n", param->PEVStatus.ReadyToCharge);
|
|
||||||
|
|
||||||
if(param->ChargingMode==AC_charging_chargingModeType)
|
|
||||||
printf("\t\t ChargingMode=AC_charging\n");
|
|
||||||
else
|
|
||||||
printf("\t\t ChargingMode=DC_charging\n");
|
|
||||||
|
|
||||||
printf("\t\t Eoc=%d\n", param->EoC);
|
|
||||||
printf("\t\t EAmount=%d\n", param->EAmount.Value);
|
|
||||||
printf("\t\t PEVMaxPower=%d\n", param->PEVMaxPower.Value);
|
|
||||||
printf("\t\t PEVMaxPhases=%d\n", param->PEVMaxPhases);
|
|
||||||
printf("\t\t PEVMaxVoltage=%d\n", param->PEVMaxVoltage.Value);
|
|
||||||
printf("\t\t PEVMinVoltage=%d\n", param->PEVMinVoltage.Value);
|
|
||||||
|
|
||||||
|
|
||||||
if(param->ChargingMode==DC_charging_chargingModeType)
|
|
||||||
{
|
|
||||||
printf("\t\t PEVMaxCurrent=%d\n", param->PEVMaxCurrent.Value);
|
|
||||||
printf("\t\t PEVMinCurrent=%d\n", param->PEVMinCurrent.Value);
|
|
||||||
}
|
|
||||||
|
|
||||||
result->ResponseCode = 0;
|
|
||||||
result->EVSEStatus.ConnectorLocked=0;
|
|
||||||
result->EVSEStatus.FatalError=0;
|
|
||||||
result->EVSEStatus.EVSEStandby=1;
|
|
||||||
result->EVSEStatus.PowerSwitchClosed=0;
|
|
||||||
result->EVSEStatus.RCD=1;
|
|
||||||
result->EVSEStatus.ShutDownTime=12345;
|
|
||||||
result->EVSEStatus.ChargerStandby = 1;
|
|
||||||
result->EVSEStatus.EVSEMalfunction = 0;
|
|
||||||
result->EVSEMaxVoltage.Multiplier = 0;
|
|
||||||
result->EVSEMaxVoltage.Unit = V_unitSymbolType;
|
|
||||||
result->EVSEMaxVoltage.Value = 950;
|
|
||||||
result->EVSEMaxPhases = 3;
|
|
||||||
|
|
||||||
/* only for DC charging */
|
|
||||||
result->EVSEMaxCurrent.Multiplier = 0;
|
|
||||||
result->EVSEMaxCurrent.Unit = A_unitSymbolType;
|
|
||||||
result->EVSEMaxCurrent.Value = 10;
|
|
||||||
result->EVSEMinCurrent.Multiplier = 0;
|
|
||||||
result->EVSEMinCurrent.Unit = A_unitSymbolType;
|
|
||||||
result->EVSEMinCurrent.Value = 2;
|
|
||||||
|
|
||||||
|
|
||||||
result->isused.EnergyProvider=0;
|
|
||||||
/*result->EnergyProvider.arraylen.data=1;
|
|
||||||
result->EnergyProvider.data[0]=11; */
|
|
||||||
result->isused.TariffTable = 0;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int lineLock(struct LineLockReqType* param, struct LineLockResType* result)
|
|
||||||
{
|
|
||||||
printf("EVSE: lineLock called\n" );
|
|
||||||
printf("\tReceived data:\n");
|
|
||||||
printf("\t\t PEVStatus:\n\t\t\t ChargerStandby=%d\n",param->PEVStatus.ChargerStandby);
|
|
||||||
printf("\t\t\t ConnectorLocked=%d\n", param->PEVStatus.ConnectorLocked);
|
|
||||||
printf("\t\t\t ReadyToCharge=%d\n", param->PEVStatus.ReadyToCharge);
|
|
||||||
printf("\t\t ReqLockStatus=%d\n", param->ReqLockStatus);
|
|
||||||
|
|
||||||
result->ResponseCode = 0;
|
|
||||||
result->EVSEStatus.ConnectorLocked=0;
|
|
||||||
result->EVSEStatus.FatalError=0;
|
|
||||||
result->EVSEStatus.EVSEStandby=1;
|
|
||||||
result->EVSEStatus.PowerSwitchClosed=1;
|
|
||||||
result->EVSEStatus.RCD=1;
|
|
||||||
result->EVSEStatus.ShutDownTime=12345;
|
|
||||||
result->EVSEStatus.ChargerStandby = 1;
|
|
||||||
result->EVSEStatus.EVSEMalfunction = 0;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int powerDelivery(struct PowerDeliveryReqType* param, struct PowerDeliveryResType* result)
|
|
||||||
{
|
|
||||||
printf("EVSE: powerDelivery called\n" );
|
|
||||||
printf("\tReceived data:\n");
|
|
||||||
printf("\t\t PEVStatus:\n\t\t\t ChargerStandby=%d\n",param->PEVStatus.ChargerStandby);
|
|
||||||
printf("\t\t\t ConnectorLocked=%d\n", param->PEVStatus.ConnectorLocked);
|
|
||||||
printf("\t\t\t ReadyToCharge=%d\n", param->PEVStatus.ReadyToCharge);
|
|
||||||
|
|
||||||
result->ResponseCode=0;
|
|
||||||
result->EVSEStatus.ConnectorLocked=0;
|
|
||||||
result->EVSEStatus.FatalError=0;
|
|
||||||
result->EVSEStatus.EVSEStandby=1;
|
|
||||||
result->EVSEStatus.PowerSwitchClosed=1;
|
|
||||||
result->EVSEStatus.RCD=1;
|
|
||||||
result->EVSEStatus.ShutDownTime=12345;
|
|
||||||
result->EVSEStatus.ChargerStandby = 1;
|
|
||||||
result->EVSEStatus.EVSEMalfunction = 0;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int meteringStatus(struct MeteringStatusReqType* param, struct MeteringStatusResType* result)
|
|
||||||
{
|
|
||||||
printf("EVSE: meteringStatus called\n" );
|
|
||||||
|
|
||||||
result->ResponseCode=1;
|
|
||||||
result->EVSEID.data[0]=1;
|
|
||||||
result->EVSEID.arraylen.data=1;
|
|
||||||
result->EVSEStatus.ConnectorLocked=1;
|
|
||||||
result->EVSEStatus.EVSEStandby=1;
|
|
||||||
result->EVSEStatus.FatalError=0;
|
|
||||||
result->EVSEStatus.PowerSwitchClosed=1;
|
|
||||||
result->EVSEStatus.RCD=1;
|
|
||||||
result->EVSEStatus.ShutDownTime=12345678;
|
|
||||||
result->EVSEStatus.EVSEMalfunction = 0;
|
|
||||||
result->EVSEStatus.ChargerStandby = 1;
|
|
||||||
result->TCurrent=12345678;
|
|
||||||
result->EVSEMaxPower.Multiplier = 2;
|
|
||||||
result->EVSEMaxPower.Unit = A_unitSymbolType;
|
|
||||||
result->EVSEMaxPower.Value = 400;
|
|
||||||
|
|
||||||
result->isused.MeterInfo=1;
|
|
||||||
result->MeterInfo.MeterID.arraylen.data=1;
|
|
||||||
result->MeterInfo.MeterID.data[0]=2;
|
|
||||||
result->MeterInfo.MeterReading.Multiplier = 0;
|
|
||||||
result->MeterInfo.MeterReading.Unit = A_unitSymbolType;
|
|
||||||
result->MeterInfo.MeterReading.Value = 500;
|
|
||||||
result->MeterInfo.MeterStatus = 4321;
|
|
||||||
result->MeterInfo.TMeter =123456789;
|
|
||||||
result->MeterInfo.isused.MeterID=1;
|
|
||||||
result->MeterInfo.isused.MeterReading = 1;
|
|
||||||
result->MeterInfo.isused.MeterStatus=1;
|
|
||||||
result->MeterInfo.isused.TMeter=1;
|
|
||||||
|
|
||||||
result->isused.PCurrent=1;
|
|
||||||
result->PCurrent.Value=4321;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int meteringReceipt(struct MeteringReceiptReqType* param, struct MeteringReceiptResType* result)
|
|
||||||
{
|
|
||||||
|
|
||||||
printf("EVSE: meteringReceipt called\n" );
|
|
||||||
printf("\tReceived data:\n");
|
|
||||||
printf("\t\t PEVStatus:\n\t\t\t ChargerStandby=%d\n",param->PEVStatus.ChargerStandby);
|
|
||||||
printf("\t\t\t ConnectorLocked=%d\n", param->PEVStatus.ConnectorLocked);
|
|
||||||
printf("\t\t\t ReadyToCharge=%d\n", param->PEVStatus.ReadyToCharge);
|
|
||||||
printf("\t\t TCurrent=%d\n", param->TCurrent);
|
|
||||||
printf("\t\t MeterInfo.MeterStatus=%d\n", param->MeterInfo.MeterStatus);
|
|
||||||
printf("\t\t MeterInfo.MeterID=%d\n", param->MeterInfo.MeterID.data[0]);
|
|
||||||
printf("\t\t MeterInfo.isused.MeterReading=%d\n", param->MeterInfo.isused.MeterReading);
|
|
||||||
printf("\t\t MeterReading.Value=%d\n", param->MeterInfo.MeterReading.Value);
|
|
||||||
printf("\t\t MeterInfo.TMeter=%d\n", param->MeterInfo.TMeter);
|
|
||||||
if(param->Tariff==Green_charge_tariffIDType)
|
|
||||||
printf("\t\t Tariff==Green_charge_tariffIDType\n");
|
|
||||||
result->ResponseCode = 0;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int cableCheck(struct CableCheckReqType* param, struct CableCheckResType* result)
|
|
||||||
{
|
|
||||||
printf("EVSE: cableCheck called\n" );
|
|
||||||
printf("\tReceived data:\n");
|
|
||||||
printf("\t\t PEVStatus:\n\t\t\t ChargerStandby=%d\n",param->PEVStatus.ChargerStandby);
|
|
||||||
printf("\t\t\t ConnectorLocked=%d\n", param->PEVStatus.ConnectorLocked);
|
|
||||||
printf("\t\t\t ReadyToCharge=%d\n", param->PEVStatus.ReadyToCharge);
|
|
||||||
|
|
||||||
result->EVSEStatus.ConnectorLocked=1;
|
|
||||||
result->EVSEStatus.EVSEStandby=1;
|
|
||||||
result->EVSEStatus.FatalError=0;
|
|
||||||
result->EVSEStatus.PowerSwitchClosed=1;
|
|
||||||
result->EVSEStatus.RCD=1;
|
|
||||||
result->EVSEStatus.ShutDownTime=12345678;
|
|
||||||
result->EVSEStatus.EVSEMalfunction = 0;
|
|
||||||
result->EVSEStatus.ChargerStandby = 1;
|
|
||||||
|
|
||||||
result->ResponseCode = OK_responseCode_CableCheckType;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int preCharge(struct PreChargeReqType* param, struct PreChargeResType* result)
|
|
||||||
{
|
|
||||||
struct FloatingValueType float_type;
|
|
||||||
float_type.Multiplier = 0;
|
|
||||||
float_type.Unit = V_unitSymbolType;
|
|
||||||
|
|
||||||
printf("EVSE: currentDemand called\n" );
|
|
||||||
printf("\tReceived data:\n");
|
|
||||||
printf("\t\t PEVStatus:\n\t\t\t ChargerStandby=%d\n",param->PEVStatus.ChargerStandby);
|
|
||||||
printf("\t\t\t ConnectorLocked=%d\n", param->PEVStatus.ConnectorLocked);
|
|
||||||
printf("\t\t\t ReadyToCharge=%d\n", param->PEVStatus.ReadyToCharge);
|
|
||||||
|
|
||||||
printf("\t\t PEVDemandCurrent=%d\n",param->PEVDemandCurrent.Value);
|
|
||||||
printf("\t\t PEVTargetVoltage=%d\n", param->PEVTargetVoltage.Value);
|
|
||||||
|
|
||||||
result->ResponseCode=OK_responseCode_CurrentDemandType;
|
|
||||||
result->EVSEStatus.ConnectorLocked=1;
|
|
||||||
result->EVSEStatus.EVSEStandby=1;
|
|
||||||
result->EVSEStatus.FatalError=0;
|
|
||||||
result->EVSEStatus.PowerSwitchClosed=1;
|
|
||||||
result->EVSEStatus.RCD=1;
|
|
||||||
result->EVSEStatus.ShutDownTime=12345678;
|
|
||||||
result->EVSEStatus.ChargerStandby=1;
|
|
||||||
result->EVSEStatus.EVSEMalfunction=0;
|
|
||||||
result->EVSEStatus.StopCharging=0;
|
|
||||||
|
|
||||||
float_type.Value = 800;
|
|
||||||
|
|
||||||
result->EVSEPresentVoltage = float_type;
|
|
||||||
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
int currentDemand(struct CurrentDemandReqType* param, struct CurrentDemandResType* result)
|
|
||||||
{
|
|
||||||
struct FloatingValueType float_type;
|
|
||||||
float_type.Multiplier = 0;
|
|
||||||
|
|
||||||
printf("EVSE: currentDemand called\n" );
|
|
||||||
printf("\tReceived data:\n");
|
|
||||||
printf("\t\t PEVStatus:\n\t\t\t ChargerStandby=%d\n",param->PEVStatus.ChargerStandby);
|
|
||||||
printf("\t\t\t ConnectorLocked=%d\n", param->PEVStatus.ConnectorLocked);
|
|
||||||
printf("\t\t\t ReadyToCharge=%d\n", param->PEVStatus.ReadyToCharge);
|
|
||||||
|
|
||||||
printf("\t\t PEVDemandCurrent=%d\n",param->PEVDemandCurrent.Value);
|
|
||||||
printf("\t\t PEVTargetVoltage=%d\n", param->PEVTargetVoltage.Value);
|
|
||||||
|
|
||||||
result->EVSEStatus.ConnectorLocked=1;
|
|
||||||
result->EVSEStatus.EVSEStandby=1;
|
|
||||||
result->EVSEStatus.FatalError=0;
|
|
||||||
result->EVSEStatus.PowerSwitchClosed=1;
|
|
||||||
result->EVSEStatus.RCD=1;
|
|
||||||
result->EVSEStatus.ShutDownTime=12345678;
|
|
||||||
result->EVSEStatus.ChargerStandby=1;
|
|
||||||
result->EVSEStatus.EVSEMalfunction=0;
|
|
||||||
result->EVSEStatus.StopCharging=0;
|
|
||||||
result->ResponseCode=OK_responseCode_CurrentDemandType;
|
|
||||||
|
|
||||||
float_type.Unit = A_unitSymbolType;
|
|
||||||
float_type.Value = 40;
|
|
||||||
result->EVSEPresentCurrent = float_type;
|
|
||||||
|
|
||||||
float_type.Unit = V_unitSymbolType;
|
|
||||||
float_type.Value = 700;
|
|
||||||
result->EVSEPresentVoltage = float_type;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int weldingDetection(struct WeldingDetectionReqType* param, struct WeldingDetectionResType* result)
|
|
||||||
{
|
|
||||||
struct FloatingValueType float_type;
|
|
||||||
float_type.Multiplier = 0;
|
|
||||||
float_type.Unit = V_unitSymbolType;
|
|
||||||
float_type.Value = 0;
|
|
||||||
|
|
||||||
printf("EVSE: weldingDetection called\n" );
|
|
||||||
printf("\tReceived data:\n");
|
|
||||||
printf("\t\t PEVStatus:\n\t\t\t ChargerStandby=%d\n",param->PEVStatus.ChargerStandby);
|
|
||||||
printf("\t\t\t ConnectorLocked=%d\n", param->PEVStatus.ConnectorLocked);
|
|
||||||
printf("\t\t\t ReadyToCharge=%d\n", param->PEVStatus.ReadyToCharge);
|
|
||||||
|
|
||||||
result->ResponseCode = OK_responseCode_WeldingDetectionType;
|
|
||||||
|
|
||||||
result->EVSEStatus.ConnectorLocked=1;
|
|
||||||
result->EVSEStatus.EVSEStandby=1;
|
|
||||||
result->EVSEStatus.FatalError=0;
|
|
||||||
result->EVSEStatus.PowerSwitchClosed=1;
|
|
||||||
result->EVSEStatus.RCD=1;
|
|
||||||
result->EVSEStatus.ShutDownTime=12345678;
|
|
||||||
result->EVSEStatus.ChargerStandby=1;
|
|
||||||
result->EVSEStatus.EVSEMalfunction=0;
|
|
||||||
result->EVSEStatus.StopCharging=0;
|
|
||||||
|
|
||||||
result->EVSEPresentVoltage=float_type;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int terminateCharging(struct TerminateChargingReqType* param, struct TerminateChargingResType* result)
|
|
||||||
{
|
|
||||||
struct FloatingValueType float_type;
|
|
||||||
float_type.Multiplier = 0;
|
|
||||||
float_type.Unit = V_unitSymbolType;
|
|
||||||
float_type.Value =0;
|
|
||||||
|
|
||||||
printf("EVSE: terminateCharging called\n" );
|
|
||||||
printf("\tReceived data:\n");
|
|
||||||
printf("\t\t PEVStatus:\n\t\t\t ChargerStandby=%d\n",param->PEVStatus.ChargerStandby);
|
|
||||||
printf("\t\t\t ConnectorLocked=%d\n", param->PEVStatus.ConnectorLocked);
|
|
||||||
printf("\t\t\t ReadyToCharge=%d\n", param->PEVStatus.ReadyToCharge);
|
|
||||||
|
|
||||||
result->EVSEPresentVoltage = float_type;
|
|
||||||
result->ResponseCode = OK_responseCode_TerminateChargingType;
|
|
||||||
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,117 +0,0 @@
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright (C) 2007-2011 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.4
|
|
||||||
* @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;
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,68 +0,0 @@
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright (C) 2007-2011 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.4
|
|
||||||
* @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
|
|
Loading…
Reference in a new issue