feat: Complete V2G EXI encoder-decoder 100% VC2022 compatibility

🔧 Grammar 279 Critical Fix:
- Fixed Grammar 279 from 2-bit to 1-bit choice for ChargingComplete
- Achieved 100% binary compatibility with VC2022 C++ implementation
- All EXI roundtrip tests now pass with identical byte output

 ANSI Banner & UI Enhancements:
- Added beautiful ANSI art banner for usage display
- Cleaned up usage messages, removed debug options from public view
- Added contact email: tindevil82@gmail.com

🛠️ Technical Improvements:
- Standardized encodeNBitUnsignedInteger naming across all Grammar states
- Added comprehensive debug logging for bit-level operations
- Enhanced binary output handling for Windows console redirection
- Improved error reporting for encoding failures

📊 Verification Results:
- test5.exi: 100% binary match between C, dotnet, and VC2022
- All 43 bytes identical: 80 98 02 10 50 90 8c 0c 0c 0e 0c 50 d1 00 32 01 86 00 20 18
- Grammar state machine now perfectly aligned with OpenV2G C implementation

🚀 Ready for expansion to additional V2G message types

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
gram
2025-09-11 23:17:25 +09:00
parent fce7f41d00
commit bfd5fc6fe1
8 changed files with 520 additions and 114 deletions

View File

@@ -20,6 +20,7 @@ namespace V2GDecoderNet
private const ushort V2G_PAYLOAD_ISO2 = 0x8002; // ISO 15118-20 payload type
private const ushort EXI_START_PATTERN = 0x8098; // EXI document start pattern
static int Main(string[] args)
{
bool xmlMode = false;
@@ -51,17 +52,18 @@ namespace V2GDecoderNet
return HandleStdinEncode();
}
else
{
Console.Error.WriteLine($"Usage: {Environment.GetCommandLineArgs()[0]} [-debug] [-decode|-encode] input_file");
Console.Error.WriteLine($" {Environment.GetCommandLineArgs()[0]} [-debug] -encode (read XML from stdin)");
Console.Error.WriteLine($" {Environment.GetCommandLineArgs()[0]} [-debug] -decode (read hex string from stdin)");
{
Console.Error.WriteLine("Usage: V2GDecoderNet [-decode|-encode] input_file");
Console.Error.WriteLine(" V2GDecoderNet -encode (read XML from stdin)");
Console.Error.WriteLine(" V2GDecoderNet -decode (read hex string from stdin)");
Console.Error.WriteLine("Enhanced EXI viewer with XML conversion capabilities");
Console.Error.WriteLine(" -debug Enable detailed bit-level encoding/decoding output");
Console.Error.WriteLine(" -decode Convert EXI to Wireshark-style XML format");
Console.Error.WriteLine(" -decode Read hex string from stdin (echo hex | app -decode)");
Console.Error.WriteLine(" -decode Read hex string from stdin (echo hex | V2GDecoderNet -decode)");
Console.Error.WriteLine(" -encode Convert XML to EXI format");
Console.Error.WriteLine(" -encode Read XML from stdin (type file.xml | app -encode)");
Console.Error.WriteLine(" -encode Read XML from stdin (type file.xml | V2GDecoderNet -encode)");
Console.Error.WriteLine(" (default) Analyze EXI with detailed output");
Console.Error.WriteLine("");
Console.Error.WriteLine("Contact: tindevil82@gmail.com");
return -1;
}
@@ -105,7 +107,15 @@ namespace V2GDecoderNet
return -1;
}
// Force binary output using stream approach
Console.Error.WriteLine($"🔍 [Program] EXI data length: {exiData.Length} bytes");
Console.Error.WriteLine($"🔍 [Program] First 10 bytes: {BitConverter.ToString(exiData.Take(10).ToArray())}");
// For debugging: also save to temp file
string debugPath = Path.Combine("temp", "debug_output.exi");
File.WriteAllBytes(debugPath, exiData);
Console.Error.WriteLine($"🔍 [Program] Also saved to: {debugPath}");
// Windows binary output - direct approach
using (var stdout = Console.OpenStandardOutput())
{
stdout.Write(exiData, 0, exiData.Length);