main_service.c 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. /*
  2. * Copyright (C) 2007-2010 Siemens AG
  3. *
  4. * This program is free software: you can redistribute it and/or modify
  5. * it under the terms of the GNU Lesser General Public License as published
  6. * by the Free Software Foundation, either version 3 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU Lesser General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU Lesser General Public License
  15. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. */
  17. /*******************************************************************
  18. *
  19. * @author Sebastian.Kaebisch.EXT@siemens.com
  20. * @version 0.2.2
  21. * @contact Joerg.Heuer@siemens.com
  22. *
  23. ********************************************************************/
  24. #include "v2g_service.h"
  25. #include "v2g_serviceDataTypes.h"
  26. #include "v2g_serviceClientStubs.h"
  27. #include "EXITypes.h"
  28. #include "BitStream.h"
  29. #include <stdlib.h>
  30. #define MAX_BYTE_SIZE 128
  31. #define MAX_STRING_SIZE 256
  32. #define MAX_STREAM_SIZE 60
  33. int main_service(int argc, char *argv[])
  34. {
  35. static uint8_t byte_array[MAX_BYTE_SIZE]; /* define MAX_BYTE_SIZE before*/
  36. static uint32_t string_array[MAX_STRING_SIZE]; /* define MAX_STRING_SIZE before*/
  37. /* define in and out byte stream */
  38. uint8_t inStream[MAX_STREAM_SIZE]; /* define MAX_STREAM_SIZE before */
  39. uint8_t outStream[MAX_STREAM_SIZE]; /* define MAX_STREAM_SIZE before */
  40. /* service data structure */
  41. struct v2gService service;
  42. struct HeaderType v2gHeader;
  43. struct SessionSetupReqType sessionSetup;
  44. struct SessionSetupResType resultSessionSetup;
  45. /* struct PowerDiscoveryReqType powerDiscovery;
  46. struct PowerDiscoveryResType resultPowerDiscovery;
  47. */
  48. /* BINARY memory setup */
  49. bytes_t bytes = { MAX_BYTE_SIZE, byte_array, 0 };
  50. /* STRING memory setup */
  51. string_ucs_t string = { MAX_STRING_SIZE, string_array, 0 };
  52. printf("+++Start V2G Client / Service Example+++\n\n");
  53. /*******************
  54. * Init V2G Client *
  55. *******************/
  56. init_v2gServiceClient(&service,bytes,string,inStream,MAX_STREAM_SIZE, outStream, MAX_STREAM_SIZE);
  57. /*******************************
  58. * Setup data for sessionSetup *
  59. *******************************/
  60. /* setup header information */
  61. v2gHeader.SessionInformation.SessionID.arraylen.data = 0; /* no session id in the initial message -> array length = 0*/
  62. v2gHeader.SessionInformation.ProtocolVersion.data[0]='1'; /* assign protocol version number*/
  63. v2gHeader.SessionInformation.ProtocolVersion.arraylen.data=1; /* array string length =1 of protocol version */
  64. v2gHeader.SessionInformation.isused.ProtocolVersion = 1; /* important: signalize, protocol version is used */
  65. v2gHeader.isused.Notification=0; /* no notification */
  66. /* setup sessionSetup parameters */
  67. sessionSetup.isused.PEVID=1; /* no PEVID is transported */
  68. sessionSetup.PEVStatus.ChargerStandby=1; /* charger standby = true */
  69. sessionSetup.PEVStatus.ConnectorLocked=0; /* connector locked = false */
  70. printf("PEV: call EVSE sessionSetup\n");
  71. /*********************
  72. * Call sessionSetup *
  73. *********************/
  74. call_sessionSetup(&service,&v2gHeader,&sessionSetup,&resultSessionSetup);
  75. /* show results of the answer message of EVSE sessionSetup*/
  76. printf("PEV: received response message from EVSE\n");
  77. printf("\tResponseCode=%d\n",resultSessionSetup.ResponseCode);
  78. printf("\tEVSEID=%d\n", resultSessionSetup.EVSEID.data[0]);
  79. printf("\tEVSEStatus:\n\t\tConnectorLocked=%d\n",resultSessionSetup.EVSEStatus.ConnectorLocked);
  80. printf("\t\tEVSEStandby=%d\n",resultSessionSetup.EVSEStatus.EVSEStandby);
  81. printf("\t\tFatalError=%d\n",resultSessionSetup.EVSEStatus.FatalError);
  82. printf("\t\tPowerSwitchClosed=%d\n",resultSessionSetup.EVSEStatus.PowerSwitchClosed);
  83. printf("\t\tRCD=%d\n",resultSessionSetup.EVSEStatus.RCD);
  84. printf("\t\tShutDownTime=%lld\n",resultSessionSetup.EVSEStatus.ShutDownTime);
  85. printf("\tTCurrent=%lld\n",resultSessionSetup.TCurrent);
  86. printf("\n+++Terminate V2G Client / Service Example+++");
  87. return 0;
  88. }