- changed Tool Chain Editor from 'MinGW GCC' to 'Linux GCC'

- added test/network_expample_1 --> TCP-Server for EVSE
This commit is contained in:
mlauterbach 2010-10-27 08:45:20 +00:00
parent a927dec294
commit 852d4dbcfa
7 changed files with 1399 additions and 1020 deletions

View file

@ -16,43 +16,34 @@
<storageModule moduleId="cdtBuildSystem" version="4.0.0"> <storageModule moduleId="cdtBuildSystem" version="4.0.0">
<configuration artifactName="OpenV2G" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe" buildProperties="org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.debug,org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe" cleanCommand="rm -rf" description="" id="cdt.managedbuild.config.gnu.mingw.exe.debug.181718907" name="Debug" parent="cdt.managedbuild.config.gnu.mingw.exe.debug"> <configuration artifactName="OpenV2G" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe" buildProperties="org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.debug,org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe" cleanCommand="rm -rf" description="" id="cdt.managedbuild.config.gnu.mingw.exe.debug.181718907" name="Debug" parent="cdt.managedbuild.config.gnu.mingw.exe.debug">
<folderInfo id="cdt.managedbuild.config.gnu.mingw.exe.debug.181718907." name="/" resourcePath=""> <folderInfo id="cdt.managedbuild.config.gnu.mingw.exe.debug.181718907." name="/" resourcePath="">
<toolChain id="cdt.managedbuild.toolchain.gnu.mingw.exe.debug.876485680" name="MinGW GCC" superClass="cdt.managedbuild.toolchain.gnu.mingw.exe.debug"> <toolChain id="cdt.managedbuild.toolchain.gnu.mingw.base.61547579" name="MinGW GCC" superClass="cdt.managedbuild.toolchain.gnu.mingw.base">
<targetPlatform id="cdt.managedbuild.target.gnu.platform.mingw.exe.debug.457244346" name="Debug Platform" superClass="cdt.managedbuild.target.gnu.platform.mingw.exe.debug"/> <targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.PE" id="cdt.managedbuild.target.gnu.platform.mingw.base.2111260617" name="Debug Platform" osList="win32" superClass="cdt.managedbuild.target.gnu.platform.mingw.base"/>
<builder buildPath="${workspace_loc:/OpenV2G/Debug}" id="cdt.managedbuild.tool.gnu.builder.mingw.base.312232103" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="CDT Internal Builder" superClass="cdt.managedbuild.tool.gnu.builder.mingw.base"/> <builder buildPath="${workspace_loc:/OpenV2G/Debug}" id="cdt.managedbuild.tool.gnu.builder.mingw.base.1906140327" name="CDT Internal Builder.Debug" superClass="cdt.managedbuild.tool.gnu.builder.mingw.base"/>
<tool id="cdt.managedbuild.tool.gnu.assembler.mingw.exe.debug.1400631881" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.mingw.exe.debug"> <tool id="cdt.managedbuild.tool.gnu.assembler.mingw.base.1571190553" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.mingw.base">
<inputType id="cdt.managedbuild.tool.gnu.assembler.input.1072508302" superClass="cdt.managedbuild.tool.gnu.assembler.input"/> <inputType id="cdt.managedbuild.tool.gnu.assembler.input.1866737768" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
</tool> </tool>
<tool id="cdt.managedbuild.tool.gnu.archiver.mingw.base.1769540501" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.mingw.base"/> <tool id="cdt.managedbuild.tool.gnu.archiver.mingw.base.1290025209" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.mingw.base"/>
<tool id="cdt.managedbuild.tool.gnu.cpp.compiler.mingw.exe.debug.1144566927" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.mingw.exe.debug"> <tool id="cdt.managedbuild.tool.gnu.cpp.compiler.mingw.base.390259959" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.mingw.base">
<option id="gnu.cpp.compiler.mingw.exe.debug.option.optimization.level.1036013605" name="Optimization Level" superClass="gnu.cpp.compiler.mingw.exe.debug.option.optimization.level" value="gnu.cpp.compiler.optimization.level.none" valueType="enumerated"/> <option id="gnu.cpp.compiler.option.optimization.level.1512753216" superClass="gnu.cpp.compiler.option.optimization.level" value="gnu.cpp.compiler.optimization.level.none" valueType="enumerated"/>
<option id="gnu.cpp.compiler.mingw.exe.debug.option.debugging.level.1326060222" name="Debug Level" superClass="gnu.cpp.compiler.mingw.exe.debug.option.debugging.level" value="gnu.cpp.compiler.debugging.level.max" valueType="enumerated"/> <option id="gnu.cpp.compiler.option.debugging.level.531182604" superClass="gnu.cpp.compiler.option.debugging.level" value="gnu.cpp.compiler.debugging.level.max" valueType="enumerated"/>
</tool> </tool>
<tool id="cdt.managedbuild.tool.gnu.c.compiler.mingw.exe.debug.113647340" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.mingw.exe.debug"> <tool id="cdt.managedbuild.tool.gnu.c.compiler.mingw.base.949740711" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.mingw.base">
<option defaultValue="gnu.c.optimization.level.none" id="gnu.c.compiler.mingw.exe.debug.option.optimization.level.1898653479" name="Optimization Level" superClass="gnu.c.compiler.mingw.exe.debug.option.optimization.level" value="gnu.c.optimization.level.none" valueType="enumerated"/> <option id="gnu.c.compiler.option.include.paths.2099943524" superClass="gnu.c.compiler.option.include.paths" valueType="includePath">
<option id="gnu.c.compiler.mingw.exe.debug.option.debugging.level.294845555" name="Debug Level" superClass="gnu.c.compiler.mingw.exe.debug.option.debugging.level" value="gnu.c.debugging.level.max" valueType="enumerated"/>
<option id="gnu.c.compiler.option.include.paths.773068816" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/OpenV2G/src/codec}&quot;"/> <listOptionValue builtIn="false" value="&quot;${workspace_loc:/OpenV2G/src/codec}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/OpenV2G/src/service}&quot;"/> <listOptionValue builtIn="false" value="&quot;${workspace_loc:/OpenV2G/src/service}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/OpenV2G/src/test}&quot;"/> <listOptionValue builtIn="false" value="&quot;${workspace_loc:/OpenV2G/src/test}&quot;"/>
</option> </option>
<option id="gnu.c.compiler.option.warnings.pedantic.1676854851" name="Pedantic (-pedantic)" superClass="gnu.c.compiler.option.warnings.pedantic" value="true" valueType="boolean"/> <option defaultValue="gnu.c.optimization.level.none" id="gnu.c.compiler.option.optimization.level.462712729" superClass="gnu.c.compiler.option.optimization.level" valueType="enumerated"/>
<option id="gnu.c.compiler.option.misc.ansi.722225100" name="Support ANSI programs (-ansi)" superClass="gnu.c.compiler.option.misc.ansi" value="true" valueType="boolean"/> <option id="gnu.c.compiler.option.debugging.level.1008589022" superClass="gnu.c.compiler.option.debugging.level" value="gnu.c.debugging.level.max" valueType="enumerated"/>
<option id="gnu.c.compiler.option.optimization.flags.1389725002" name="Other optimization flags" superClass="gnu.c.compiler.option.optimization.flags" value="" valueType="string"/> <inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.2007502172" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
<option id="gnu.c.compiler.option.warnings.pedantic.error.149509232" name="Pedantic warnings as errors (-pedantic-errors)" superClass="gnu.c.compiler.option.warnings.pedantic.error" value="true" valueType="boolean"/>
<option id="gnu.c.compiler.option.misc.verbose.538510822" name="Verbose (-v)" superClass="gnu.c.compiler.option.misc.verbose" value="false" valueType="boolean"/>
<option id="gnu.c.compiler.option.warnings.toerrors.333094291" name="Warnings as errors (-Werror)" superClass="gnu.c.compiler.option.warnings.toerrors" value="false" valueType="boolean"/>
<option id="gnu.c.compiler.option.warnings.nowarn.1833719087" name="Inhibit all warnings (-w)" superClass="gnu.c.compiler.option.warnings.nowarn" value="false" valueType="boolean"/>
<option id="gnu.c.compiler.option.warnings.syntax.1603120263" name="Check syntax only (-fsyntax-only)" superClass="gnu.c.compiler.option.warnings.syntax" value="false" valueType="boolean"/>
<option id="gnu.c.compiler.option.warnings.allwarn.1391825268" name="All warnings (-Wall)" superClass="gnu.c.compiler.option.warnings.allwarn" value="true" valueType="boolean"/>
<inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.67299528" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
</tool> </tool>
<tool id="cdt.managedbuild.tool.gnu.c.linker.mingw.exe.debug.867726048" name="MinGW C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.mingw.exe.debug"> <tool id="cdt.managedbuild.tool.gnu.c.linker.mingw.base.1261045096" name="MinGW C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.mingw.base">
<inputType id="cdt.managedbuild.tool.gnu.c.linker.input.343385996" superClass="cdt.managedbuild.tool.gnu.c.linker.input"> <inputType id="cdt.managedbuild.tool.gnu.c.linker.input.605182894" superClass="cdt.managedbuild.tool.gnu.c.linker.input">
<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/> <additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
<additionalInput kind="additionalinput" paths="$(LIBS)"/> <additionalInput kind="additionalinput" paths="$(LIBS)"/>
</inputType> </inputType>
</tool> </tool>
<tool id="cdt.managedbuild.tool.gnu.cpp.linker.mingw.exe.debug.895012244" name="MinGW C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.mingw.exe.debug"/> <tool id="cdt.managedbuild.tool.gnu.cpp.linker.mingw.base.1948082912" name="MinGW C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.mingw.base"/>
</toolChain> </toolChain>
</folderInfo> </folderInfo>
<sourceEntries> <sourceEntries>
@ -483,44 +474,44 @@
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.config.gnu.mingw.exe.release.681614450" moduleId="org.eclipse.cdt.core.settings" name="Release"> <storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.config.gnu.mingw.exe.release.681614450" moduleId="org.eclipse.cdt.core.settings" name="Release">
<externalSettings/> <externalSettings/>
<extensions> <extensions>
<extension id="org.eclipse.cdt.core.PE" point="org.eclipse.cdt.core.BinaryParser"/> <extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> <extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> <extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> <extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.MakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
</extensions> </extensions>
</storageModule> </storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0"> <storageModule moduleId="cdtBuildSystem" version="4.0.0">
<configuration artifactName="OpenV2G" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe" buildProperties="org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.release,org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe" cleanCommand="rm -rf" description="" id="cdt.managedbuild.config.gnu.mingw.exe.release.681614450" name="Release" parent="cdt.managedbuild.config.gnu.mingw.exe.release"> <configuration artifactName="OpenV2G" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe" buildProperties="org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.release,org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe" cleanCommand="rm -rf" description="" id="cdt.managedbuild.config.gnu.mingw.exe.release.681614450" name="Release" parent="cdt.managedbuild.config.gnu.mingw.exe.release">
<folderInfo id="cdt.managedbuild.config.gnu.mingw.exe.release.681614450." name="/" resourcePath=""> <folderInfo id="cdt.managedbuild.config.gnu.mingw.exe.release.681614450." name="/" resourcePath="">
<toolChain id="cdt.managedbuild.toolchain.gnu.mingw.exe.release.2035335846" name="MinGW GCC" superClass="cdt.managedbuild.toolchain.gnu.mingw.exe.release"> <toolChain id="cdt.managedbuild.toolchain.gnu.base.506532925" name="Linux GCC" superClass="cdt.managedbuild.toolchain.gnu.base">
<targetPlatform id="cdt.managedbuild.target.gnu.platform.mingw.exe.release.123106486" name="Debug Platform" superClass="cdt.managedbuild.target.gnu.platform.mingw.exe.release"/> <targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="cdt.managedbuild.target.gnu.platform.base.784544317" name="Debug Platform" osList="linux,hpux,aix,qnx" superClass="cdt.managedbuild.target.gnu.platform.base"/>
<builder buildPath="${workspace_loc:/OpenV2G/Release}" id="cdt.managedbuild.tool.gnu.builder.mingw.base.660697414" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="CDT Internal Builder" superClass="cdt.managedbuild.tool.gnu.builder.mingw.base"/> <builder buildPath="${workspace_loc:/OpenV2G/Release}" id="cdt.managedbuild.target.gnu.builder.base.903692170" name="Gnu Make Builder.Release" superClass="cdt.managedbuild.target.gnu.builder.base"/>
<tool id="cdt.managedbuild.tool.gnu.assembler.mingw.exe.release.495179675" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.mingw.exe.release"> <tool id="cdt.managedbuild.tool.gnu.archiver.base.501212056" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.base"/>
<inputType id="cdt.managedbuild.tool.gnu.assembler.input.1609271173" superClass="cdt.managedbuild.tool.gnu.assembler.input"/> <tool id="cdt.managedbuild.tool.gnu.cpp.compiler.base.605628336" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.base">
<option id="gnu.cpp.compiler.option.optimization.level.937286096" superClass="gnu.cpp.compiler.option.optimization.level" value="gnu.cpp.compiler.optimization.level.most" valueType="enumerated"/>
<option id="gnu.cpp.compiler.option.debugging.level.1762244177" superClass="gnu.cpp.compiler.option.debugging.level" value="gnu.cpp.compiler.debugging.level.none" valueType="enumerated"/>
</tool> </tool>
<tool id="cdt.managedbuild.tool.gnu.archiver.mingw.base.1798958359" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.mingw.base"/> <tool id="cdt.managedbuild.tool.gnu.c.compiler.base.1358204014" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.base">
<tool id="cdt.managedbuild.tool.gnu.cpp.compiler.mingw.exe.release.1816121644" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.mingw.exe.release"> <option id="gnu.c.compiler.option.include.paths.1801191227" superClass="gnu.c.compiler.option.include.paths" valueType="includePath">
<option id="gnu.cpp.compiler.mingw.exe.release.option.optimization.level.1885785748" name="Optimization Level" superClass="gnu.cpp.compiler.mingw.exe.release.option.optimization.level" value="gnu.cpp.compiler.optimization.level.most" valueType="enumerated"/>
<option id="gnu.cpp.compiler.mingw.exe.release.option.debugging.level.1323278871" name="Debug Level" superClass="gnu.cpp.compiler.mingw.exe.release.option.debugging.level" value="gnu.cpp.compiler.debugging.level.none" valueType="enumerated"/>
</tool>
<tool id="cdt.managedbuild.tool.gnu.c.compiler.mingw.exe.release.150928873" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.mingw.exe.release">
<option defaultValue="gnu.c.optimization.level.most" id="gnu.c.compiler.mingw.exe.release.option.optimization.level.939780170" name="Optimization Level" superClass="gnu.c.compiler.mingw.exe.release.option.optimization.level" valueType="enumerated"/>
<option id="gnu.c.compiler.mingw.exe.release.option.debugging.level.8158262" name="Debug Level" superClass="gnu.c.compiler.mingw.exe.release.option.debugging.level" value="gnu.c.debugging.level.none" valueType="enumerated"/>
<option id="gnu.c.compiler.option.optimization.flags.2070224333" name="Other optimization flags" superClass="gnu.c.compiler.option.optimization.flags" value="-Os" valueType="string"/>
<option id="gnu.c.compiler.option.include.paths.672224426" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/OpenV2G/src/codec}&quot;"/> <listOptionValue builtIn="false" value="&quot;${workspace_loc:/OpenV2G/src/codec}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/OpenV2G/src/service}&quot;"/> <listOptionValue builtIn="false" value="&quot;${workspace_loc:/OpenV2G/src/service}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/OpenV2G/src/test}&quot;"/> <listOptionValue builtIn="false" value="&quot;${workspace_loc:/OpenV2G/src/test}&quot;"/>
</option> </option>
<inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.2117635578" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/> <option defaultValue="gnu.c.optimization.level.most" id="gnu.c.compiler.option.optimization.level.269511649" superClass="gnu.c.compiler.option.optimization.level" valueType="enumerated"/>
<option id="gnu.c.compiler.option.debugging.level.1614677996" superClass="gnu.c.compiler.option.debugging.level" value="gnu.c.debugging.level.none" valueType="enumerated"/>
<inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.822105819" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
</tool> </tool>
<tool id="cdt.managedbuild.tool.gnu.c.linker.mingw.exe.release.891155820" name="MinGW C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.mingw.exe.release"> <tool id="cdt.managedbuild.tool.gnu.c.linker.base.1432229809" name="GCC C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.base">
<inputType id="cdt.managedbuild.tool.gnu.c.linker.input.1593270687" superClass="cdt.managedbuild.tool.gnu.c.linker.input"> <inputType id="cdt.managedbuild.tool.gnu.c.linker.input.1805334009" superClass="cdt.managedbuild.tool.gnu.c.linker.input">
<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/> <additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
<additionalInput kind="additionalinput" paths="$(LIBS)"/> <additionalInput kind="additionalinput" paths="$(LIBS)"/>
</inputType> </inputType>
</tool> </tool>
<tool id="cdt.managedbuild.tool.gnu.cpp.linker.mingw.exe.release.1711492373" name="MinGW C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.mingw.exe.release"/> <tool id="cdt.managedbuild.tool.gnu.cpp.linker.base.1184740467" name="GCC C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.base"/>
<tool id="cdt.managedbuild.tool.gnu.assembler.base.1998194122" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.base">
<inputType id="cdt.managedbuild.tool.gnu.assembler.input.67175024" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
</tool>
</toolChain> </toolChain>
</folderInfo> </folderInfo>
</configuration> </configuration>

View file

@ -37,5 +37,8 @@ int main(int argc, char *argv[]) {
/* V2G client / service example scenario */ /* V2G client / service example scenario */
return main_service(argc, argv); return main_service(argc, argv);
/* network example 1 */
/* return main_network_1(argc, argv); */
} }

View file

@ -30,5 +30,6 @@
int main_codec(int argc, char *argv[]); int main_codec(int argc, char *argv[]);
int main_service(int argc, char *argv[]); int main_service(int argc, char *argv[]);
int main_network_1(int argc, char *argv[]);
#endif #endif

View file

@ -0,0 +1,140 @@
/*
* Copyright (C) 2010 INSYS Microelectronics GmbH
*
* 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 mlauterbach
* @version 0.0.1
*
********************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#define EVSE 1
#define PEV 2
static char *help_string =
"%s: Valid parameters are:\n"
" -v - print the program version and exit\n"
" -d - daemonize this process\n"
" -m<x> - mode of application with x=1 EVSE or x=2 PEV\n"
" -h - help\n";
extern void run_evse(unsigned int port);
extern void run_pev(unsigned int port);
static void arg_error(char *name)
{
fprintf(stderr, help_string, name);
exit(1);
}
int main_network_1(int argc, char *argv[])
{
int fd0, fd1, fd2;
int i, pid;
int daemonize = 0;
int mode = -1;
unsigned int port = 7259; /* TODO port is fix, should be configurable */
/* check arguments */
if(argc == 1)
arg_error("too few parameters");
for (i = 1; i < argc; i++) {
if ((argv[i][0] != '-') || (strlen(argv[i]) > 3)) {
fprintf(stderr, "Invalid argument: '%s'\n", argv[i]);
arg_error(argv[0]);
}
switch (argv[i][1]) {
case 'd':
daemonize = 1;
break;
case 'm':
mode = atoi(&argv[i][2]);
if(mode != EVSE && mode != PEV) {
fprintf(stderr, "Invalid option: '%s'\n", argv[i]);
arg_error(argv[0]);
}
break;
case 'h' :
fprintf(stdout, help_string, argv[0]);
exit(0);
case 'v':
printf("%s Example 1: 0.0.1\n", argv[0]);
exit(0);
default:
fprintf(stderr, "Invalid option: '%s'\n", argv[i]);
arg_error(argv[0]);
}
}
if (daemonize) {
if ((pid = fork()) > 0) {
exit(0);
} else if (pid < 0) {
printf("Error forking first fork\n");
exit(1);
} else {
/* setsid() is necessary if we really want to demonize */
if(setsid() == -1)
printf("Error setsid()\n");
/* Second fork to really deamonize me. */
if ((pid = fork()) > 0) {
exit(0);
} else if (pid < 0) {
printf("Error forking second fork\n");
exit(1);
}
}
/* change working directory to root so we won't prevent file systems
* from being unmounted.
*/
if(chdir("/") < 0) {
;
}
/* Attach file descriptors 0, 1, and 2 to /dev/null */
fd0 = open("/dev/null", O_RDWR);
fd1 = dup(0);
fd2 = dup(0);
}else {
printf("+++Start EVSE/PEV Example+++\n\n");
}
if (mode == EVSE) {
printf("+++Start EVSE on port: %i+++\n\n", port);
run_evse(port);
}else if (mode == PEV) {
printf("+++Start PEV to port: %i+++\n\n", port);
run_pev(port);
}
printf("+++Terminate EV2SE Example+++\n\n");
return 0;
}

View file

@ -0,0 +1,214 @@
/*
* Copyright (C) 2010 INSYS Microelectronics GmbH
*
* 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 mlauterbach
* @version 0.0.1
*
********************************************************************/
#include <netdb.h>
#include <errno.h>
#include <string.h>
#include <stdio.h>
#include <sys/select.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <time.h>
#include <termios.h>
#include <unistd.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
fd_set master_fd; /* master fd list */
fd_set read_fds; /* tmp fd list for select() */
int fdmax; /* maximum file descriptor number */
int listen_fd; /* file descriptor for TCP-Server */
int pev_fd; /* file descriptor to PEV */
static void close_server(void)
{
if(listen_fd == -1)
return;
tcflush(listen_fd, TCIOFLUSH);
FD_CLR(listen_fd, &master_fd);
close(listen_fd);
listen_fd = -1;
return;
}
static void init_server(void)
{
listen_fd = -1;
pev_fd = -1;
FD_ZERO(&master_fd);
FD_ZERO(&read_fds);
return;
}
static void cleanup_server(void)
{
close_server();
if(pev_fd != -1) {
close(pev_fd);
pev_fd = -1;
}
return;
}
static int start_server(unsigned int port)
{
int yes = 1;
struct addrinfo hints;
struct addrinfo *ai;
char str_port[10];
memset(&hints, 0, sizeof hints);
hints.ai_family = AF_INET;
hints.ai_socktype = SOCK_STREAM;
hints.ai_flags = AI_PASSIVE;
sprintf(str_port, "%d", port);
if ((getaddrinfo(NULL, str_port, &hints, &ai)) != 0) {
printf("ERROR: Could not get address info for the TCP listener: %s\n", strerror(errno));
return -1;
}
listen_fd = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol); /* create the socket */
if (listen_fd < 0) {
printf("ERROR: Creation of TCP listen socket failed: %s\n", strerror(errno));
listen_fd = -1;
return 1;
}
setsockopt(listen_fd, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(int)); /* just some options */
if (bind(listen_fd, ai->ai_addr, ai->ai_addrlen) < 0) { /* now we bind it to the port */
printf("ERROR: Binding TCP listen socket failed: %s\n", strerror(errno));
close(listen_fd);
listen_fd = -1;
return -1;
}
freeaddrinfo(ai);
if (listen(listen_fd, 10) == -1) { /* and put the socket in listen-mode */
printf("ERROR: Listening on TCP listen socket failed: %s\n", strerror(errno));
close(listen_fd);
listen_fd = -1;
return -1;
}
FD_SET(listen_fd, &master_fd);
if(listen_fd > fdmax)
fdmax = listen_fd;
printf("DEBUG: TCP-Server fd:%i\n", listen_fd);
return listen_fd;
}
static int accept_connection(void)
{
struct sockaddr_in remoteaddr;
socklen_t addrlen = sizeof remoteaddr;
pev_fd = accept(listen_fd, (struct sockaddr *) &remoteaddr, &addrlen);
if (pev_fd == -1) {
printf("ERROR: Could not accept on TCP listen socket: %s\n", strerror(errno));
return -1;
}
FD_SET(pev_fd, &master_fd);
if (pev_fd > fdmax) {
fdmax = pev_fd;
}
printf("PEV arrived .................... ;-)\n");
close_server();
return pev_fd;
}
static int handle_tcp_data(void)
{
ssize_t read_bytes;
uint8_t buffer[512];
read_bytes = read(pev_fd, buffer, sizeof(buffer)); /* get data from PEV */
if(read_bytes < 1) {
if(errno != EAGAIN) {
if(errno == EBADF)
printf("ERROR: Reading from TCP failed: connection is gone\n");
else
printf("ERROR: Reading from TCP failed: %d: %s\n", errno, strerror(errno));
printf("INFO: PEV gone\n");
close(pev_fd);
return -1;
}
}
printf("INFO: number of bytes from PEV: %i\n", read_bytes);
/* TODO give data to DoIP/EXI Parser and send response to PEV, if a complete EXI msg. was received */
return 0;
}
void run_evse(unsigned int port)
{
int sel;
struct timeval tv;
init_server();
listen_fd = start_server(port);
if (listen_fd == -1) {
printf("ERROR: open_server failed\n");
return;
}
for (;;) {
tv.tv_sec = 0;
tv.tv_usec = 100000;
FD_ZERO(&read_fds);
read_fds = master_fd;
sel = select(fdmax + 1, &read_fds, NULL, NULL, &tv);
if(sel > 0) {
if (FD_ISSET(listen_fd, &read_fds))
accept_connection();
if (FD_ISSET(pev_fd, &read_fds))
if(handle_tcp_data() == -1) { /* PEV gone */
break;
}
}else if (sel == -1) {
break;
}
}
cleanup_server();
return;
}

View file

@ -0,0 +1,30 @@
/*
* Copyright (C) 2010 INSYS Microelectronics GmbH
*
* 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 mlauterbach
* @version 0.0.1
*
********************************************************************/
void run_pev(unsigned int port)
{
// TODO
return;
}