Sevenstax / FreeV2G

Python based Host MPU Application for the use with 8DEVICES WHITE-BEET Embedded ISO15118 Module modules to realize IEC/ISO15118 and DIN70121 conform charging communication between electric vehicles (PEV) and elevtric vehicle supply equipment (EVSE). FreeV2G can e.g. been used with a Raspberry Pi.
Other
57 stars 26 forks source link

Unexpected session stop when processing ISO15118-2 AC charge parameters response #231

Closed mbirtwistle closed 1 year ago

mbirtwistle commented 1 year ago

Your Setup Platform: PEV Firmware Version: i.e. V01_00_07 Host Controller Interface: Ethernet Host: FreeV2G (EV_v1.0.7_0) / Own Implementation

Describe the bug

During an AC ISO15118-2 session, the EV session unexpectedly stops with a debug message 'Battery current out of range!'.
This is because the _handleACChargeParametersChanged method incorrectly calculates the target battery in_current

self.battery.in_current = self.schedule['power'][self.currentSchedule] / self.currentAcMaxCurrent

The nominal voltage from the EVSE response should be used to work out the target current, note that a few lines above, self.battery.in_voltage is assigned the value from the 'nominal_voltage' response parameter

so I believe the self.battery.in_current should be calculated as

self.battery.in_current = self.schedule['power'][self.currentSchedule] / self.battery.in_voltage

To Reproduce

Expected behavior The session should continue on to sending the next state machine request rather than aborting the session.

Logs not submitting logs as the code above is clearly not following the I=P/V rule

Additional context

lho-stx commented 1 year ago

Hey @mbirtwistle,

Thanks for contributing and pointing out!

Thank you very much, lho