diff --git a/enhanced_exi_viewer.c b/V2GDecoder.c similarity index 76% rename from enhanced_exi_viewer.c rename to V2GDecoder.c index 9431f4d..a5f61cd 100644 --- a/enhanced_exi_viewer.c +++ b/V2GDecoder.c @@ -468,9 +468,23 @@ int parse_xml_to_iso1(const char* xml_content, struct iso1EXIDocument* doc) { // Check for CurrentDemandReq if (strstr(xml_content, "") || strstr(xml_content, "")) { + // Body 구조체 초기화 (모든 메시지 타입 플래그를 0으로 설정) + init_iso1BodyType(&doc->V2G_Message.Body); + + // 오직 CurrentDemandReq만 활성화 doc->V2G_Message.Body.CurrentDemandReq_isUsed = 1; + + // Initialize CurrentDemandReq structure completely init_iso1CurrentDemandReqType(&doc->V2G_Message.Body.CurrentDemandReq); + // Set all optional fields to NOT USED by default + doc->V2G_Message.Body.CurrentDemandReq.EVMaximumVoltageLimit_isUsed = 0; + doc->V2G_Message.Body.CurrentDemandReq.EVMaximumCurrentLimit_isUsed = 0; + doc->V2G_Message.Body.CurrentDemandReq.EVMaximumPowerLimit_isUsed = 0; + doc->V2G_Message.Body.CurrentDemandReq.BulkChargingComplete_isUsed = 0; + doc->V2G_Message.Body.CurrentDemandReq.RemainingTimeToFullSoC_isUsed = 0; + doc->V2G_Message.Body.CurrentDemandReq.RemainingTimeToBulkSoC_isUsed = 0; + // Parse DC_EVStatus char* ev_ready = find_tag_content(xml_content, "EVReady"); if (ev_ready) { @@ -588,6 +602,10 @@ int parse_xml_to_iso1(const char* xml_content, struct iso1EXIDocument* doc) { // Check for CurrentDemandRes if (strstr(xml_content, "") || strstr(xml_content, "")) { + // Body 구조체 초기화 (모든 메시지 타입 플래그를 0으로 설정) + init_iso1BodyType(&doc->V2G_Message.Body); + + // 오직 CurrentDemandRes만 활성화 doc->V2G_Message.Body.CurrentDemandRes_isUsed = 1; init_iso1CurrentDemandResType(&doc->V2G_Message.Body.CurrentDemandRes); @@ -669,6 +687,138 @@ int parse_xml_to_iso1(const char* xml_content, struct iso1EXIDocument* doc) { return -1; // Unsupported message type } +// 구조체 전체 내용을 텍스트 파일로 덤프하는 함수 +void dump_iso1_document_to_file(const struct iso1EXIDocument* doc, const char* filename) { + FILE* fp = fopen(filename, "w"); + if (!fp) { + printf("Error: Cannot create file %s\n", filename); + return; + } + + fprintf(fp, "=== ISO1 EXI Document Structure Dump ===\n\n"); + + // Document level + fprintf(fp, "V2G_Message_isUsed: %u\n", doc->V2G_Message_isUsed); + + if (doc->V2G_Message_isUsed) { + // Header + fprintf(fp, "\n--- Header ---\n"); + fprintf(fp, "SessionID.bytesLen: %u\n", doc->V2G_Message.Header.SessionID.bytesLen); + fprintf(fp, "SessionID.bytes: "); + for (int i = 0; i < doc->V2G_Message.Header.SessionID.bytesLen; i++) { + fprintf(fp, "%02X", doc->V2G_Message.Header.SessionID.bytes[i]); + } + fprintf(fp, "\n"); + fprintf(fp, "Notification_isUsed: %u\n", doc->V2G_Message.Header.Notification_isUsed); + fprintf(fp, "Signature_isUsed: %u\n", doc->V2G_Message.Header.Signature_isUsed); + + // Body - All message type flags + fprintf(fp, "\n--- Body Message Type Flags ---\n"); + fprintf(fp, "AuthorizationReq_isUsed: %u\n", doc->V2G_Message.Body.AuthorizationReq_isUsed); + fprintf(fp, "AuthorizationRes_isUsed: %u\n", doc->V2G_Message.Body.AuthorizationRes_isUsed); + fprintf(fp, "BodyElement_isUsed: %u\n", doc->V2G_Message.Body.BodyElement_isUsed); + fprintf(fp, "CableCheckReq_isUsed: %u\n", doc->V2G_Message.Body.CableCheckReq_isUsed); + fprintf(fp, "CableCheckRes_isUsed: %u\n", doc->V2G_Message.Body.CableCheckRes_isUsed); + fprintf(fp, "CertificateInstallationReq_isUsed: %u\n", doc->V2G_Message.Body.CertificateInstallationReq_isUsed); + fprintf(fp, "CertificateInstallationRes_isUsed: %u\n", doc->V2G_Message.Body.CertificateInstallationRes_isUsed); + fprintf(fp, "CertificateUpdateReq_isUsed: %u\n", doc->V2G_Message.Body.CertificateUpdateReq_isUsed); + fprintf(fp, "CertificateUpdateRes_isUsed: %u\n", doc->V2G_Message.Body.CertificateUpdateRes_isUsed); + fprintf(fp, "ChargeParameterDiscoveryReq_isUsed: %u\n", doc->V2G_Message.Body.ChargeParameterDiscoveryReq_isUsed); + fprintf(fp, "ChargeParameterDiscoveryRes_isUsed: %u\n", doc->V2G_Message.Body.ChargeParameterDiscoveryRes_isUsed); + fprintf(fp, "ChargingStatusReq_isUsed: %u\n", doc->V2G_Message.Body.ChargingStatusReq_isUsed); + fprintf(fp, "ChargingStatusRes_isUsed: %u\n", doc->V2G_Message.Body.ChargingStatusRes_isUsed); + fprintf(fp, "CurrentDemandReq_isUsed: %u\n", doc->V2G_Message.Body.CurrentDemandReq_isUsed); + fprintf(fp, "CurrentDemandRes_isUsed: %u\n", doc->V2G_Message.Body.CurrentDemandRes_isUsed); + fprintf(fp, "MeteringReceiptReq_isUsed: %u\n", doc->V2G_Message.Body.MeteringReceiptReq_isUsed); + fprintf(fp, "MeteringReceiptRes_isUsed: %u\n", doc->V2G_Message.Body.MeteringReceiptRes_isUsed); + fprintf(fp, "PaymentDetailsReq_isUsed: %u\n", doc->V2G_Message.Body.PaymentDetailsReq_isUsed); + fprintf(fp, "PaymentDetailsRes_isUsed: %u\n", doc->V2G_Message.Body.PaymentDetailsRes_isUsed); + fprintf(fp, "PaymentServiceSelectionReq_isUsed: %u\n", doc->V2G_Message.Body.PaymentServiceSelectionReq_isUsed); + fprintf(fp, "PaymentServiceSelectionRes_isUsed: %u\n", doc->V2G_Message.Body.PaymentServiceSelectionRes_isUsed); + fprintf(fp, "PowerDeliveryReq_isUsed: %u\n", doc->V2G_Message.Body.PowerDeliveryReq_isUsed); + fprintf(fp, "PowerDeliveryRes_isUsed: %u\n", doc->V2G_Message.Body.PowerDeliveryRes_isUsed); + fprintf(fp, "PreChargeReq_isUsed: %u\n", doc->V2G_Message.Body.PreChargeReq_isUsed); + fprintf(fp, "PreChargeRes_isUsed: %u\n", doc->V2G_Message.Body.PreChargeRes_isUsed); + fprintf(fp, "ServiceDetailReq_isUsed: %u\n", doc->V2G_Message.Body.ServiceDetailReq_isUsed); + fprintf(fp, "ServiceDetailRes_isUsed: %u\n", doc->V2G_Message.Body.ServiceDetailRes_isUsed); + fprintf(fp, "ServiceDiscoveryReq_isUsed: %u\n", doc->V2G_Message.Body.ServiceDiscoveryReq_isUsed); + fprintf(fp, "ServiceDiscoveryRes_isUsed: %u\n", doc->V2G_Message.Body.ServiceDiscoveryRes_isUsed); + fprintf(fp, "SessionSetupReq_isUsed: %u\n", doc->V2G_Message.Body.SessionSetupReq_isUsed); + fprintf(fp, "SessionSetupRes_isUsed: %u\n", doc->V2G_Message.Body.SessionSetupRes_isUsed); + fprintf(fp, "SessionStopReq_isUsed: %u\n", doc->V2G_Message.Body.SessionStopReq_isUsed); + fprintf(fp, "SessionStopRes_isUsed: %u\n", doc->V2G_Message.Body.SessionStopRes_isUsed); + fprintf(fp, "WeldingDetectionReq_isUsed: %u\n", doc->V2G_Message.Body.WeldingDetectionReq_isUsed); + fprintf(fp, "WeldingDetectionRes_isUsed: %u\n", doc->V2G_Message.Body.WeldingDetectionRes_isUsed); + + // CurrentDemandReq 상세 정보 + if (doc->V2G_Message.Body.CurrentDemandReq_isUsed) { + fprintf(fp, "\n--- CurrentDemandReq Details ---\n"); + + // DC_EVStatus + fprintf(fp, "DC_EVStatus.EVReady: %u\n", doc->V2G_Message.Body.CurrentDemandReq.DC_EVStatus.EVReady); + fprintf(fp, "DC_EVStatus.EVErrorCode: %d\n", doc->V2G_Message.Body.CurrentDemandReq.DC_EVStatus.EVErrorCode); + fprintf(fp, "DC_EVStatus.EVRESSSOC: %d\n", doc->V2G_Message.Body.CurrentDemandReq.DC_EVStatus.EVRESSSOC); + + // EVTargetCurrent + fprintf(fp, "EVTargetCurrent.Multiplier: %d\n", doc->V2G_Message.Body.CurrentDemandReq.EVTargetCurrent.Multiplier); + fprintf(fp, "EVTargetCurrent.Unit: %d\n", doc->V2G_Message.Body.CurrentDemandReq.EVTargetCurrent.Unit); + fprintf(fp, "EVTargetCurrent.Value: %d\n", doc->V2G_Message.Body.CurrentDemandReq.EVTargetCurrent.Value); + + // 선택적 필드들 + fprintf(fp, "EVMaximumVoltageLimit_isUsed: %u\n", doc->V2G_Message.Body.CurrentDemandReq.EVMaximumVoltageLimit_isUsed); + if (doc->V2G_Message.Body.CurrentDemandReq.EVMaximumVoltageLimit_isUsed) { + fprintf(fp, "EVMaximumVoltageLimit.Multiplier: %d\n", doc->V2G_Message.Body.CurrentDemandReq.EVMaximumVoltageLimit.Multiplier); + fprintf(fp, "EVMaximumVoltageLimit.Unit: %d\n", doc->V2G_Message.Body.CurrentDemandReq.EVMaximumVoltageLimit.Unit); + fprintf(fp, "EVMaximumVoltageLimit.Value: %d\n", doc->V2G_Message.Body.CurrentDemandReq.EVMaximumVoltageLimit.Value); + } + + fprintf(fp, "EVMaximumCurrentLimit_isUsed: %u\n", doc->V2G_Message.Body.CurrentDemandReq.EVMaximumCurrentLimit_isUsed); + if (doc->V2G_Message.Body.CurrentDemandReq.EVMaximumCurrentLimit_isUsed) { + fprintf(fp, "EVMaximumCurrentLimit.Multiplier: %d\n", doc->V2G_Message.Body.CurrentDemandReq.EVMaximumCurrentLimit.Multiplier); + fprintf(fp, "EVMaximumCurrentLimit.Unit: %d\n", doc->V2G_Message.Body.CurrentDemandReq.EVMaximumCurrentLimit.Unit); + fprintf(fp, "EVMaximumCurrentLimit.Value: %d\n", doc->V2G_Message.Body.CurrentDemandReq.EVMaximumCurrentLimit.Value); + } + + fprintf(fp, "EVMaximumPowerLimit_isUsed: %u\n", doc->V2G_Message.Body.CurrentDemandReq.EVMaximumPowerLimit_isUsed); + if (doc->V2G_Message.Body.CurrentDemandReq.EVMaximumPowerLimit_isUsed) { + fprintf(fp, "EVMaximumPowerLimit.Multiplier: %d\n", doc->V2G_Message.Body.CurrentDemandReq.EVMaximumPowerLimit.Multiplier); + fprintf(fp, "EVMaximumPowerLimit.Unit: %d\n", doc->V2G_Message.Body.CurrentDemandReq.EVMaximumPowerLimit.Unit); + fprintf(fp, "EVMaximumPowerLimit.Value: %d\n", doc->V2G_Message.Body.CurrentDemandReq.EVMaximumPowerLimit.Value); + } + + fprintf(fp, "BulkChargingComplete_isUsed: %u\n", doc->V2G_Message.Body.CurrentDemandReq.BulkChargingComplete_isUsed); + if (doc->V2G_Message.Body.CurrentDemandReq.BulkChargingComplete_isUsed) { + fprintf(fp, "BulkChargingComplete: %u\n", doc->V2G_Message.Body.CurrentDemandReq.BulkChargingComplete); + } + + // ChargingComplete (필수 필드) + fprintf(fp, "ChargingComplete: %u\n", doc->V2G_Message.Body.CurrentDemandReq.ChargingComplete); + + fprintf(fp, "RemainingTimeToFullSoC_isUsed: %u\n", doc->V2G_Message.Body.CurrentDemandReq.RemainingTimeToFullSoC_isUsed); + if (doc->V2G_Message.Body.CurrentDemandReq.RemainingTimeToFullSoC_isUsed) { + fprintf(fp, "RemainingTimeToFullSoC.Multiplier: %d\n", doc->V2G_Message.Body.CurrentDemandReq.RemainingTimeToFullSoC.Multiplier); + fprintf(fp, "RemainingTimeToFullSoC.Unit: %d\n", doc->V2G_Message.Body.CurrentDemandReq.RemainingTimeToFullSoC.Unit); + fprintf(fp, "RemainingTimeToFullSoC.Value: %d\n", doc->V2G_Message.Body.CurrentDemandReq.RemainingTimeToFullSoC.Value); + } + + fprintf(fp, "RemainingTimeToBulkSoC_isUsed: %u\n", doc->V2G_Message.Body.CurrentDemandReq.RemainingTimeToBulkSoC_isUsed); + if (doc->V2G_Message.Body.CurrentDemandReq.RemainingTimeToBulkSoC_isUsed) { + fprintf(fp, "RemainingTimeToBulkSoC.Multiplier: %d\n", doc->V2G_Message.Body.CurrentDemandReq.RemainingTimeToBulkSoC.Multiplier); + fprintf(fp, "RemainingTimeToBulkSoC.Unit: %d\n", doc->V2G_Message.Body.CurrentDemandReq.RemainingTimeToBulkSoC.Unit); + fprintf(fp, "RemainingTimeToBulkSoC.Value: %d\n", doc->V2G_Message.Body.CurrentDemandReq.RemainingTimeToBulkSoC.Value); + } + + // EVTargetVoltage (필수 필드) + fprintf(fp, "EVTargetVoltage.Multiplier: %d\n", doc->V2G_Message.Body.CurrentDemandReq.EVTargetVoltage.Multiplier); + fprintf(fp, "EVTargetVoltage.Unit: %d\n", doc->V2G_Message.Body.CurrentDemandReq.EVTargetVoltage.Unit); + fprintf(fp, "EVTargetVoltage.Value: %d\n", doc->V2G_Message.Body.CurrentDemandReq.EVTargetVoltage.Value); + } + } + + fclose(fp); + printf("✓ Structure dump saved to %s\n", filename); +} + // Helper function to read EXI file int readEXIFile(char* file, uint8_t* buffer, size_t buffer_size, size_t *bytes_read) { FILE *fp = fopen(file, "rb"); @@ -756,12 +906,6 @@ void print_iso1_xml_wireshark(struct iso1EXIDocument* doc) { printf("%d", doc->V2G_Message.Body.CurrentDemandReq.EVTargetCurrent.Value); printf(""); - printf(""); - printf("%d", doc->V2G_Message.Body.CurrentDemandReq.EVTargetVoltage.Multiplier); - printf("%d", doc->V2G_Message.Body.CurrentDemandReq.EVTargetVoltage.Unit); - printf("%d", doc->V2G_Message.Body.CurrentDemandReq.EVTargetVoltage.Value); - printf(""); - if (doc->V2G_Message.Body.CurrentDemandReq.EVMaximumVoltageLimit_isUsed) { printf(""); printf("%d", doc->V2G_Message.Body.CurrentDemandReq.EVMaximumVoltageLimit.Multiplier); @@ -808,6 +952,13 @@ void print_iso1_xml_wireshark(struct iso1EXIDocument* doc) { printf(""); } + // EVTargetVoltage must come last according to EXI grammar + printf(""); + printf("%d", doc->V2G_Message.Body.CurrentDemandReq.EVTargetVoltage.Multiplier); + printf("%d", doc->V2G_Message.Body.CurrentDemandReq.EVTargetVoltage.Unit); + printf("%d", doc->V2G_Message.Body.CurrentDemandReq.EVTargetVoltage.Value); + printf(""); + printf(""); } @@ -999,14 +1150,29 @@ int main(int argc, char *argv[]) { free(xml_content); return -1; } - // Show encoding info only when redirecting to file (keeps terminal output clean) - struct stat stat_buf_debug; - int is_file_redirect = (fstat(fileno(stdout), &stat_buf_debug) == 0 && S_ISREG(stat_buf_debug.st_mode)); - if (is_file_redirect) { - fprintf(stderr, "XML parsing successful\\n"); - fprintf(stderr, "SessionID length: %d\\n", iso1Doc.V2G_Message.Header.SessionID.bytesLen); - fprintf(stderr, "CurrentDemandReq_isUsed: %s\\n", iso1Doc.V2G_Message.Body.CurrentDemandReq_isUsed ? "true" : "false"); + + // XML parsing debug info to stderr (optional) + // fprintf(stderr, "=== XML Parsing Debug ===\\n"); + // fprintf(stderr, "V2G_Message_isUsed: %s\\n", iso1Doc.V2G_Message_isUsed ? "true" : "false"); + // fprintf(stderr, "SessionID length: %d\\n", iso1Doc.V2G_Message.Header.SessionID.bytesLen); + // fprintf(stderr, "CurrentDemandReq_isUsed: %s\\n", iso1Doc.V2G_Message.Body.CurrentDemandReq_isUsed ? "true" : "false"); + + // Debug output disabled for clean hex-only output + /* + if (iso1Doc.V2G_Message.Body.CurrentDemandReq_isUsed) { + fprintf(stderr, "EVReady: %s\\n", iso1Doc.V2G_Message.Body.CurrentDemandReq.DC_EVStatus.EVReady ? "true" : "false"); + fprintf(stderr, "EVErrorCode: %d\\n", iso1Doc.V2G_Message.Body.CurrentDemandReq.DC_EVStatus.EVErrorCode); + fprintf(stderr, "EVRESSSOC: %d\\n", iso1Doc.V2G_Message.Body.CurrentDemandReq.DC_EVStatus.EVRESSSOC); + fprintf(stderr, "EVTargetCurrent: M=%d, U=%d, V=%d\\n", + iso1Doc.V2G_Message.Body.CurrentDemandReq.EVTargetCurrent.Multiplier, + iso1Doc.V2G_Message.Body.CurrentDemandReq.EVTargetCurrent.Unit, + iso1Doc.V2G_Message.Body.CurrentDemandReq.EVTargetCurrent.Value); + fprintf(stderr, "EVTargetVoltage: M=%d, U=%d, V=%d\\n", + iso1Doc.V2G_Message.Body.CurrentDemandReq.EVTargetVoltage.Multiplier, + iso1Doc.V2G_Message.Body.CurrentDemandReq.EVTargetVoltage.Unit, + iso1Doc.V2G_Message.Body.CurrentDemandReq.EVTargetVoltage.Value); } + */ free(xml_content); @@ -1018,32 +1184,29 @@ int main(int argc, char *argv[]) { stream.buffer = 0; stream.capacity = 0; + // 구조체 덤프 (디버그용, 필요시 활성화) + // dump_iso1_document_to_file(&iso1Doc, "struct_xml.txt"); + errn = encode_iso1ExiDocument(&stream, &iso1Doc); + if (errn != 0) { - printf("Error encoding to EXI (error: %d)\\n", errn); + fprintf(stderr, "Error encoding to EXI (error: %d)\\n", errn); return -1; } - // Check if output is redirected (for Windows/MINGW compatibility) - // Use environment variable approach or check for redirection - char* term = getenv("TERM"); - int use_hex_output = (term != NULL) || isatty(fileno(stdout)); - - // Also check if user specifically wants binary output by checking for redirection + // Check if output is redirected struct stat stat_buf; - if (fstat(fileno(stdout), &stat_buf) == 0 && S_ISREG(stat_buf.st_mode)) { - use_hex_output = 0; // Regular file, use binary - } + int is_redirected = (fstat(fileno(stdout), &stat_buf) == 0 && S_ISREG(stat_buf.st_mode)); - if (use_hex_output) { - // Terminal output: show hex string only + if (is_redirected) { + // Redirected output: write binary data + fwrite(buffer, 1, pos, stdout); + } else { + // Terminal output: show hex string only (like XML decode mode) for(size_t i = 0; i < pos; i++) { printf("%02X", buffer[i]); } printf("\n"); - } else { - // Redirected output: write binary data - fwrite(buffer, 1, pos, stdout); } return 0; } @@ -1105,7 +1268,41 @@ int main(int argc, char *argv[]) { print_iso1_xml_wireshark(&iso1Doc); } else { print_iso1_message(&iso1Doc); + + // Compare with expected structure + printf("\\n=== Original EXI Structure Debug ===\\n"); + printf("V2G_Message_isUsed: %s\\n", iso1Doc.V2G_Message_isUsed ? "true" : "false"); + printf("SessionID length: %d\\n", iso1Doc.V2G_Message.Header.SessionID.bytesLen); + printf("CurrentDemandReq_isUsed: %s\\n", iso1Doc.V2G_Message.Body.CurrentDemandReq_isUsed ? "true" : "false"); + + if (iso1Doc.V2G_Message.Body.CurrentDemandReq_isUsed) { + printf("EVReady: %s\\n", iso1Doc.V2G_Message.Body.CurrentDemandReq.DC_EVStatus.EVReady ? "true" : "false"); + printf("EVErrorCode: %d\\n", iso1Doc.V2G_Message.Body.CurrentDemandReq.DC_EVStatus.EVErrorCode); + printf("EVRESSSOC: %d\\n", iso1Doc.V2G_Message.Body.CurrentDemandReq.DC_EVStatus.EVRESSSOC); + printf("EVTargetCurrent: M=%d, U=%d, V=%d\\n", + iso1Doc.V2G_Message.Body.CurrentDemandReq.EVTargetCurrent.Multiplier, + iso1Doc.V2G_Message.Body.CurrentDemandReq.EVTargetCurrent.Unit, + iso1Doc.V2G_Message.Body.CurrentDemandReq.EVTargetCurrent.Value); + printf("EVMaximumVoltageLimit_isUsed: %s\\n", + iso1Doc.V2G_Message.Body.CurrentDemandReq.EVMaximumVoltageLimit_isUsed ? "true" : "false"); + printf("EVMaximumCurrentLimit_isUsed: %s\\n", + iso1Doc.V2G_Message.Body.CurrentDemandReq.EVMaximumCurrentLimit_isUsed ? "true" : "false"); + printf("EVMaximumPowerLimit_isUsed: %s\\n", + iso1Doc.V2G_Message.Body.CurrentDemandReq.EVMaximumPowerLimit_isUsed ? "true" : "false"); + printf("BulkChargingComplete_isUsed: %s\\n", + iso1Doc.V2G_Message.Body.CurrentDemandReq.BulkChargingComplete_isUsed ? "true" : "false"); + printf("RemainingTimeToFullSoC_isUsed: %s\\n", + iso1Doc.V2G_Message.Body.CurrentDemandReq.RemainingTimeToFullSoC_isUsed ? "true" : "false"); + printf("RemainingTimeToBulkSoC_isUsed: %s\\n", + iso1Doc.V2G_Message.Body.CurrentDemandReq.RemainingTimeToBulkSoC_isUsed ? "true" : "false"); + } } + + // 원본 EXI 디코딩 후 구조체 덤프 (분석 모드일 때만) + if (!xml_mode) { + dump_iso1_document_to_file(&iso1Doc, "struct_exi.txt"); + } + return 0; } else { if (!xml_mode) printf("✗ ISO1 decode failed (error: %d)\\n", errn); diff --git a/V2GDecoder.exe b/V2GDecoder.exe new file mode 100644 index 0000000..c1c5f5b Binary files /dev/null and b/V2GDecoder.exe differ diff --git a/build.bat b/build.bat index 733261a..1112461 100644 --- a/build.bat +++ b/build.bat @@ -1,7 +1,7 @@ @echo off -echo Building enhanced_exi_viewer... +echo Building V2GDecoder... -gcc -o enhanced_exi_viewer enhanced_exi_viewer.c ^ +gcc -o V2GDecoder V2GDecoder.c ^ src/iso1/*.c ^ src/iso2/*.c ^ src/din/*.c ^ @@ -12,7 +12,7 @@ gcc -o enhanced_exi_viewer enhanced_exi_viewer.c ^ -I./src/din if %ERRORLEVEL% EQU 0 ( - echo Build successful! enhanced_exi_viewer.exe created. + echo Build successful! V2GDecoder.exe created. ) else ( echo Build failed with error code %ERRORLEVEL% ) diff --git a/enhanced_exi_viewer.exe b/enhanced_exi_viewer.exe deleted file mode 100644 index f183553..0000000 Binary files a/enhanced_exi_viewer.exe and /dev/null differ diff --git a/minimal_test.xml b/minimal_test.xml new file mode 100644 index 0000000..e37c819 --- /dev/null +++ b/minimal_test.xml @@ -0,0 +1,29 @@ + + + + 4142423030303831 + + + + + true + 0 + 100 + + + 0 + 3 + 5 + + true + + 0 + 4 + 460 + + + + \ No newline at end of file diff --git a/src/iso1/iso1EXIDatatypesEncoder.c b/src/iso1/iso1EXIDatatypesEncoder.c index 8f9789d..0a0107e 100644 --- a/src/iso1/iso1EXIDatatypesEncoder.c +++ b/src/iso1/iso1EXIDatatypesEncoder.c @@ -27,24 +27,24 @@ * ********************************************************************/ - - - -#include "iso1EXIDatatypesEncoder.h" - -#include "EncoderChannel.h" -#include "EXIHeaderEncoder.h" - -#include "iso1EXIDatatypes.h" -#include "ErrorCodes.h" - -#ifndef EXI_iso1_DATATYPES_ENCODER_C -#define EXI_iso1_DATATYPES_ENCODER_C - -#if DEPLOY_ISO1_CODEC == SUPPORT_YES - -static int errn; - + + + +#include "iso1EXIDatatypesEncoder.h" + +#include "EncoderChannel.h" +#include "EXIHeaderEncoder.h" + +#include "iso1EXIDatatypes.h" +#include "ErrorCodes.h" + +#ifndef EXI_iso1_DATATYPES_ENCODER_C +#define EXI_iso1_DATATYPES_ENCODER_C + +#if DEPLOY_ISO1_CODEC == SUPPORT_YES + +static int errn; + /* Forward Declarations */ static int encode_iso1MessageHeaderType(bitstream_t* stream, struct iso1MessageHeaderType* iso1MessageHeaderType); static int encode_iso1SignatureType(bitstream_t* stream, struct iso1SignatureType* iso1SignatureType); @@ -153,7 +153,7 @@ static int encode_iso1DigestMethodType(bitstream_t* stream, struct iso1DigestMet static int encode_iso1SignaturePropertyType(bitstream_t* stream, struct iso1SignaturePropertyType* iso1SignaturePropertyType); static int encode_iso1PGPDataType(bitstream_t* stream, struct iso1PGPDataType* iso1PGPDataType); - + /* Complex type name='urn:iso:15118:2:2013:MsgHeader,MessageHeaderType', base type name='anyType', content type='ELEMENT', isAbstract='false', hasTypeId='false', final='0', block='0', particle='("urn:iso:15118:2:2013:MsgHeader":SessionID,"urn:iso:15118:2:2013:MsgHeader":Notification{0-1},"http://www.w3.org/2000/09/xmldsig#":Signature{0-1})', derivedBy='RESTRICTION'. */ static int encode_iso1MessageHeaderType(bitstream_t* stream, struct iso1MessageHeaderType* iso1MessageHeaderType) { int grammarID = 0; @@ -8780,8 +8780,10 @@ static int encode_iso1CurrentDemandReqType(bitstream_t* stream, struct iso1Curre int grammarID = 273; int done = 0; + // printf("🏁 [DEBUG CurrentDemandReq] Starting encoding, stream pos: %zu\n", *stream->pos); while(!done) { + // printf("🔍 [DEBUG CurrentDemandReq] Grammar case: %d, stream pos: %zu\n", grammarID, *stream->pos); switch(grammarID) { case 273: /* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2013:MsgBody}DC_EVStatus)] */ @@ -11866,12 +11868,12 @@ int encode_iso1EXISchemaInformedElementFragmentGrammar(bitstream_t* stream, stru return errn; } - - -int encode_iso1ExiDocument(bitstream_t* stream, struct iso1EXIDocument* exiDoc) { - errn = writeEXIHeader(stream); - - if(errn == 0) { + + +int encode_iso1ExiDocument(bitstream_t* stream, struct iso1EXIDocument* exiDoc) { + errn = writeEXIHeader(stream); + + if(errn == 0) { /* DocContent[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}AC_EVChargeParameter), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}AC_EVSEChargeParameter), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}AC_EVSEStatus), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}AuthorizationReq), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}AuthorizationRes), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}BodyElement), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}CableCheckReq), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}CableCheckRes), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}CanonicalizationMethod), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}CertificateInstallationReq), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}CertificateInstallationRes), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}CertificateUpdateReq), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}CertificateUpdateRes), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ChargeParameterDiscoveryReq), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ChargeParameterDiscoveryRes), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ChargingStatusReq), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ChargingStatusRes), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}CurrentDemandReq), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}CurrentDemandRes), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}DC_EVChargeParameter), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}DC_EVPowerDeliveryParameter), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}DC_EVSEChargeParameter), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}DC_EVSEStatus), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}DC_EVStatus), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}DSAKeyValue), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}DigestMethod), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}DigestValue), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVChargeParameter), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVPowerDeliveryParameter), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVSEChargeParameter), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVSEStatus), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVStatus), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}Entry), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}KeyInfo), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}KeyName), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}KeyValue), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Manifest), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}MeteringReceiptReq), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}MeteringReceiptRes), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}MgmtData), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Object), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}PGPData), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}PMaxScheduleEntry), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}PaymentDetailsReq), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}PaymentDetailsRes), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}PaymentServiceSelectionReq), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}PaymentServiceSelectionRes), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}PowerDeliveryReq), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}PowerDeliveryRes), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}PreChargeReq), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}PreChargeRes), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}RSAKeyValue), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Reference), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}RelativeTimeInterval), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}RetrievalMethod), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}SAScheduleList), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}SASchedules), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}SPKIData), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}SalesTariffEntry), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ServiceDetailReq), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ServiceDetailRes), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ServiceDiscoveryReq), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ServiceDiscoveryRes), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}SessionSetupReq), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}SessionSetupRes), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}SessionStopReq), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}SessionStopRes), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Signature), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}SignatureMethod), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}SignatureProperties), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}SignatureProperty), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}SignatureValue), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}SignedInfo), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}TimeInterval), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Transform), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Transforms), START_ELEMENT({urn:iso:15118:2:2013:MsgDef}V2G_Message), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}WeldingDetectionReq), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}WeldingDetectionRes), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}X509Data), START_ELEMENT_GENERIC] */ if ( exiDoc->AC_EVChargeParameter_isUsed == 1u ) { /* START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}AC_EVChargeParameter) */ @@ -12385,21 +12387,21 @@ int encode_iso1ExiDocument(bitstream_t* stream, struct iso1EXIDocument* exiDoc) } else { errn = EXI_ERROR_UNKOWN_EVENT; } - - } - - if(errn == 0) { - /* flush any pending bits */ - errn = encodeFinish(stream); - } - - return errn; -} - -#if DEPLOY_ISO1_CODEC_FRAGMENT == SUPPORT_YES -int encode_iso1ExiFragment(bitstream_t* stream, struct iso1EXIFragment* exiFrag) { - errn = writeEXIHeader(stream); - + + } + + if(errn == 0) { + /* flush any pending bits */ + errn = encodeFinish(stream); + } + + return errn; +} + +#if DEPLOY_ISO1_CODEC_FRAGMENT == SUPPORT_YES +int encode_iso1ExiFragment(bitstream_t* stream, struct iso1EXIFragment* exiFrag) { + errn = writeEXIHeader(stream); + if(errn == 0) { /* FragmentContent[START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}AC_EVChargeParameter), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}AC_EVSEChargeParameter), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}AC_EVSEStatus), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}AC_EVSEStatus), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}AuthorizationReq), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}AuthorizationRes), START_ELEMENT({urn:iso:15118:2:2013:MsgDef}Body), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}BodyElement), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}BulkChargingComplete), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}BulkChargingComplete), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}BulkSOC), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}CableCheckReq), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}CableCheckRes), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}CanonicalizationMethod), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}Certificate), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}CertificateInstallationReq), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}CertificateInstallationRes), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}CertificateUpdateReq), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}CertificateUpdateRes), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ChargeParameterDiscoveryReq), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ChargeParameterDiscoveryRes), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ChargeProgress), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ChargeService), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ChargingComplete), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}ChargingComplete), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ChargingProfile), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}ChargingProfileEntryMaxNumberOfPhasesInUse), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}ChargingProfileEntryMaxPower), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}ChargingProfileEntryStart), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ChargingSession), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ChargingStatusReq), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ChargingStatusRes), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}ConsumptionCost), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ContractSignatureCertChain), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ContractSignatureEncryptedPrivateKey), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}Cost), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}CurrentDemandReq), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}CurrentDemandRes), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}DC_EVChargeParameter), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}DC_EVPowerDeliveryParameter), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}DC_EVSEChargeParameter), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}DC_EVSEStatus), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}DC_EVSEStatus), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}DC_EVStatus), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}DC_EVStatus), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}DHpublickey), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}DSAKeyValue), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}DepartureTime), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}DigestMethod), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}DigestValue), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EAmount), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EPriceLevel), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}EVCCID), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVChargeParameter), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVEnergyCapacity), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVEnergyRequest), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVErrorCode), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVMaxCurrent), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVMaxVoltage), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}EVMaximumCurrentLimit), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVMaximumCurrentLimit), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}EVMaximumPowerLimit), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVMaximumPowerLimit), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}EVMaximumVoltageLimit), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVMaximumVoltageLimit), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVMinCurrent), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVPowerDeliveryParameter), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVRESSSOC), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVReady), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVSEChargeParameter), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}EVSECurrentLimitAchieved), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVSECurrentRegulationTolerance), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVSEEnergyToBeDelivered), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}EVSEID), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVSEIsolationStatus), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}EVSEMaxCurrent), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVSEMaxCurrent), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}EVSEMaximumCurrentLimit), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVSEMaximumCurrentLimit), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}EVSEMaximumPowerLimit), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVSEMaximumPowerLimit), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}EVSEMaximumVoltageLimit), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVSEMaximumVoltageLimit), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVSEMinimumCurrentLimit), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVSEMinimumVoltageLimit), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVSENominalVoltage), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVSENotification), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVSEPeakCurrentRipple), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}EVSEPowerLimitAchieved), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}EVSEPresentCurrent), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}EVSEPresentVoltage), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}EVSEProcessing), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVSEStatus), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVSEStatusCode), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}EVSETimeStamp), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}EVSEVoltageLimitAchieved), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EVStatus), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}EVTargetCurrent), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}EVTargetVoltage), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}EnergyTransferMode), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}Entry), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Exponent), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}FaultCode), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}FaultMsg), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}FreeService), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}FullSOC), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}G), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}GenChallenge), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}HMACOutputLength), START_ELEMENT({urn:iso:15118:2:2013:MsgDef}Header), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}J), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}KeyInfo), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}KeyName), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}KeyValue), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ListOfRootCertificateIDs), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Manifest), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}MaxEntriesSAScheduleTuple), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}MeterID), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}MeterInfo), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}MeterReading), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}MeterStatus), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}MeteringReceiptReq), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}MeteringReceiptRes), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}MgmtData), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Modulus), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}Multiplier), START_ELEMENT({urn:iso:15118:2:2013:MsgHeader}Notification), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}NotificationMaxDelay), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}NumEPriceLevels), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}OEMProvisioningCert), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Object), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}P), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}PGPData), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}PGPKeyID), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}PGPKeyPacket), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}PMax), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}PMaxSchedule), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}PMaxScheduleEntry), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}Parameter), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}ParameterSet), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}ParameterSetID), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}PaymentDetailsReq), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}PaymentDetailsRes), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}PaymentOption), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}PaymentOptionList), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}PaymentServiceSelectionReq), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}PaymentServiceSelectionRes), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}PgenCounter), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}PowerDeliveryReq), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}PowerDeliveryRes), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}PreChargeReq), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}PreChargeRes), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}ProfileEntry), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Q), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}RCD), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}RSAKeyValue), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ReceiptRequired), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Reference), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}RelativeTimeInterval), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}RemainingTimeToBulkSoC), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}RemainingTimeToFullSoC), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}RequestedEnergyTransferMode), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ResponseCode), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}RetrievalMethod), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}RetryCounter), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}RootCertificateID), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}SAProvisioningCertificateChain), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}SAScheduleList), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}SAScheduleTuple), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}SAScheduleTupleID), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}SAScheduleTupleID), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}SASchedules), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}SPKIData), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}SPKISexp), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}SalesTariff), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}SalesTariffDescription), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}SalesTariffEntry), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}SalesTariffID), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Seed), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}SelectedPaymentOption), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}SelectedService), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}SelectedServiceList), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}Service), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ServiceCategory), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}ServiceCategory), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ServiceDetailReq), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ServiceDetailRes), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ServiceDiscoveryReq), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ServiceDiscoveryRes), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ServiceID), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}ServiceID), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ServiceList), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}ServiceName), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ServiceParameterList), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}ServiceScope), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}ServiceScope), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}SessionID), START_ELEMENT({urn:iso:15118:2:2013:MsgHeader}SessionID), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}SessionSetupReq), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}SessionSetupRes), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}SessionStopReq), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}SessionStopRes), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}SigMeterReading), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Signature), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}SignatureMethod), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}SignatureProperties), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}SignatureProperty), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}SignatureValue), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}SignedInfo), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}SubCertificates), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}SupportedEnergyTransferMode), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}TMeter), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}TimeInterval), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Transform), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Transforms), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}Unit), START_ELEMENT({urn:iso:15118:2:2013:MsgDef}V2G_Message), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}Value), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}WeldingDetectionReq), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}WeldingDetectionRes), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}X509CRL), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}X509Certificate), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}X509Data), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}X509IssuerName), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}X509IssuerSerial), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}X509SKI), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}X509SerialNumber), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}X509SubjectName), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}XPath), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Y), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}amount), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}amountMultiplier), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}boolValue), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}byteValue), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}costKind), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}duration), START_ELEMENT({urn:iso:15118:2:2013:MsgBody}eMAID), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}intValue), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}physicalValue), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}shortValue), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}start), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}startValue), START_ELEMENT({urn:iso:15118:2:2013:MsgDataTypes}stringValue), START_ELEMENT_GENERIC, END_DOCUMENT] */ if ( exiFrag->AC_EVChargeParameter_isUsed == 1u ) { @@ -14571,19 +14573,19 @@ int encode_iso1ExiFragment(bitstream_t* stream, struct iso1EXIFragment* exiFrag) /* EndDocument */ errn = encodeNBitUnsignedInteger(stream, 8, 244); } - - - if(errn == 0) { - /* flush any pending bits */ - errn = encodeFinish(stream); - } - - return errn; -} -#endif /* DEPLOY_ISO1_CODEC_FRAGMENT */ - - -#endif /* DEPLOY_ISO1_CODEC */ - -#endif - + + + if(errn == 0) { + /* flush any pending bits */ + errn = encodeFinish(stream); + } + + return errn; +} +#endif /* DEPLOY_ISO1_CODEC_FRAGMENT */ + + +#endif /* DEPLOY_ISO1_CODEC */ + +#endif + diff --git a/struct_exi.txt b/struct_exi.txt new file mode 100644 index 0000000..aed3667 --- /dev/null +++ b/struct_exi.txt @@ -0,0 +1,46 @@ +=== ISO1 EXI Document Structure Dump === + +V2G_Message_isUsed: 1 + +--- Header --- +SessionID.bytesLen: 8 +SessionID.bytes: 4142423030303831 +Notification_isUsed: 0 +Signature_isUsed: 0 + +--- Body Message Type Flags --- +AuthorizationReq_isUsed: 0 +AuthorizationRes_isUsed: 0 +BodyElement_isUsed: 0 +CableCheckReq_isUsed: 0 +CableCheckRes_isUsed: 0 +CertificateInstallationReq_isUsed: 0 +CertificateInstallationRes_isUsed: 0 +CertificateUpdateReq_isUsed: 0 +CertificateUpdateRes_isUsed: 0 +ChargeParameterDiscoveryReq_isUsed: 0 +ChargeParameterDiscoveryRes_isUsed: 0 +ChargingStatusReq_isUsed: 0 +ChargingStatusRes_isUsed: 0 +CurrentDemandReq_isUsed: 0 +CurrentDemandRes_isUsed: 1 +MeteringReceiptReq_isUsed: 0 +MeteringReceiptRes_isUsed: 0 +PaymentDetailsReq_isUsed: 0 +PaymentDetailsRes_isUsed: 0 +PaymentServiceSelectionReq_isUsed: 0 +PaymentServiceSelectionRes_isUsed: 0 +PowerDeliveryReq_isUsed: 0 +PowerDeliveryRes_isUsed: 0 +PreChargeReq_isUsed: 0 +PreChargeRes_isUsed: 0 +ServiceDetailReq_isUsed: 0 +ServiceDetailRes_isUsed: 0 +ServiceDiscoveryReq_isUsed: 0 +ServiceDiscoveryRes_isUsed: 0 +SessionSetupReq_isUsed: 0 +SessionSetupRes_isUsed: 0 +SessionStopReq_isUsed: 0 +SessionStopRes_isUsed: 0 +WeldingDetectionReq_isUsed: 0 +WeldingDetectionRes_isUsed: 0 diff --git a/struct_xml.txt b/struct_xml.txt new file mode 100644 index 0000000..e853588 --- /dev/null +++ b/struct_xml.txt @@ -0,0 +1,80 @@ +=== ISO1 EXI Document Structure Dump === + +V2G_Message_isUsed: 1 + +--- Header --- +SessionID.bytesLen: 8 +SessionID.bytes: 4142423030303831 +Notification_isUsed: 0 +Signature_isUsed: 0 + +--- Body Message Type Flags --- +AuthorizationReq_isUsed: 0 +AuthorizationRes_isUsed: 0 +BodyElement_isUsed: 0 +CableCheckReq_isUsed: 0 +CableCheckRes_isUsed: 0 +CertificateInstallationReq_isUsed: 0 +CertificateInstallationRes_isUsed: 0 +CertificateUpdateReq_isUsed: 0 +CertificateUpdateRes_isUsed: 0 +ChargeParameterDiscoveryReq_isUsed: 0 +ChargeParameterDiscoveryRes_isUsed: 0 +ChargingStatusReq_isUsed: 0 +ChargingStatusRes_isUsed: 0 +CurrentDemandReq_isUsed: 1 +CurrentDemandRes_isUsed: 0 +MeteringReceiptReq_isUsed: 0 +MeteringReceiptRes_isUsed: 0 +PaymentDetailsReq_isUsed: 0 +PaymentDetailsRes_isUsed: 0 +PaymentServiceSelectionReq_isUsed: 0 +PaymentServiceSelectionRes_isUsed: 0 +PowerDeliveryReq_isUsed: 0 +PowerDeliveryRes_isUsed: 0 +PreChargeReq_isUsed: 0 +PreChargeRes_isUsed: 0 +ServiceDetailReq_isUsed: 0 +ServiceDetailRes_isUsed: 0 +ServiceDiscoveryReq_isUsed: 0 +ServiceDiscoveryRes_isUsed: 0 +SessionSetupReq_isUsed: 0 +SessionSetupRes_isUsed: 0 +SessionStopReq_isUsed: 0 +SessionStopRes_isUsed: 0 +WeldingDetectionReq_isUsed: 0 +WeldingDetectionRes_isUsed: 0 + +--- CurrentDemandReq Details --- +DC_EVStatus.EVReady: 1 +DC_EVStatus.EVErrorCode: 0 +DC_EVStatus.EVRESSSOC: 100 +EVTargetCurrent.Multiplier: 0 +EVTargetCurrent.Unit: 3 +EVTargetCurrent.Value: 1 +EVMaximumVoltageLimit_isUsed: 1 +EVMaximumVoltageLimit.Multiplier: 0 +EVMaximumVoltageLimit.Unit: 4 +EVMaximumVoltageLimit.Value: 471 +EVMaximumCurrentLimit_isUsed: 1 +EVMaximumCurrentLimit.Multiplier: 0 +EVMaximumCurrentLimit.Unit: 3 +EVMaximumCurrentLimit.Value: 100 +EVMaximumPowerLimit_isUsed: 1 +EVMaximumPowerLimit.Multiplier: 3 +EVMaximumPowerLimit.Unit: 5 +EVMaximumPowerLimit.Value: 50 +BulkChargingComplete_isUsed: 1 +BulkChargingComplete: 0 +ChargingComplete: 1 +RemainingTimeToFullSoC_isUsed: 1 +RemainingTimeToFullSoC.Multiplier: 0 +RemainingTimeToFullSoC.Unit: 2 +RemainingTimeToFullSoC.Value: 0 +RemainingTimeToBulkSoC_isUsed: 1 +RemainingTimeToBulkSoC.Multiplier: 0 +RemainingTimeToBulkSoC.Unit: 2 +RemainingTimeToBulkSoC.Value: 0 +EVTargetVoltage.Multiplier: 0 +EVTargetVoltage.Unit: 4 +EVTargetVoltage.Value: 460