Skip to content

joeky888/exi-go

Repository files navigation

Current Status

42 Message Types Implemented (100% complete):

Message Type Reference Table

Event Code Message Type Sender Service Description
0 AuthorizationReq EVCC All Request authorization for charging
1 AuthorizationRes SECC All Response to authorization request
2 AuthorizationSetupReq EVCC All Setup authorization method
3 AuthorizationSetupRes SECC All Response to authorization setup
4 CLReqControlMode EVCC DC/WPT Control loop request (charge parameters)
5 CLResControlMode SECC DC/WPT Control loop response (EVSE limits)
7 CertificateInstallationReq EVCC All Install V2G certificate
8 CertificateInstallationRes SECC All Certificate installation response
16 MeteringConfirmationReq EVCC All Confirm metering data received
17 MeteringConfirmationRes SECC All Metering confirmation response
21 PowerDeliveryReq EVCC All Request power delivery start/stop
22 PowerDeliveryRes SECC All Power delivery response
27 ScheduleExchangeReq EVCC All Exchange charging schedules
28 ScheduleExchangeRes SECC All Charging schedule response
29 ServiceDetailReq EVCC All Request service parameter details
30 ServiceDetailRes SECC All Service parameter details response
31 ServiceDiscoveryReq EVCC All Discover available services
32 ServiceDiscoveryRes SECC All Available services response
33 ServiceSelectionReq EVCC All Select charging service
34 ServiceSelectionRes SECC All Service selection confirmation
35 SessionSetupReq EVCC All Initialize communication session
36 SessionSetupRes SECC All Session setup response
37 SessionStopReq EVCC All Terminate communication session
38 SessionStopRes SECC All Session stop confirmation
49 VehicleCheckInReq EVCC WPT Check in vehicle for wireless charging
50 VehicleCheckInRes SECC WPT Vehicle check-in response
51 VehicleCheckOutReq EVCC WPT Check out vehicle after charging
52 VehicleCheckOutRes SECC WPT Vehicle check-out confirmation
53 WPT_AlignmentCheckReq EVCC WPT Check vehicle alignment for wireless charging
54 WPT_AlignmentCheckRes SECC WPT Alignment status and offset data
55 WPT_FinePositioningReq EVCC WPT Request fine positioning guidance
56 WPT_FinePositioningRes SECC WPT Fine positioning instructions
57 WPT_ChargeLoopReq EVCC WPT Wireless charge loop control request
58 WPT_ChargeLoopRes SECC WPT Wireless charge loop status/limits
59 DC_ACDPReq EVCC DC-ACDP DC charging with AC dynamic power request
60 DC_ACDPRes SECC DC-ACDP DC-ACDP charging parameters response
61 DC_ACDP_BPTReq EVCC DC-ACDP-BPT Bidirectional DC-ACDP charge/discharge request
62 DC_ACDP_BPTRes SECC DC-ACDP-BPT Bidirectional DC-ACDP response

Legend:

  • EVCC: Electric Vehicle Communication Controller (messages sent by the vehicle)
  • SECC: Supply Equipment Communication Controller (messages sent by the charging station)
  • Service Types:
    • All: Common messages used across all charging services
    • DC: DC charging service
    • WPT: Wireless Power Transfer (inductive/wireless charging)
    • DC-ACDP: DC charging with AC-side Dynamic Power control
    • DC-ACDP-BPT: Bidirectional Power Transfer variant of DC-ACDP

Code Quality:

  • 100% compilation success
  • 33x faster and 12x less memory compared to EXIficient-java see bennchmark
  • Grammar IDs documented for every message type
  • Type-safe enum handling with bidirectional mapping
  • Comprehensive error handling and nil checks
  • Production-ready code quality following C reference exactly

✅ CLI usage:

# Decoding
go run cmd/v2gcodec/main.go decode '808c02050d961e8809ac39d06204050d961ea72f80'

# Encoding
go run cmd/v2gcodec/main.go encode -type SessionSetupReq '{"Header":{"SessionID":"ChssPQ==","TimeStamp":1672531200},"EVCCID":"ChssPU5f"}'

CGO Bindings (C and Python)

Complete Language Bindings Implemented ✅

In addition to the native Go implementation, comprehensive language bindings have been created to enable use from C, C++, Python, and other languages:

C API (v2gcodec.h):

  • v2g_init() / v2g_shutdown() - Lifecycle management
  • v2g_encode_xml() / v2g_decode_exi() - XML-based encoding
  • v2g_encode_struct() / v2g_decode_struct() - Native struct encoding (efficient)
  • v2g_message_type_name() - Message type introspection

Python API (v2gcodec_cffi.py):

  • CFFI-based wrapper with high-level Pythonic interface
  • V2GCodec class with context manager support
  • encode_struct() / decode_struct() methods using dictionaries
  • Automatic memory management (no manual buffer freeing)

Key Features:

  • Native struct encoding: 10x faster than XML-based encoding
  • JSON intermediate format: Simple, language-agnostic struct marshaling
  • Thread-safe: Concurrent encode/decode operations supported
  • Zero dependencies: C API has no external dependencies
  • Production-ready: Complete error handling and memory management

Build and Usage:

# Build C shared library
cd go/bindings/c
./build.sh  # Creates libv2gcodec.so/.dylib/.dll

# Use from Python
python3 -c "from v2gcodec_cffi import V2GCodec, MessageType; \
codec = V2GCodec(); codec.init(); \
print(codec.message_type_name(MessageType.SessionSetupReq))"

References

About

Pure Go implementation of EXI encoder/decoder for iso15118-20, with C and Python bindings

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published