This commit is contained in:
gram
2025-09-10 01:56:17 +09:00
parent 3c43fa1318
commit d4af6cfc14
16 changed files with 0 additions and 272 deletions

View File

@@ -1,76 +0,0 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
int hex_char_to_int(char c) {
if (c >= '0' && c <= '9') return c - '0';
if (c >= 'A' && c <= 'F') return c - 'A' + 10;
if (c >= 'a' && c <= 'f') return c - 'a' + 10;
return -1;
}
int main() {
const char* hex_string = "8098021050908C0C0C0E0C50E00000002040C40C203030C01400003103D00C0618370105088270095A5A30303030300008";
size_t hex_len = strlen(hex_string);
if (hex_len % 2 != 0) {
printf("Error: Hex string length must be even\n");
return -1;
}
size_t binary_len = hex_len / 2;
unsigned char* binary_data = malloc(binary_len);
if (!binary_data) {
printf("Memory allocation failed\n");
return -1;
}
// Convert hex string to binary
for (size_t i = 0; i < binary_len; i++) {
int high = hex_char_to_int(hex_string[i * 2]);
int low = hex_char_to_int(hex_string[i * 2 + 1]);
if (high == -1 || low == -1) {
printf("Invalid hex character at position %zu\n", i * 2);
free(binary_data);
return -1;
}
binary_data[i] = (high << 4) | low;
}
// Write to file
FILE* file = fopen("test3.exi", "wb");
if (!file) {
printf("Cannot create output file\n");
free(binary_data);
return -1;
}
size_t written = fwrite(binary_data, 1, binary_len, file);
fclose(file);
free(binary_data);
if (written != binary_len) {
printf("Write error\n");
return -1;
}
printf("Successfully created test3.exi with %zu bytes\n", binary_len);
// Show first few bytes for verification
printf("First 16 bytes: ");
FILE* verify = fopen("test3.exi", "rb");
if (verify) {
for (int i = 0; i < 16 && i < binary_len; i++) {
int c = fgetc(verify);
printf("%02X ", c);
}
fclose(verify);
}
printf("\n");
return 0;
}

Binary file not shown.

View File

@@ -1,24 +0,0 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main() {
const char* hex_string = "8098021050908C0C0C0E0C50D10032018600A01881AE0601860C806140C801030800006100001881980600";
FILE* file = fopen("test4.exi", "wb");
if (!file) {
printf("Error creating test4.exi\n");
return -1;
}
size_t len = strlen(hex_string);
for (size_t i = 0; i < len; i += 2) {
unsigned int byte;
sscanf(&hex_string[i], "%2x", &byte);
fputc(byte, file);
}
fclose(file);
printf("test4.exi created successfully (%zu bytes)\n", len/2);
return 0;
}

Binary file not shown.

View File

@@ -1,66 +0,0 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/* EXI codec headers */
#include "iso1EXIDatatypes.h"
#include "iso1EXIDatatypesEncoder.h"
#include "ByteStream.h"
#define BUFFER_SIZE 1024
int main() {
struct iso1EXIDocument exiDoc;
bitstream_t stream;
uint8_t buffer[BUFFER_SIZE];
size_t pos = 0;
int errn = 0;
/* Initialize EXI document */
init_iso1EXIDocument(&exiDoc);
/* Create a simple V2G message */
exiDoc.V2G_Message_isUsed = 1;
init_iso1MessageHeaderType(&exiDoc.V2G_Message.Header);
/* Set session ID to all zeros */
memset(exiDoc.V2G_Message.Header.SessionID.bytes, 0, 8);
exiDoc.V2G_Message.Header.SessionID.bytesLen = 8;
/* Create session setup request */
exiDoc.V2G_Message.Body.SessionSetupReq_isUsed = 1;
init_iso1SessionSetupReqType(&exiDoc.V2G_Message.Body.SessionSetupReq);
/* Set EVCC ID */
strcpy((char*)exiDoc.V2G_Message.Body.SessionSetupReq.EVCCID.bytes, "01");
exiDoc.V2G_Message.Body.SessionSetupReq.EVCCID.bytesLen = 2;
/* Setup output stream */
stream.size = BUFFER_SIZE;
stream.data = buffer;
stream.pos = &pos;
stream.buffer = 0;
stream.capacity = 8;
/* Encode to EXI */
printf("Encoding V2G message to EXI...\n");
errn = encode_iso1ExiDocument(&stream, &exiDoc);
if (errn != 0) {
printf("Encoding failed with error: %d\n", errn);
return -1;
}
/* Write to file */
FILE *fp = fopen("test_message.exi", "wb");
if (fp == NULL) {
printf("Cannot create output file\n");
return -1;
}
fwrite(buffer, 1, pos, fp);
fclose(fp);
printf("Created test_message.exi with %zu bytes\n", pos);
return 0;
}

Binary file not shown.

Binary file not shown.

BIN
test1.exi Normal file

Binary file not shown.

BIN
test2.exi Normal file

Binary file not shown.

BIN
test3.exi Normal file

Binary file not shown.

View File

@@ -1,53 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<V2G_Message xmlns="urn:iso:15118:2:2013:MsgDef"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Header>
<SessionID>4142423030303831</SessionID>
</Header>
<Body>
<CurrentDemandReq>
<DC_EVStatus>
<EVReady>true</EVReady>
<EVErrorCode>0</EVErrorCode>
<EVRESSSOC>100</EVRESSSOC>
</DC_EVStatus>
<EVTargetCurrent>
<Multiplier>0</Multiplier>
<Unit>3</Unit>
<Value>5</Value>
</EVTargetCurrent>
<EVTargetVoltage>
<Multiplier>0</Multiplier>
<Unit>4</Unit>
<Value>460</Value>
</EVTargetVoltage>
<EVMaximumVoltageLimit>
<Multiplier>0</Multiplier>
<Unit>4</Unit>
<Value>471</Value>
</EVMaximumVoltageLimit>
<EVMaximumCurrentLimit>
<Multiplier>0</Multiplier>
<Unit>3</Unit>
<Value>100</Value>
</EVMaximumCurrentLimit>
<EVMaximumPowerLimit>
<Multiplier>3</Multiplier>
<Unit>5</Unit>
<Value>50</Value>
</EVMaximumPowerLimit>
<BulkChargingComplete>false</BulkChargingComplete>
<ChargingComplete>true</ChargingComplete>
<RemainingTimeToFullSoC>
<Multiplier>0</Multiplier>
<Unit>2</Unit>
<Value>0</Value>
</RemainingTimeToFullSoC>
<RemainingTimeToBulkSoC>
<Multiplier>0</Multiplier>
<Unit>2</Unit>
<Value>0</Value>
</RemainingTimeToBulkSoC>
</CurrentDemandReq>
</Body>
</V2G_Message>

View File

@@ -1 +0,0 @@
Error encoding to EXI (error: -109)

View File

@@ -1,3 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ns1:V2G_Message xmlns:ns1="urn:iso:15118:2:2013:MsgDef" xmlns:ns2="urn:iso:15118:2:2013:MsgHeader" xmlns:ns3="urn:iso:15118:2:2013:MsgBody" xmlns:ns4="urn:iso:15118:2:2013:MsgDataTypes">
<ns1:Header><ns2:SessionID>4142423030303831</ns2:SessionID></ns1:Header><ns1:Body><ns3:CurrentDemandReq><ns3:DC_EVStatus><ns4:EVReady>true</ns4:EVReady><ns4:EVErrorCode>0</ns4:EVErrorCode><ns4:EVRESSSOC>100</ns4:EVRESSSOC></ns3:DC_EVStatus><ns3:EVTargetCurrent><ns4:Multiplier>0</ns4:Multiplier><ns4:Unit>3</ns4:Unit><ns4:Value>1</ns4:Value></ns3:EVTargetCurrent><ns3:EVTargetVoltage><ns4:Multiplier>0</ns4:Multiplier><ns4:Unit>4</ns4:Unit><ns4:Value>460</ns4:Value></ns3:EVTargetVoltage><ns3:EVMaximumVoltageLimit><ns4:Multiplier>0</ns4:Multiplier><ns4:Unit>4</ns4:Unit><ns4:Value>471</ns4:Value></ns3:EVMaximumVoltageLimit><ns3:EVMaximumCurrentLimit><ns4:Multiplier>0</ns4:Multiplier><ns4:Unit>3</ns4:Unit><ns4:Value>100</ns4:Value></ns3:EVMaximumCurrentLimit><ns3:EVMaximumPowerLimit><ns4:Multiplier>3</ns4:Multiplier><ns4:Unit>5</ns4:Unit><ns4:Value>50</ns4:Value></ns3:EVMaximumPowerLimit><ns3:BulkChargingComplete>false</ns3:BulkChargingComplete><ns3:ChargingComplete>true</ns3:ChargingComplete><ns3:RemainingTimeToFullSoC><ns4:Multiplier>0</ns4:Multiplier><ns4:Unit>2</ns4:Unit><ns4:Value>0</ns4:Value></ns3:RemainingTimeToFullSoC><ns3:RemainingTimeToBulkSoC><ns4:Multiplier>0</ns4:Multiplier><ns4:Unit>2</ns4:Unit><ns4:Value>0</ns4:Value></ns3:RemainingTimeToBulkSoC></ns3:CurrentDemandReq></ns1:Body></ns1:V2G_Message>

View File

@@ -1 +0,0 @@
Error encoding to EXI (error: -109)\n

View File

@@ -1 +0,0 @@
<EFBFBD><EFBFBD>P<><50>  P

View File

@@ -1,47 +0,0 @@
DEBUG: Parsing EVTargetCurrent section
DEBUG find_tag_in_section: Looking for 'Multiplier' in section of 137 chars
DEBUG: Found 'Multiplier' = '0'
DEBUG find_tag_in_section: Looking for 'Unit' in section of 137 chars
DEBUG: Found 'Unit' = '3'
DEBUG find_tag_in_section: Looking for 'Value' in section of 137 chars
DEBUG: Found 'Value' = '1'
DEBUG PhysicalValue: mult='0'->0, unit='3'->3, value='1'->1
DEBUG: Parsing EVTargetVoltage section
DEBUG find_tag_in_section: Looking for 'Multiplier' in section of 139 chars
DEBUG: Found 'Multiplier' = '0'
DEBUG find_tag_in_section: Looking for 'Unit' in section of 139 chars
DEBUG: Found 'Unit' = '4'
DEBUG find_tag_in_section: Looking for 'Value' in section of 139 chars
DEBUG: Found 'Value' = '460'
DEBUG PhysicalValue: mult='0'->0, unit='4'->4, value='460'->460
DEBUG find_tag_in_section: Looking for 'Multiplier' in section of 145 chars
DEBUG: Found 'Multiplier' = '0'
DEBUG find_tag_in_section: Looking for 'Unit' in section of 145 chars
DEBUG: Found 'Unit' = '4'
DEBUG find_tag_in_section: Looking for 'Value' in section of 145 chars
DEBUG: Found 'Value' = '471'
DEBUG PhysicalValue: mult='0'->0, unit='4'->4, value='471'->471
DEBUG find_tag_in_section: Looking for 'Multiplier' in section of 145 chars
DEBUG: Found 'Multiplier' = '0'
DEBUG find_tag_in_section: Looking for 'Unit' in section of 145 chars
DEBUG: Found 'Unit' = '3'
DEBUG find_tag_in_section: Looking for 'Value' in section of 145 chars
DEBUG: Found 'Value' = '100'
DEBUG PhysicalValue: mult='0'->0, unit='3'->3, value='100'->100
DEBUG find_tag_in_section: Looking for 'Multiplier' in section of 142 chars
DEBUG: Found 'Multiplier' = '3'
DEBUG find_tag_in_section: Looking for 'Unit' in section of 142 chars
DEBUG: Found 'Unit' = '5'
DEBUG find_tag_in_section: Looking for 'Value' in section of 142 chars
DEBUG: Found 'Value' = '50'
DEBUG PhysicalValue: mult='3'->3, unit='5'->5, value='50'->50
DEBUG: Parsed V2G Message:
V2G_Message_isUsed: 1
CurrentDemandReq_isUsed: 1
EVReady: 1
EVErrorCode: 0
EVRESSSOC: 100
EVTargetCurrent: 1 (Mult: 0, Unit: 3)
EVTargetVoltage: 460 (Mult: 0, Unit: 4)
ChargingComplete: 1
<EFBFBD><EFBFBD>P<><50>  P