cim

package
v0.3.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 11, 2023 License: GPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const IsoDate = "2006-01-02"

Variables

View Source
var (
	Debug = false
)

Functions

func VinCheck added in v0.2.3

func VinCheck(vin string) (bool, string)

Types

type Bin

type Bin struct {
	ProgrammingDate        []byte         `bin:"len:4" json:"programming_date"` // BCD Binary-Coded Decimal yyyy-mm-dd
	SasOption              uint8          `bin:"len:1" json:"sas_option"`       // Steering Angle Sensor 0x03 = true
	UnknownBytes1          []byte         `bin:"len:6" json:"unknown_bytes_1"`
	PartNo1                uint32         `bin:"len:4" json:"partno1"` // End model (HW+SW)
	PartNo1Rev             string         `bin:"len:2" json:"partno1_rev"`
	ConfigurationVersion   uint32         `bin:"len:4" json:"configuration_version"`
	PnBase1                uint32         `bin:"len:4" json:"pnbase1"` // Base model (HW+boot)
	PnBase1Rev             string         `bin:"len:2" json:"pnbase1_rev"`
	Vin                    Vin            `bin:"len:30" json:"vin"`
	ProgrammingID          []string       `bin:"len:3,[len:10]" json:"programming_id"` // 3 last sps progrmming ids's groups of 10 characters each. 30 bytes
	DiagnosticData         DiagnosticData `bin:"len:88" json:"unknown_data_3"`
	Pin                    Pin            `bin:"len:20" json:"pin"`
	Options                Options        `bin:"len:4" json:"unknown_data_4"`
	UnknownData1           UnknownData1   `bin:"len:44" json:"unknown_data_1"`
	Const1                 Const1         `bin:"len:10" json:"const1"`
	Keys                   Keys           `bin:"len:74" json:"keys"`
	UnknownData5           UnknownData5   `bin:"len:25" json:"unknown_data_5"`
	Sync                   Sync           `bin:"len:66" json:"sync"`
	UnknownData7           UnknownData7   `bin:"len:14" json:"unknown_data_7"`
	UnknownData8           UnknownData8   `bin:"len:8" json:"unknown_data_8"`
	UnknownData9           UnknownData9   `bin:"len:7" json:"unknown_data_9"`
	UnknownData2           UnknownData2   `bin:"len:14" json:"unknown_data_2"`
	SnSticker              []byte         `bin:"len:5" json:"snsticker"`                // BCD
	FactoryProgrammingDate []byte         `bin:"len:3" json:"factory_programming_date"` // Reversed BCD date dd-mm-yy
	UnknownBytes2          []byte         `bin:"len:3" json:"unknown_bytes_2"`
	DelphiPN               uint32         `bin:"le,len:4" json:"delphipn"` // Little endian, Delphi part number
	UnknownBytes3          []byte         `bin:"len:2" json:"unknown_bytes_3"`
	PartNo                 uint32         `bin:"le,len:4" json:"partno"` // Little endian, SAAB part number (factory?)
	UnknownData14          []byte         `bin:"len:3" json:"unknown_data_14"`
	PSK                    PSK            `bin:"len:14" json:"psk"`
	SASCalibration         SASCalibration `bin:"len:12" json:"sas_calibration"`
	EOF                    byte           `bin:"len:1" json:"eof"`
}

Cim eeprom layout

func Load

func Load(filename string) (*Bin, error)

Load a file from disk

func LoadBytes

func LoadBytes(filename string, b []byte) (*Bin, error)

Load a byte slice as a named binary

func MustLoad

func MustLoad(filename string) (*Bin, error)

func MustLoadBytes

func MustLoadBytes(filename string, b []byte) (*Bin, error)

Load byte array and validate it directly

func (*Bin) Bytes

func (bin *Bin) Bytes() ([]byte, error)

Return the byte representation of the memory dump

func (*Bin) CRC32

func (bin *Bin) CRC32() string

func (*Bin) ClearDTCS added in v0.2.8

func (bin *Bin) ClearDTCS()

func (*Bin) DeleteKey added in v0.2.3

func (bin *Bin) DeleteKey(keyno int) error

func (*Bin) Dump

func (fw *Bin) Dump()

func (*Bin) GetFactoryProgrammingDate added in v0.2.7

func (bin *Bin) GetFactoryProgrammingDate() (time.Time, error)

func (*Bin) GetProgrammingDate added in v0.2.7

func (bin *Bin) GetProgrammingDate() (time.Time, error)

func (*Bin) GetSasOpt added in v0.2.3

func (bin *Bin) GetSasOpt() bool

func (*Bin) Json

func (bin *Bin) Json() ([]byte, error)

func (*Bin) MD5

func (bin *Bin) MD5() string

func (*Bin) ModelYear

func (bin *Bin) ModelYear() string

Return model year from VIN

func (*Bin) Pretty

func (fw *Bin) Pretty()

func (*Bin) SetConfVer

func (bin *Bin) SetConfVer(ver uint32)

func (*Bin) SetKeyCount added in v0.2.3

func (bin *Bin) SetKeyCount(keys uint8) error

Set key count

func (*Bin) SetKeyErrorCount added in v0.2.3

func (bin *Bin) SetKeyErrorCount(value uint8) error

func (*Bin) SetKeyID added in v0.2.3

func (bin *Bin) SetKeyID(keyno uint8, value []byte) error

Set key ID

func (*Bin) SetPin added in v0.2.3

func (bin *Bin) SetPin(hexstring string) error

func (*Bin) SetPinBytes added in v0.2.3

func (bin *Bin) SetPinBytes(pin []byte) error

func (*Bin) SetProgrammingID

func (bin *Bin) SetProgrammingID(no int, value string) error

func (*Bin) SetSasOpt

func (bin *Bin) SetSasOpt(opt bool)

func (*Bin) SetSyncData added in v0.2.3

func (bin *Bin) SetSyncData(no uint8, data []byte) error

func (*Bin) Unmarry added in v0.1.6

func (bin *Bin) Unmarry()

func (*Bin) Validate

func (bin *Bin) Validate() error

Validate all checksums and known tests to ensure a healthy bin

func (*Bin) XORBytes

func (bin *Bin) XORBytes() ([]byte, error)

Return Bytes() Xored for you ready for flashing

type Const1

type Const1 struct {
	Data     []byte `bin:"len:8" json:"data"`
	Checksum uint16 `bin:"le,len:2" json:"checksum"` // CRC16 MCRF4XX

} // 10 bytes

func (*Const1) Crc16

func (c *Const1) Crc16() uint16

func (*Const1) Validate added in v0.3.2

func (c *Const1) Validate() error

type DiagnosticData added in v0.2.8

type DiagnosticData struct {
	Data1_1   []byte `bin:"len:14" json:"data1_1"`
	DTCS1     []byte `bin:"len:14" json:"dtcs1"`
	Data1_2   []byte `bin:"len:14" json:"data1_2"`
	Checksum1 uint16 `bin:"le,len:2" json:"checksum1" `
	Data2_1   []byte `bin:"len:14" json:"data2_1"`
	DTCS2     []byte `bin:"len:14" json:"dtcs2"`
	Data2_2   []byte `bin:"len:14" json:"data2_2"`
	Checksum2 uint16 `bin:"le,len:2" json:"checksum2"`
}

func (*DiagnosticData) Crc16 added in v0.2.8

func (u *DiagnosticData) Crc16() (uint16, uint16)

func (*DiagnosticData) Validate added in v0.3.2

func (u *DiagnosticData) Validate() error

type KeyID added in v0.2.1

type KeyID struct {
	Value []byte `bin:"len:4" json:"value"`
}

func (*KeyID) Type added in v0.2.1

func (kid *KeyID) Type() string

type Keys

type Keys struct {
	IskHI1    []byte  `bin:"len:4" json:"isk_hi1"`
	IskLO1    []byte  `bin:"len:2" json:"isk_lo1"`
	Data1     []KeyID `bin:"len:5,[len:4]" json:"data1"`
	Count1    uint8   `bin:"len:1" json:"count1"`
	Constant1 []byte  `bin:"len:7" json:"constant1"`
	Errors1   uint8   `bin:"len:1" json:"errors1"`
	Checksum1 uint16  `bin:"le,len:2" json:"checksum1"`
	IskHI2    []byte  `bin:"len:4" json:"isk_hi2"`
	IskLO2    []byte  `bin:"len:2" json:"isk_lo2"`
	Data2     []KeyID `bin:"len:5,[len:4]" json:"data2"`
	Count2    uint8   `bin:"len:1" json:"count2"`
	Constant2 []byte  `bin:"len:7" json:"constant2"`
	Errors2   uint8   `bin:"len:1" json:"errors2"`
	Checksum2 uint16  `bin:"le,len:2" json:"checksum2"` // CRC16 MCRF4XX

} // 74 bytes

func (*Keys) Crc16

func (k *Keys) Crc16() (uint16, uint16)

func (*Keys) SetISK added in v0.2.2

func (k *Keys) SetISK(data []byte) error

func (*Keys) SetISKHigh added in v0.2.2

func (k *Keys) SetISKHigh(value string) error

func (*Keys) SetISKLow added in v0.2.2

func (k *Keys) SetISKLow(value string) error

func (*Keys) Validate added in v0.3.2

func (k *Keys) Validate() error

type OptionRemoteFrequency added in v0.3.2

type OptionRemoteFrequency int
var (
	OptionRemoteFrequency433MHzOr315MHzLongDistance OptionRemoteFrequency = 0
	OptionRemoteFrequency315MHzShortDistance        OptionRemoteFrequency = 1
)

func (*OptionRemoteFrequency) String added in v0.3.2

func (orf *OptionRemoteFrequency) String() string

type Options added in v0.2.8

type Options struct {
	Data     uint16 `bin:"le,len:2" json:"data"`
	Checksum uint16 `bin:"le,len:2" json:"checksum"`
}

func (*Options) Crc16 added in v0.2.8

func (u *Options) Crc16() uint16

func (*Options) GetOptions added in v0.3.2

func (opts *Options) GetOptions() *OptionsResult

func (*Options) Validate added in v0.3.2

func (u *Options) Validate() error

type OptionsResult added in v0.3.2

type OptionsResult struct {
	Unknown1               bool
	SteeringWheelControlls bool
	SentronicControlls     bool
	RemoteFrequency        OptionRemoteFrequency
	Unknown2               bool
	RainSensor             bool
	CruiseControl          bool
	AutomaticTransmission  bool
	Unknown3               bool
	Facelift               bool
	Unknown4               bool
	RearWiper              bool
}

func (*OptionsResult) Byte added in v0.3.2

func (o *OptionsResult) Byte() uint16

func (*OptionsResult) String added in v0.3.2

func (o *OptionsResult) String() string

type Opts added in v0.3.2

type Opts struct {
}

type PSK

type PSK struct {
	High     []byte `bin:"len:4" json:"high"`
	Low      []byte `bin:"len:2" json:"low"`
	Constant []byte `bin:"len:4" json:"constant"`
	Unknown  []byte `bin:"len:2" json:"unknown"`
	Checksum uint16 `bin:"le,len:2" json:"checksum"` // CRC16 MCRF4XX

} // 14 bytes

func (*PSK) Crc16

func (p *PSK) Crc16() uint16

func (*PSK) SetHigh

func (p *PSK) SetHigh(high []byte) error

func (*PSK) SetLow

func (p *PSK) SetLow(low []byte) error

func (*PSK) Validate added in v0.3.2

func (p *PSK) Validate() error

type Pin

type Pin struct {
	Data1     []byte `bin:"len:4" json:"data1"`
	Unknown1  []byte `bin:"len:4" json:"unknown1"`
	Checksum1 uint16 `bin:"le,len:2" json:"checksum1"`
	Data2     []byte `bin:"len:4" json:"data2"`
	Unknown2  []byte `bin:"len:4" json:"unknown2"`
	Checksum2 uint16 `bin:"le,len:2" json:"checksum2"`

} // 20 bytes

0xb4 and 0xb5 are also counters - both separate, byte 1 and byte 2 in Data

func (*Pin) Crc16

func (p *Pin) Crc16() (uint16, uint16)

func (*Pin) Validate added in v0.3.2

func (p *Pin) Validate() error

type SASCalibration

type SASCalibration struct {
	Data1     []byte `bin:"len:4" json:"data1"`
	Checksum1 uint16 `bin:"le,len:2" json:"checksum1"`
	Data2     []byte `bin:"len:4" json:"data2"`
	Checksum2 uint16 `bin:"le,len:2" json:"checksum2"`
}

func (*SASCalibration) Crc16

func (u *SASCalibration) Crc16() (uint16, uint16)

func (*SASCalibration) Set

func (u *SASCalibration) Set(data []byte) error

func (*SASCalibration) Validate added in v0.3.2

func (u *SASCalibration) Validate() error

type Sync

type Sync struct {
	Data      [][]byte `bin:"len:5,[len:4]" json:"data"`
	Checksum  uint16   `bin:"le,len:2" json:"checksum"`
	Bank1     [][]byte `bin:"len:5,[len:4]" json:"data1"`
	Checksum1 uint16   `bin:"le,len:2" json:"checksum1"`
	Bank2     [][]byte `bin:"len:5,[len:4]" json:"data2"`
	Checksum2 uint16   `bin:"le,len:2" json:"checksum2"`

} // 66 bytes

func (*Sync) Crc16

func (s *Sync) Crc16() (uint16, uint16, uint16)

func (*Sync) Validate added in v0.3.2

func (s *Sync) Validate() error

type UnknownData1

type UnknownData1 struct {
	Data1     []byte `bin:"len:20"`
	Checksum1 uint16 `bin:"le,len:2"`
	Data2     []byte `bin:"len:20"`
	Checksum2 uint16 `bin:"le,len:2"`
}

func (*UnknownData1) Crc16

func (u *UnknownData1) Crc16() (uint16, uint16)

func (*UnknownData1) Validate added in v0.3.2

func (u *UnknownData1) Validate() error

type UnknownData2

type UnknownData2 struct {
	Data1     []byte `bin:"len:5"`
	Checksum1 uint16 `bin:"le,len:2"`
	Data2     []byte `bin:"len:5"`
	Checksum2 uint16 `bin:"le,len:2"`
}

func (*UnknownData2) Crc16

func (u *UnknownData2) Crc16() (uint16, uint16)

func (*UnknownData2) Validate added in v0.3.2

func (u *UnknownData2) Validate() error

type UnknownData5

type UnknownData5 struct {
	Data     []byte `bin:"len:23" json:"data"`
	Checksum uint16 `bin:"le,len:2" json:"checksum"`
}

func (*UnknownData5) Crc16

func (u *UnknownData5) Crc16() uint16

func (*UnknownData5) Validate added in v0.3.2

func (u *UnknownData5) Validate() error

type UnknownData7

type UnknownData7 struct {
	Data1     []byte `bin:"len:5" json:"data1"`
	Checksum1 uint16 `bin:"le,len:2" json:"checksum1"`
	Data2     []byte `bin:"len:5" json:"data2"`
	Checksum2 uint16 `bin:"le,len:2" json:"checksum2"`
}

address 1a6 (last byte) changed with region setting - 1 = EU, 0 = GB

func (*UnknownData7) Crc16

func (u *UnknownData7) Crc16() (uint16, uint16)

func (*UnknownData7) Validate added in v0.3.2

func (u *UnknownData7) Validate() error

type UnknownData8

type UnknownData8 struct {
	Data     []byte `bin:"len:6" json:"data"`
	Checksum uint16 `bin:"le,len:2" json:"checksum"`
}

func (*UnknownData8) Crc16

func (u *UnknownData8) Crc16() uint16

func (*UnknownData8) Validate added in v0.3.2

func (u *UnknownData8) Validate() error

type UnknownData9

type UnknownData9 struct {
	Data     []byte `bin:"len:5" json:"data"`
	Checksum uint16 `bin:"le,len:2" json:"checksum"`
}

func (*UnknownData9) Crc16

func (u *UnknownData9) Crc16() uint16

func (*UnknownData9) Validate added in v0.3.2

func (u *UnknownData9) Validate() error

type Vin

type Vin struct {
	Data       string `bin:"len:17" json:"data"` // Vin as ASCII
	AddCounter uint8  `bin:"len:1" json:"value"` // unknown value, seems to be a counter?
	Unknown    []byte `bin:"len:9" json:"unknown"`
	SpsCount   uint8  `bin:"len:1" json:"spscount"`
	Checksum   uint16 `bin:"le,len:2" json:"checksum"` // CRC16 MCRF4XX

} // 30 bytes

func (*Vin) Crc16

func (v *Vin) Crc16() uint16

func (*Vin) Set

func (v *Vin) Set(vin string) error

func (*Vin) SetAddCounter added in v0.3.2

func (v *Vin) SetAddCounter(val uint8)

func (*Vin) SetSpsCount

func (v *Vin) SetSpsCount(value uint8)

func (*Vin) Validate added in v0.3.2

func (v *Vin) Validate() error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL