# V2Gdecoder V2Gdecoder is a tool aimed to encode and decode V2G messages that commonly use EXI to compress exchanged XML files between a car Power-Line Communication module and a charging station. This tool is based on [RISE V2G shared library](https://github.com/V2GClarity/RISE-V2G) to easily parse messages. A release is available with a compiled Java Runtime binary there: https://github.com/FlUxIuS/V2Gdecoder/releases ## How to compile or execute Install maven. To compile: ```mvn compile assembly:single``` To execute: ```java -jar target/V2Gdecoder-jar-with-dependencies.jar``` If you wish to update risev2g version to something >1.2.6: ``` git clone https://github.com/V2GClarity/RISE-V2G/ cd RISE-V2G/RISE-V2G-PARENT mvn install ``` Now copy RISE-V2G-Shared in our project: ```cp RISE-V2G/RISE-V2G-Shared/target/rise-v2g-shared-1.2.6.jar src/lib/com.v2gclarity.risev2g/``` Be aware that you might have to do some changes to the code. ## How to use V2Gdecoder supports many methods to encode XML/decode EXI data as follows: ``` $ java -jar V2Gdecoder.jar -h Unrecognized option: -h usage: V2GEXI Helper -e,--exi EXI format -f,--file input file path -o,--output output file in a dedicated path -s,--string string to decode -w,--web Webserver -x,--xml XML format ``` To get it work, the directory "./schemas", containing V2G grammar, should be in tool's root directory. ### Decoding data A compressed EXI data can be decoded as follows: ``` $ java -jar V2Gdecoder.jar -e -s 809802107f860d7bae65dd8a891a1d1d1c0e8bcbddddddcb9dcccb9bdc99cbd5148bd8d85b9bdb9a58d85b0b595e1a50d5a1d1d1c0e8bcbddddddcb9dcccb9bdc99cbcc8c0c0c4bcc0d0bde1b5b191cda59cb5b5bdc9948d958d91cd84b5cda184c8d4d9002b4b21890623696431024687474703a2f2f7777772e77332e6f72672f54522f63616e6f6e6963616c2d6578694852d0e8e8e0745e5eeeeeee5cee665cdee4ce5e646060625e60685ef0dad8cadcc646e6d0c2646a6c84165aa773adf12a841e302f171698e9c4d1e6bb2afdac13826f13ba6a09532c82a2841400000000000501c030a0161005696431001000100240880e201081203840110260a88032940000081030c08018503f03102400c0c3010031039804461800080 41FE1835EEB99776stU7nW+JVCDxgXi4tMdOJo812VftYJwTeJ3TUEqZZBU=OKFinished1072003W111011800436002540030NoneValidEVSE_Ready0A323W630V4000A160V2300A0 ``` By using parameters like "file" and "output", data can be taken from input file and exported in an output path respectively. ### Encoding data In the inverse, the encoding feature can be used as follows: ``` $ java -jar V2Gdecoder.jar -x -s 'urn:din:70121:2012:MsgDef2001urn:iso:15118:2:2013:MsgDef2012' 8000DBAB9371D3234B71D1B981899189D191818991D26B9B3A232B30020000000001D75726E3A69736F3A31353131383A323A323031333A4D73674465660040000080880 ``` ### Using the web service The tool can be runned as follows: ``` $ java -jar V2Gdecoder_test.jar -w ``` This opens a local port TCP 9000. You can then use your favorite tool/interpreter to send EXI data to get the reply as follows: ``` In [1]: import requests In [2]: r = requests.post("http://localhost:9000", headers={"Format":"EXI"}, data="809802107f860d7bae65d ...: d8a891a1d1d1c0e8bcbddddddcb9dcccb9bdc99cbd5148bd8d85b9bdb9a58d85b0b595e1a50d5a1d1d1c0e8bcbdddddd ...: cb9dcccb9bdc99cbcc8c0c0c4bcc0d0bde1b5b191cda59cb5b5bdc9948d958d91cd84b5cda184c8d4d9002b4b2189062 ...: 3696431024687474703a2f2f7777772e77332e6f72672f54522f63616e6f6e6963616c2d6578694852d0e8e8e0745e5e ...: eeeeee5cee665cdee4ce5e646060625e60685ef0dad8cadcc646e6d0c2646a6c84165aa773adf12a841e302f171698e9 ...: c4d1e6bb2afdac13826f13ba6a09532c82a2841400000000000501c030a0161005696431001000100240880e20108120 ...: 3840110260a88032940000081030c08018503f03102400c0c3010031039804461800080") In [3]: r.text Out[3]: u'41FE1835EEB99776stU7nW+JVCDxgXi4tMdOJo812VftYJwTeJ3TUEqZZBU=OKFinished1072003W111011800436002540030NoneValidEVSE_Ready0A323W630V4000A160V2300A0' ``` ## Issues when decoding data XML definition schemas are available in the "./schemas" directory. Unfortunately, a lot of constructors use very old definitions. To fix the issue, you can make your own definition or try to contact us for more information.