Signed-off-by: didinst <9f6129a2ddff0d0c6d03169eaa75e3fea1c1770f>
feature/evse-to-ev-win
didinst 3 years ago
parent 781d83297e
commit 8d541a71d9
Signed by untrusted user who does not match committer: didinst
GPG Key ID: 2EA0BE33BF9516AD
  1. 17
      candump.go
  2. 83
      chademo.go

@ -5,6 +5,7 @@ import (
"flag" "flag"
"fmt" "fmt"
"os" "os"
"reflect"
) )
func main() { func main() {
@ -12,6 +13,7 @@ func main() {
flag.Parse() flag.Parse()
var frames <-chan *CanFrame var frames <-chan *CanFrame
last := make(map[interface{}]interface{})
switch { switch {
case len(*filename) > 0: case len(*filename) > 0:
@ -28,16 +30,17 @@ func main() {
events := FromCanFrames(frames) events := FromCanFrames(frames)
fmt.Printf("Value %v", PARKING)
for event := range events { for event := range events {
switch msg := event.(type) { eventType := reflect.TypeOf(event)
default:
fmt.Println(msg)
}
fmt.Println(event.GetValue()) lastValue := last[eventType]
value, date := event.GetValue()
if lastValue != value {
fmt.Printf("%v | %s = %v\n", *date, eventType, value)
last[eventType] = value
}
//if msg, isType := event.(MaximumBatteryVoltage); isType { //if msg, isType := event.(MaximumBatteryVoltage); isType {
// fmt.Printf("MaximumBatteryVoltage: %v\n", msg.GetMaxBattVoltage()) // fmt.Printf("MaximumBatteryVoltage: %v\n", msg.GetMaxBattVoltage())

@ -36,7 +36,8 @@ type ContactorVehicleStatus uint8
type StopRequest uint8 type StopRequest uint8
type ChademoEvent interface { type ChademoEvent interface {
GetValue() interface{} // GetValue Return processed/calculated value and timestamp string
GetValue() (interface{}, *string)
} }
type frame struct { type frame struct {
@ -197,84 +198,84 @@ func bytesToUint16(bytes []uint8) uint16 {
return result return result
} }
func (m MaximumBatteryVoltage) GetValue() interface{} { func (m MaximumBatteryVoltage) GetValue() (interface{}, *string) {
return bytesToUint16(m.payload[4:6]) return bytesToUint16(m.payload[4:6]), &m.date
} }
func (c ConstChargingRateInd) GetValue() interface{} { func (c ConstChargingRateInd) GetValue() (interface{}, *string) {
return c.payload[6] return c.payload[6], &c.date
} }
func (b BatteryCapacity) GetValue() interface{} { func (b BatteryCapacity) GetValue() (interface{}, *string) {
return 0.1 * float32(bytesToUint16(b.payload[5:7])) return 0.1 * float32(bytesToUint16(b.payload[5:7])), &b.date
} }
func (m MaxChargingTimeS) GetValue() interface{} { func (m MaxChargingTimeS) GetValue() (interface{}, *string) {
return 10 * uint16(m.payload[1]) return 10 * uint16(m.payload[1]), &m.date
} }
func (m MaxChargingTimeM) GetValue() interface{} { func (m MaxChargingTimeM) GetValue() (interface{}, *string) {
return m.payload[2] return m.payload[2], &m.date
} }
func (e EstChargingTimeM) GetValue() interface{} { func (e EstChargingTimeM) GetValue() (interface{}, *string) {
return e.payload[3] return e.payload[3], &e.date
} }
func (c ControlProtocolNumber) GetValue() interface{} { func (c ControlProtocolNumber) GetValue() (interface{}, *string) {
return c.payload[0] return c.payload[0], &c.date
} }
func (t TargetBatteryVoltage) GetValue() interface{} { func (t TargetBatteryVoltage) GetValue() (interface{}, *string) {
return bytesToUint16(t.payload[1:3]) return bytesToUint16(t.payload[1:3]), &t.date
} }
func (c ChargingCurrentReq) GetValue() interface{} { func (c ChargingCurrentReq) GetValue() (interface{}, *string) {
return c.payload[3] return c.payload[3], &c.date
} }
func (c ChargingRate) GetValue() interface{} { func (c ChargingRate) GetValue() (interface{}, *string) {
return c.payload[6] return c.payload[6], &c.date
} }
func (s ShiftLever) GetValue() interface{} { func (s ShiftLever) GetValue() (interface{}, *string) {
return getVehicleShiftLever(&s.payload) return getVehicleShiftLever(&s.payload), &s.date
} }
func (v VehicleCharging) GetValue() interface{} { func (v VehicleCharging) GetValue() (interface{}, *string) {
return getVehicleCharging(&v.payload) return getVehicleCharging(&v.payload), &v.date
} }
func (c ChargingSystemFault) GetValue() interface{} { func (c ChargingSystemFault) GetValue() (interface{}, *string) {
return getFault(&c.payload, 5, 2) return getFault(&c.payload, 5, 2), &c.date
} }
func (v VehicleStatus) GetValue() interface{} { func (v VehicleStatus) GetValue() (interface{}, *string) {
return getVehicleStatus(&v.payload) return getVehicleStatus(&v.payload), &v.date
} }
func (n NormalStopReq) GetValue() interface{} { func (n NormalStopReq) GetValue() (interface{}, *string) {
return getNormalStopReq(&n.payload) return getNormalStopReq(&n.payload), &n.date
} }
func (b BattOvervoltage) GetValue() interface{} { func (b BattOvervoltage) GetValue() (interface{}, *string) {
return getFault(&b.payload, 4, 0) return getFault(&b.payload, 4, 0), &b.date
} }
func (b BattUndervoltage) GetValue() interface{} { func (b BattUndervoltage) GetValue() (interface{}, *string) {
return getFault(&b.payload, 4, 1) return getFault(&b.payload, 4, 1), &b.date
} }
func (b BattCurrentDeviationErr) GetValue() interface{} { func (b BattCurrentDeviationErr) GetValue() (interface{}, *string) {
return getFault(&b.payload, 4, 2) return getFault(&b.payload, 4, 2), &b.date
} }
func (h HighBattTemperature) GetValue() interface{} { func (h HighBattTemperature) GetValue() (interface{}, *string) {
return getFault(&h.payload, 4, 3) return getFault(&h.payload, 4, 3), &h.date
} }
func (b BattVoltageDeviationErr) GetValue() interface{} { func (b BattVoltageDeviationErr) GetValue() (interface{}, *string) {
return getFault(&b.payload, 4, 4) return getFault(&b.payload, 4, 4), &b.date
} }
func (v VehicleChargingEnabled) String() string { func (v VehicleChargingEnabled) String() string {

Loading…
Cancel
Save