pyxcp package

Submodules

pyxcp.checksum module

Checksum calculation for memory ranges

[1]XCP Specification, BUILD_CHECKSUM service.
pyxcp.checksum.ADD11(frame)
pyxcp.checksum.ADD12(frame)
pyxcp.checksum.ADD14(frame)
pyxcp.checksum.ADD22(frame)
pyxcp.checksum.ADD24(frame)
pyxcp.checksum.ADD44(frame)
class pyxcp.checksum.Algorithm

Bases: enum.IntEnum

Enumerates available checksum algorithms

XCP_ADD_11 = 1
XCP_ADD_12 = 2
XCP_ADD_14 = 3
XCP_ADD_22 = 4
XCP_ADD_24 = 5
XCP_ADD_44 = 6
XCP_CRC_16 = 7
XCP_CRC_16_CITT = 8
XCP_CRC_32 = 9
XCP_USER_DEFINED = 10
pyxcp.checksum.CRC32(x)
class pyxcp.checksum.Crc16(table, initalRemainder, finalXorValue, reflectData, reflectRemainder)

Bases: object

Calculate CRC (16-bit)

Parameters:
WIDTH = 16
reflectIn(ch, remainder)
reflectOut(remainder)
pyxcp.checksum.adder(modulus)

Factory function for modulus adders

Parameters:modulus (int) – modulus to use
Returns:adder function
Return type:function

Examples

>>> a256=adder(256)
>>> a256([11, 22, 33, 44, 55, 66, 77, 88, 99])
239
pyxcp.checksum.check(frame, algo)

Calculate checksum using given algorithm

Parameters:
  • frame (list of integers) –
  • algo (ALGO) –
Returns:

Return type:

int

pyxcp.checksum.reflect(data, nBits)

Reflect data, i.e. reverse bit order.

Parameters:
  • data (int) –
  • nBits (int) – width in bits of data
pyxcp.checksum.userDefined(x)

User defined algorithms are not supported yet.

pyxcp.checksum.wordSum(modulus, step)

Factory function for (double-)word modulus sums

Parameters:
  • modulus (int) –
  • step ([2, 4]) – 2 - word wise 4 - double-word wise
Returns:

summation function

Return type:

function

pyxcp.config module

class pyxcp.config.Configuration(parameters, config)

Bases: object

get(key)
pyxcp.config.readConfiguration(conf)

Read a configuration file either in JSON or TOML format.

pyxcp.errormatrix module

Types and structures to support error-handling as specified by XCP.

class pyxcp.errormatrix.Action

Bases: enum.IntEnum

Action to be taken, s. XCP spec.

DISPLAY_ERROR = 1
NEW_FLASH_WARE = 12
NONE = 0
REPEAT = 6
REPEAT_2_TIMES = 7
REPEAT_INF_TIMES = 8
RESTART_SESSION = 9
RETRY_PARAM = 3
RETRY_SYNTAX = 2
SKIP = 11
TERMINATE_SESSION = 10
USE_A2L = 4
USE_ALTERATIVE = 5
class pyxcp.errormatrix.Handler(preAction, action)

Bases: tuple

action

Alias for field number 1

preAction

Alias for field number 0

class pyxcp.errormatrix.PreAction

Bases: enum.IntEnum

Pre-action to be taken, s. XCP spec.

DISPLAY_ERROR = 9
DOWNLOAD = 10
GET_SEED_UNLOCK = 3
NONE = 0
PROGRAM = 11
REINIT_DAQ = 8
SET_DAQ_PTR = 6
SET_MTA = 4
START_STOP_X = 7
SYNCH = 2
UNLOCK_SLAVE = 13
UPLOAD = 12
WAIT_T7 = 1
class pyxcp.errormatrix.Severity

Bases: enum.IntEnum

Severity of error. — S0 = Information S1 = Warning / Request S2 = Resolvable Error S3 = Fatal Error

S0 = 0
S1 = 1
S2 = 2
S3 = 3
class pyxcp.errormatrix.Timeout

Bases: enum.IntEnum

Various timeouts, s. XCP spec.

T1 = 0
T2 = 1
T3 = 2
T4 = 3
T5 = 4
T6 = 5
T7 = 6

pyxcp.logger module

class pyxcp.logger.Logger(name, level=30)

Bases: object

FORMAT = '[%(levelname)s (%(name)s)]: %(message)s'
LOGGER_BASE_NAME = 'pyxcp'
critical(message)
debug(message)
error(message)
getLastError()
info(message)
log(message, level)
setLevel(level)
silent()
verbose()
warn(message)

pyxcp.types module

class pyxcp.types.Command

Bases: enum.IntEnum

An enumeration.

ALLOC_DAQ = 213
ALLOC_ODT = 212
ALLOC_ODT_ENTRY = 211
BUILD_CHECKSUM = 243
CLEAR_DAQ_LIST = 227
CONNECT = 255
COPY_CAL_PAGE = 228
DBG_ATTACH = 12647424
DBG_EXCLUSIVE_TARGET_ACCESS = 12647432
DBG_GET_HWIO_INFO = 12647429
DBG_GET_JTAG_ID = 12647427
DBG_GET_MODE_INFO = 12647426
DBG_GET_TRI_DESC_TBL = 12647444
DBG_GET_VENDOR_INFO = 12647425
DBG_HALT_AFTER_RESET = 12647428
DBG_HWIO_CONTROL = 12647431
DBG_LLBT = 12647445
DBG_LLT = 12647434
DBG_READ = 12647441
DBG_READ_CAN1 = 12647442
DBG_READ_CAN2 = 12647443
DBG_READ_MODIFY_WRITE = 12647435
DBG_SEQUENCE_MULTIPLE = 12647433
DBG_SET_HWIO_EVENT = 12647430
DBG_WRITE = 12647436
DBG_WRITE_CAN1 = 12647438
DBG_WRITE_CAN2 = 12647439
DBG_WRITE_CAN_NEXT = 12647440
DBG_WRITE_NEXT = 12647437
DISCONNECT = 254
DOWNLOAD = 240
DOWNLOAD_MAX = 238
DOWNLOAD_NEXT = 239
DTO_CTR_PROPERTIES = 197
FREE_DAQ = 214
GET_CAL_PAGE = 234
GET_COMM_MODE_INFO = 251
GET_DAQ_CLOCK = 220
GET_DAQ_EVENT_INFO = 215
GET_DAQ_LIST_INFO = 216
GET_DAQ_LIST_MODE = 223
GET_DAQ_PACKED_MODE = 49154
GET_DAQ_PROCESSOR_INFO = 218
GET_DAQ_RESOLUTION_INFO = 217
GET_ID = 250
GET_PAGE_INFO = 231
GET_PAG_PROCESSOR_INFO = 233
GET_PGM_PROCESSOR_INFO = 206
GET_SECTOR_INFO = 205
GET_SEED = 248
GET_SEGMENT_INFO = 232
GET_SEGMENT_MODE = 229
GET_STATUS = 253
GET_VERSION = 49152
MODIFY_BITS = 236
PROGRAM = 208
PROGRAM_CLEAR = 209
PROGRAM_FORMAT = 203
PROGRAM_MAX = 201
PROGRAM_NEXT = 202
PROGRAM_PREPARE = 204
PROGRAM_RESET = 207
PROGRAM_START = 210
PROGRAM_VERIFY = 200
READ_DAQ = 219
SET_CAL_PAGE = 235
SET_DAQ_LIST_MODE = 224
SET_DAQ_PACKED_MODE = 49153
SET_DAQ_PTR = 226
SET_MTA = 246
SET_REQUEST = 249
SET_SEGMENT_MODE = 230
SHORT_DOWNLOAD = 237
SHORT_UPLOAD = 244
START_STOP_DAQ_LIST = 222
START_STOP_SYNCH = 221
SYNCH = 252
TIME_CORRELATION_PROPERTIES = 198
TRANSPORT_LAYER_CMD = 242
UNLOCK = 247
UPLOAD = 245
USER_CMD = 241
WRITE_DAQ = 225
WRITE_DAQ_MULTIPLE = 199
class pyxcp.types.CommandCategory

Bases: enum.IntEnum

Values reflect resources (resource protection status / unlock).

CAL_PAG = 1
DAQ = 4
PGM = 16
STD = 0
STIM = 8
class pyxcp.types.DaqPtr(daqListNumber, odtNumber, odtEntryNumber)

Bases: tuple

daqListNumber

Alias for field number 0

odtEntryNumber

Alias for field number 2

odtNumber

Alias for field number 1

class pyxcp.types.Event

Bases: enum.IntEnum

XCP Event Codes

EV_CLEAR_DAQ = 1
EV_CMD_PENDING = 5
EV_DAQ_OVERLOAD = 6
EV_RESUME_MODE = 0
EV_SESSION_TERMINATED = 7
EV_SLEEP = 10
EV_STIM_TIMEOUT = 9
EV_STORE_CAL = 3
EV_STORE_DAQ = 2
EV_TIME_SYNC = 8
EV_TRANSPORT = 255
EV_USER = 254
EV_WAKE_UP = 11
exception pyxcp.types.FrameSizeError

Bases: Exception

A frame with an invalid size was received.

class pyxcp.types.MtaType(address, ext)

Bases: tuple

address

Alias for field number 0

ext

Alias for field number 1

class pyxcp.types.XcpGetIdType

Bases: enum.IntEnum

An enumeration.

ASCII_TEXT = 0
ECU = 6
EPK = 5
FILENAME = 1
FILE_AND_PATH = 2
FILE_TO_UPLOAD = 4
SYSID = 7
URL = 3
VECTOR_MAPNAMES = 219
VECTOR_MDI = 220
class pyxcp.types.XcpGetSeedMode

Bases: enum.IntEnum

An enumeration.

FIRST_PART = 0
REMAINING = 1
exception pyxcp.types.XcpResponseError

Bases: Exception

Raise an exception from an XCP error packet.

get_error_code()
exception pyxcp.types.XcpTimeoutError

Bases: Exception

Timeout while waiting for a response occured.

pyxcp.utils module

pyxcp.utils.delay(amount: float)

Performe a busy-wait delay, which is much more precise than time.sleep

pyxcp.utils.flatten(*args)
pyxcp.utils.getPythonVersion()
pyxcp.utils.hexDump(arr)
pyxcp.utils.slicer(iterable, sliceLength, converter=None)
pyxcp.utils.time_perfcounter_correlation()

Get the perf_counter value nearest to when time.time() is updated if the time.time on this platform has a resolution higher than 10us. This is tipical for the Windows platform were the beste resolution is ~500us.

On non Windows platforms the current time and perf_counter is directly returned since the resolution is tipical ~1us.

Note this value is based on when time.time() is observed to update from Python, it is not directly returned by the operating system.

Returns:(t, performance_counter) time.time value and perf_counter value when the time.time is updated
pyxcp.utils.ConnectResponse

Some Doc

Module contents

Universal Calibration Protocol for Python