panda.python package

Submodules

panda.python.base module

class panda.python.base.BaseHandle[source]

Bases: ABC

A handle to talk to a panda. Borrows heavily from the libusb1 handle API.

abstract bulkRead(endpoint: int, length: int, timeout: int = 15000) bytes[source]
abstract bulkWrite(endpoint: int, data: bytes, timeout: int = 15000) int[source]
abstract close() None[source]
abstract controlRead(request_type: int, request: int, value: int, index: int, length: int, timeout: int = 15000) bytes[source]
abstract controlWrite(request_type: int, request: int, value: int, index: int, data, timeout: int = 15000, expect_disconnect: bool = False)[source]
class panda.python.base.BaseSTBootloaderHandle[source]

Bases: ABC

A handle to talk to a panda while it’s in the STM32 bootloader.

abstract clear_status() None[source]
abstract close() None[source]
abstract erase_sector(sector: int) None[source]
abstract get_mcu_type() McuType[source]
abstract jump(address: int) None[source]
abstract program(address: int, dat: bytes) None[source]

panda.python.canhandle module

class panda.python.canhandle.CanHandle(p, bus)[source]

Bases: BaseHandle

bulkRead(endpoint, length, timeout=0)[source]
bulkWrite(endpoint, data, timeout=0)[source]
close()[source]
controlRead(request_type, request, value, index, length, timeout=0)[source]
controlWrite(request_type, request, value, index, data, timeout=0, expect_disconnect=False)[source]
transact(dat)[source]

panda.python.ccp module

class panda.python.ccp.BYTE_ORDER(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: Enum

BIG_ENDIAN = '>'
LITTLE_ENDIAN = '<'
class panda.python.ccp.COMMAND_CODE(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: IntEnum

ACTION_SERVICE = 33
BUILD_CHKSUM = 14
CLEAR_MEMORY = 16
CONNECT = 1
DIAG_SERVICE = 32
DISCONNECT = 7
DNLOAD = 3
DNLOAD_6 = 35
EXCHANGE_ID = 23
GET_ACTIVE_CAL_PAGE = 9
GET_CCP_VERSION = 27
GET_DAQ_SIZE = 20
GET_SEED = 18
GET_S_STATUS = 13
MOVE = 25
PROGRAM = 24
PROGRAM_6 = 34
SELECT_CAL_PAGE = 17
SET_DAQ_PTR = 21
SET_MTA = 2
SET_S_STATUS = 12
SHORT_UP = 15
START_STOP = 6
START_STOP_ALL = 8
TEST = 5
UNLOCK = 19
UPLOAD = 4
WRITE_DAQ = 22
class panda.python.ccp.CcpClient(panda, tx_addr: int, rx_addr: int, bus: int = 0, byte_order: BYTE_ORDER = BYTE_ORDER.BIG_ENDIAN, debug=False)[source]

Bases: object

action_service(service_num: int, data: bytes = b'') dict[source]
build_checksum(size: int) bytes[source]
clear_memory(size: int) None[source]
connect(station_addr: int) None[source]
diagnostic_service(service_num: int, data: bytes = b'') dict[source]
disconnect(station_addr: int, temporary: bool = False) None[source]
download(data: bytes) int[source]
download_6_bytes(data: bytes) int[source]
exchange_station_ids(device_id_info: bytes = b'') dict[source]
get_active_calibration_page()[source]
get_daq_list_size(list_num: int, can_id: int = 0) dict[source]
get_seed(resource_mask: int) bytes[source]
get_session_status() dict[source]
get_version(desired_version: float = 2.1) float[source]
move_memory_block(size: int) None[source]
program(size: int, data: bytes) int[source]
program_6_bytes(data: bytes) int[source]
select_calibration_page() None[source]
set_daq_list_pointer(list_num: int, odt_num: int, element_num: int) None[source]
set_memory_transfer_address(mta_num: int, addr_ext: int, addr: int) None[source]
set_session_status(status: int) None[source]
short_upload(size: int, addr_ext: int, addr: int) bytes[source]
start_stop_synchronised_transmission(mode: int) None[source]
start_stop_transmission(mode: int, list_num: int, odt_num: int, channel_num: int, rate_prescaler: int = 0) None[source]
test_availability(station_addr: int) None[source]
unlock(key: bytes) int[source]
upload(size: int) bytes[source]
write_daq_list_entry(size: int, addr_ext: int, addr: int) None[source]
exception panda.python.ccp.CommandCounterError[source]

Bases: Exception

exception panda.python.ccp.CommandResponseError(message, return_code)[source]

Bases: Exception

exception panda.python.ccp.CommandTimeoutError[source]

Bases: Exception

panda.python.constants module

class panda.python.constants.McuConfig(mcu, mcu_idcode, sector_sizes, sector_count, uid_address, block_size, serial_number_address, app_address, app_fn, bootstub_address, bootstub_fn)[source]

Bases: NamedTuple

app_address: int

Alias for field number 7

app_fn: str

Alias for field number 8

block_size: int

Alias for field number 5

bootstub_address: int

Alias for field number 9

bootstub_fn: str

Alias for field number 10

mcu: str

Alias for field number 0

mcu_idcode: int

Alias for field number 1

sector_address(i)[source]
sector_count: int

Alias for field number 3

sector_sizes: list[int]

Alias for field number 2

serial_number_address: int

Alias for field number 6

uid_address: int

Alias for field number 4

class panda.python.constants.McuType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: Enum

F4 = ('STM32F4', 1123, [16384, 16384, 16384, 16384, 65536, 131072, 131072, 131072, 131072, 131072, 131072, 131072, 131072, 131072, 131072, 131072], 16, 536836624, 2048, 536836544, 134234112, 'panda.bin.signed', 134217728, 'bootstub.panda.bin')
H7 = ('STM32H7', 1155, [131072, 131072, 131072, 131072, 131072, 131072, 131072], 8, 535947264, 1024, 135266240, 134348800, 'panda_h7.bin.signed', 134217728, 'bootstub.panda_h7.bin')
property config

panda.python.dfu module

class panda.python.dfu.PandaDFU(dfu_serial: str | None)[source]

Bases: object

close()[source]
get_mcu_type() McuType[source]
static list() list[str][source]
program_bootstub(code_bootstub)[source]
recover()[source]
reset()[source]
static spi_connect(dfu_serial: str | None)[source]
static spi_list() list[str][source]
static st_serial_to_dfu_serial(st: str, mcu_type: McuType = McuType.F4)[source]
static usb_connect(dfu_serial: str | None)[source]
static usb_list() list[str][source]

panda.python.isotp module

panda.python.isotp.isotp_recv(panda, addr, bus=0, sendaddr=None, subaddr=None)[source]
panda.python.isotp.isotp_recv_subaddr(panda, addr, bus, sendaddr, subaddr)[source]
panda.python.isotp.isotp_send(panda, x, addr, bus=0, recvaddr=None, subaddr=None, rate=None)[source]
panda.python.isotp.msg(x)[source]
panda.python.isotp.recv(panda, cnt, addr, nbus)[source]

panda.python.serial module

class panda.python.serial.PandaSerial(panda, port, baud)[source]

Bases: object

property baudrate
close()[source]
flush()[source]
read(l=1)[source]
write(dat)[source]

panda.python.spi module

exception panda.python.spi.PandaProtocolMismatch[source]

Bases: PandaSpiException

exception panda.python.spi.PandaSpiBadChecksum[source]

Bases: PandaSpiException

exception panda.python.spi.PandaSpiException[source]

Bases: Exception

class panda.python.spi.PandaSpiHandle[source]

Bases: BaseHandle

A class that mimics a libusb1 handle for panda SPI communications.

PROTOCOL_VERSION = 2
bulkRead(endpoint: int, length: int, timeout: int = 15000) bytes[source]
bulkWrite(endpoint: int, data: bytes, timeout: int = 15000) int[source]
close()[source]
controlRead(request_type: int, request: int, value: int, index: int, length: int, timeout: int = 15000)[source]
controlWrite(request_type: int, request: int, value: int, index: int, data, timeout: int = 15000, expect_disconnect: bool = False)[source]
get_protocol_version() bytes[source]
exception panda.python.spi.PandaSpiMissingAck[source]

Bases: PandaSpiException

exception panda.python.spi.PandaSpiNackResponse[source]

Bases: PandaSpiException

class panda.python.spi.PandaSpiTransfer[source]

Bases: Structure

endpoint

Structure/Union member

expect_disconnect

Structure/Union member

rx_buf

Structure/Union member

rx_length_max

Structure/Union member

timeout

Structure/Union member

tx_buf

Structure/Union member

tx_length

Structure/Union member

exception panda.python.spi.PandaSpiTransferFailed[source]

Bases: PandaSpiException

exception panda.python.spi.PandaSpiUnavailable[source]

Bases: PandaSpiException

class panda.python.spi.STBootloaderSPIHandle[source]

Bases: BaseSTBootloaderHandle

Implementation of the STM32 SPI bootloader protocol described in: https://www.st.com/resource/en/application_note/an4286-spi-protocol-used-in-the-stm32-bootloader-stmicroelectronics.pdf

ACK = 121
NACK = 31
SYNC = 90
clear_status()[source]
close()[source]
erase_sector(sector: int)[source]
get_chip_id() int[source]
get_mcu_type()[source]
get_uid()[source]
go_cmd(address: int) None[source]
jump(address)[source]
program(address, dat)[source]
read(address: int, length: int)[source]
class panda.python.spi.SpiDevice(speed=50000000)[source]

Bases: object

Provides locked, thread-safe access to a panda’s SPI interface.

MAX_SPEED = 50000000
acquire()[source]
close()[source]
panda.python.spi.crc8(data)[source]

panda.python.uds module

class panda.python.uds.ACCESS_TYPE(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: IntEnum

REQUEST_SEED = 1
SEND_KEY = 2
class panda.python.uds.BAUD_RATE_TYPE(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: IntEnum

CAN1000000 = 19
CAN125000 = 16
CAN250000 = 17
CAN500000 = 18
PC115200 = 5
PC19200 = 2
PC38400 = 3
PC57600 = 4
PC9600 = 1
class panda.python.uds.CONTROL_PARAMETER_TYPE(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: IntEnum

FREEZE_CURRENT_STATE = 2
RESET_TO_DEFAULT = 1
RETURN_CONTROL_TO_ECU = 0
SHORT_TERM_ADJUSTMENT = 3
class panda.python.uds.CONTROL_TYPE(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: IntEnum

DISABLE_RX_DISABLE_TX = 3
DISABLE_RX_ENABLE_TX = 2
ENABLE_RX_DISABLE_TX = 1
ENABLE_RX_ENABLE_TX = 0
class panda.python.uds.CanClient(can_send: Callable[[int, bytes, int], None], can_recv: Callable[[], list[tuple[int, int, bytes, int]]], tx_addr: int, rx_addr: int, bus: int, sub_addr: int | None = None, debug: bool = False)[source]

Bases: object

recv(drain: bool = False) Generator[bytes, None, None][source]
send(msgs: list[bytes], delay: float = 0) None[source]
class panda.python.uds.DATA_IDENTIFIER_TYPE(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: IntEnum

ACTIVE_DIAGNOSTIC_SESSION = 61830
APPLICATION_DATA_FINGERPRINT = 61829
APPLICATION_DATA_IDENTIFICATION = 61826
APPLICATION_SOFTWARE_FINGERPRINT = 61828
APPLICATION_SOFTWARE_IDENTIFICATION = 61825
BOOT_SOFTWARE_FINGERPRINT = 61827
BOOT_SOFTWARE_IDENTIFICATION = 61824
CALIBRATION_DATE = 61851
CALIBRATION_EQUIPMENT_SOFTWARE_NUMBER = 61852
CALIBRATION_REPAIR_SHOP_CODE_OR_CALIBRATION_EQUIPMENT_SERIAL_NUMBER = 61850
ECU_INSTALLATION_DATE = 61853
ECU_MANUFACTURING_DATE = 61835
ECU_SERIAL_NUMBER = 61836
ENTITY = 61855
EXHAUST_REGULATION_OR_TYPE_APPROVAL_NUMBER = 61846
ODX_FILE = 61854
PROGRAMMING_DATE = 61849
REPAIR_SHOP_CODE_OR_TESTER_SERIAL_NUMBER = 61848
SUPPORTED_FUNCTIONAL_UNITS = 61837
SYSTEM_NAME_OR_ENGINE_TYPE = 61847
SYSTEM_SUPPLIER_ECU_HARDWARE_NUMBER = 61842
SYSTEM_SUPPLIER_ECU_HARDWARE_VERSION_NUMBER = 61843
SYSTEM_SUPPLIER_ECU_SOFTWARE_NUMBER = 61844
SYSTEM_SUPPLIER_ECU_SOFTWARE_VERSION_NUMBER = 61845
SYSTEM_SUPPLIER_IDENTIFIER = 61834
VEHICLE_MANUFACTURER_ECU_HARDWARE_NUMBER = 61841
VEHICLE_MANUFACTURER_ECU_SOFTWARE_NUMBER = 61832
VEHICLE_MANUFACTURER_ECU_SOFTWARE_VERSION_NUMBER = 61833
VEHICLE_MANUFACTURER_KIT_ASSEMBLY_PART_NUMBER = 61838
VEHICLE_MANUFACTURER_SPARE_PART_NUMBER = 61831
VIN = 61840
class panda.python.uds.DTC_GROUP_TYPE(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: IntEnum

ALL = 16777215
EMISSIONS = 0
class panda.python.uds.DTC_REPORT_TYPE(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: IntEnum

DTC_BY_SEVERITY_MASK_RECORD = 8
DTC_BY_STATUS_MASK = 2
DTC_EXTENDED_DATA_RECORD_BY_DTC_NUMBER = 6
DTC_FAULT_DETECTION_COUNTER = 20
DTC_SNAPSHOT_IDENTIFICATION = 3
DTC_SNAPSHOT_RECORD_BY_DTC_NUMBER = 4
DTC_SNAPSHOT_RECORD_BY_RECORD_NUMBER = 5
DTC_WITH_PERMANENT_STATUS = 21
FIRST_CONFIRMED_DTC = 12
FIRST_TEST_FAILED_DTC = 11
MIRROR_MEMORY_DTC_BY_STATUS_MASK = 15
MIRROR_MEMORY_DTC_EXTENDED_DATA_RECORD_BY_DTC_NUMBER = 16
MOST_RECENT_CONFIRMED_DTC = 14
MOST_RECENT_TEST_FAILED_DTC = 13
NUMBER_OF_DTC_BY_SEVERITY_MASK_RECORD = 7
NUMBER_OF_DTC_BY_STATUS_MASK = 1
NUMBER_OF_MIRROR_MEMORY_DTC_BY_STATUS_MASK = 17
SEVERITY_INFORMATION_OF_DTC = 9
SUPPORTED_DTC = 10
class panda.python.uds.DTC_SETTING_TYPE(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: IntEnum

OFF = 2
ON = 1
class panda.python.uds.DTC_SEVERITY_MASK_TYPE(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: IntEnum

ALL = 224
CHECK_AT_NEXT_HALT = 64
CHECK_IMMEDIATELY = 128
MAINTENANCE_ONLY = 32
class panda.python.uds.DTC_STATUS_MASK_TYPE(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: IntEnum

ALL = 255
CONFIRMED_DTC = 8
PENDING_DTC = 4
TEST_FAILED = 1
TEST_FAILED_SINCE_LAST_CLEAR = 32
TEST_FAILED_THIS_OPERATION_CYCLE = 2
TEST_NOT_COMPLETED_SINCE_LAST_CLEAR = 16
TEST_NOT_COMPLETED_THIS_OPERATION_CYCLE = 64
WARNING_INDICATOR_REQUESTED = 128
class panda.python.uds.DYNAMIC_DEFINITION_TYPE(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: IntEnum

CLEAR_DYNAMICALLY_DEFINED_DATA_IDENTIFIER = 3
DEFINE_BY_IDENTIFIER = 1
DEFINE_BY_MEMORY_ADDRESS = 2
class panda.python.uds.DynamicSourceDefinition(data_identifier, position, memory_size, memory_address)[source]

Bases: NamedTuple

data_identifier: int

Alias for field number 0

memory_address: int

Alias for field number 3

memory_size: int

Alias for field number 2

position: int

Alias for field number 1

class panda.python.uds.ISOTP_FRAME_TYPE(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: IntEnum

CONSECUTIVE = 2
FIRST = 1
FLOW = 3
SINGLE = 0
exception panda.python.uds.InvalidServiceIdError[source]

Bases: Exception

exception panda.python.uds.InvalidSubAddressError[source]

Bases: Exception

exception panda.python.uds.InvalidSubFunctionError[source]

Bases: Exception

class panda.python.uds.IsoTpMessage(can_client: CanClient, timeout: float = 1, single_frame_mode: bool = False, separation_time: float = 0, debug: bool = False, max_len: int = 8)[source]

Bases: object

recv(timeout=None) tuple[bytes | None, bool][source]
send(dat: bytes, setup_only: bool = False) None[source]

Bases: IntEnum

class panda.python.uds.MESSAGE_TYPE(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: IntEnum

NETWORK_MANAGEMENT = 2
NORMAL = 1
NORMAL_AND_NETWORK_MANAGEMENT = 3
exception panda.python.uds.MessageTimeoutError[source]

Bases: Exception

exception panda.python.uds.NegativeResponseError(message, service_id, error_code)[source]

Bases: Exception

class panda.python.uds.RESET_TYPE(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: IntEnum

DISABLE_RAPID_POWER_SHUTDOWN = 5
ENABLE_RAPID_POWER_SHUTDOWN = 4
HARD = 1
KEY_OFF_ON = 2
SOFT = 3
class panda.python.uds.RESPONSE_EVENT_TYPE(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: IntEnum

CLEAR_RESPONSE_ON_EVENT = 6
ON_CHANGE_OF_DATA_IDENTIFIER = 3
ON_COMPARISON_OF_VALUES = 7
ON_DTC_STATUS_CHANGE = 1
ON_TIMER_INTERRUPT = 2
REPORT_ACTIVATED_EVENTS = 4
START_RESPONSE_ON_EVENT = 5
STOP_RESPONSE_ON_EVENT = 0
class panda.python.uds.ROUTINE_CONTROL_TYPE(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: IntEnum

REQUEST_RESULTS = 3
START = 1
STOP = 2
class panda.python.uds.ROUTINE_IDENTIFIER_TYPE(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: IntEnum

CHECK_PROGRAMMING_DEPENDENCIES = 65281
ERASE_MEMORY = 65280
ERASE_MIRROR_MEMORY_DTCS = 65282
class panda.python.uds.SERVICE_TYPE(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: IntEnum

ACCESS_TIMING_PARAMETER = 131
CLEAR_DIAGNOSTIC_INFORMATION = 20
COMMUNICATION_CONTROL = 40
CONTROL_DTC_SETTING = 133
DIAGNOSTIC_SESSION_CONTROL = 16
DYNAMICALLY_DEFINE_DATA_IDENTIFIER = 44
ECU_RESET = 17
INPUT_OUTPUT_CONTROL_BY_IDENTIFIER = 47
READ_DATA_BY_IDENTIFIER = 34
READ_DATA_BY_PERIODIC_IDENTIFIER = 42
READ_DTC_INFORMATION = 25
READ_MEMORY_BY_ADDRESS = 35
READ_SCALING_DATA_BY_IDENTIFIER = 36
REQUEST_DOWNLOAD = 52
REQUEST_TRANSFER_EXIT = 55
REQUEST_UPLOAD = 53
RESPONSE_ON_EVENT = 134
ROUTINE_CONTROL = 49
SECURED_DATA_TRANSMISSION = 132
SECURITY_ACCESS = 39
TESTER_PRESENT = 62
TRANSFER_DATA = 54
WRITE_DATA_BY_IDENTIFIER = 46
WRITE_MEMORY_BY_ADDRESS = 61
class panda.python.uds.SESSION_TYPE(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: IntEnum

DEFAULT = 1
EXTENDED_DIAGNOSTIC = 3
PROGRAMMING = 2
SAFETY_SYSTEM_DIAGNOSTIC = 4
class panda.python.uds.TIMING_PARAMETER_TYPE(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: IntEnum

READ_CURRENTLY_ACTIVE = 3
READ_EXTENDED_SET = 1
SET_TO_DEFAULT_VALUES = 2
SET_TO_GIVEN_VALUES = 4
class panda.python.uds.TRANSMISSION_MODE_TYPE(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: IntEnum

SEND_AT_FAST_RATE = 3
SEND_AT_MEDIUM_RATE = 2
SEND_AT_SLOW_RATE = 1
STOP_SENDING = 4
class panda.python.uds.UdsClient(panda, tx_addr: int, rx_addr: int | None = None, bus: int = 0, sub_addr: int | None = None, timeout: float = 1, debug: bool = False, tx_timeout: float = 1, response_pending_timeout: float = 10)[source]

Bases: object

access_timing_parameter(timing_parameter_type: TIMING_PARAMETER_TYPE, parameter_values: bytes | None = None)[source]
clear_diagnostic_information(dtc_group_type: DTC_GROUP_TYPE)[source]
communication_control(control_type: CONTROL_TYPE, message_type: MESSAGE_TYPE)[source]
control_dtc_setting(dtc_setting_type: DTC_SETTING_TYPE)[source]
diagnostic_session_control(session_type: SESSION_TYPE)[source]
dynamically_define_data_identifier(dynamic_definition_type: DYNAMIC_DEFINITION_TYPE, dynamic_data_identifier: int, source_definitions: list[DynamicSourceDefinition], memory_address_bytes: int = 4, memory_size_bytes: int = 1)[source]
ecu_reset(reset_type: RESET_TYPE)[source]
input_output_control_by_identifier(data_identifier_type: DATA_IDENTIFIER_TYPE, control_parameter_type: CONTROL_PARAMETER_TYPE, control_option_record: bytes = b'', control_enable_mask_record: bytes = b'')[source]
read_data_by_identifier(data_identifier_type: DATA_IDENTIFIER_TYPE)[source]
read_data_by_periodic_identifier(transmission_mode_type: TRANSMISSION_MODE_TYPE, periodic_data_identifier: int)[source]
read_dtc_information(dtc_report_type: DTC_REPORT_TYPE, dtc_status_mask_type: DTC_STATUS_MASK_TYPE = DTC_STATUS_MASK_TYPE.ALL, dtc_severity_mask_type: DTC_SEVERITY_MASK_TYPE = DTC_SEVERITY_MASK_TYPE.ALL, dtc_mask_record: int = 16777215, dtc_snapshot_record_num: int = 255, dtc_extended_record_num: int = 255)[source]
read_memory_by_address(memory_address: int, memory_size: int, memory_address_bytes: int = 4, memory_size_bytes: int = 1)[source]
read_scaling_data_by_identifier(data_identifier_type: DATA_IDENTIFIER_TYPE)[source]
request_download(memory_address: int, memory_size: int, memory_address_bytes: int = 4, memory_size_bytes: int = 4, data_format: int = 0)[source]
request_transfer_exit()[source]
request_upload(memory_address: int, memory_size: int, memory_address_bytes: int = 4, memory_size_bytes: int = 4, data_format: int = 0)[source]
response_on_event(response_event_type: RESPONSE_EVENT_TYPE, store_event: bool, window_time: int, event_type_record: int, service_response_record: int)[source]
routine_control(routine_control_type: ROUTINE_CONTROL_TYPE, routine_identifier_type: ROUTINE_IDENTIFIER_TYPE, routine_option_record: bytes = b'')[source]
secured_data_transmission(data: bytes)[source]
security_access(access_type: ACCESS_TYPE, security_key: bytes = b'', data_record: bytes = b'')[source]
tester_present()[source]
transfer_data(block_sequence_count: int, data: bytes = b'')[source]
write_data_by_identifier(data_identifier_type: DATA_IDENTIFIER_TYPE, data_record: bytes)[source]
write_memory_by_address(memory_address: int, memory_size: int, data_record: bytes, memory_address_bytes: int = 4, memory_size_bytes: int = 1)[source]
panda.python.uds.get_dtc_num_as_str(dtc_num_bytes)[source]
panda.python.uds.get_dtc_status_names(status)[source]
panda.python.uds.get_rx_addr_for_tx_addr(tx_addr, rx_offset=8)[source]

panda.python.usb module

class panda.python.usb.PandaUsbHandle(libusb_handle)[source]

Bases: BaseHandle

bulkRead(endpoint: int, length: int, timeout: int = 15000) bytes[source]
bulkWrite(endpoint: int, data: bytes, timeout: int = 15000) int[source]
close()[source]
controlRead(request_type: int, request: int, value: int, index: int, length: int, timeout: int = 15000)[source]
controlWrite(request_type: int, request: int, value: int, index: int, data, timeout: int = 15000, expect_disconnect: bool = False)[source]
class panda.python.usb.STBootloaderUSBHandle(libusb_device, libusb_handle)[source]

Bases: BaseSTBootloaderHandle

DFU_ABORT = 6
DFU_CLRSTATUS = 4
DFU_DNLOAD = 1
DFU_GETSTATUS = 3
DFU_UPLOAD = 2
clear_status()[source]
close()[source]
erase_sector(sector: int)[source]
get_mcu_type()[source]
jump(address)[source]
program(address, dat)[source]

panda.python.xcp module

class panda.python.xcp.COMMAND_CODE(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: IntEnum

ALLOC_DAQ = 213
ALLOC_ODT = 212
ALLOC_ODT_ENTRY = 211
BUILD_CHECKSUM = 243
CLEAR_DAQ_LIST = 227
CONNECT = 255
COPY_CAL_PAGE = 228
DISCONNECT = 254
DOWNLOAD = 240
DOWNLOAD_MAX = 238
DOWNLOAD_NEXT = 239
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_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
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_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
TRANSPORT_LAYER_CMD = 242
UNLOCK = 247
UPLOAD = 245
USER_CMD = 241
WRITE_DAQ = 225
class panda.python.xcp.CONNECT_MODE(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: IntEnum

NORMAL = 0
USER_DEFINED = 1
exception panda.python.xcp.CommandCounterError[source]

Bases: Exception

exception panda.python.xcp.CommandResponseError(message, return_code)[source]

Bases: Exception

exception panda.python.xcp.CommandTimeoutError[source]

Bases: Exception

class panda.python.xcp.GET_ID_REQUEST_TYPE(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: IntEnum

ASAM_MC2_FILE = 1
ASAM_MC2_PATH = 2
ASAM_MC2_UPLOAD = 4
ASAM_MC2_URL = 3
ASCII = 0
class panda.python.xcp.XcpClient(panda, tx_addr: int, rx_addr: int, bus: int = 0, timeout: float = 0.1, debug=False, pad=True)[source]

Bases: object

connect(connect_mode: CONNECT_MODE = CONNECT_MODE.NORMAL) dict[source]
disconnect() None[source]
download(data: bytes) bytes[source]
get_id(req_id_type: GET_ID_REQUEST_TYPE = GET_ID_REQUEST_TYPE.ASCII) dict[source]
get_seed(mode: int = 0) bytes[source]
set_mta(addr: int, addr_ext: int = 0) bytes[source]
short_upload(size: int, addr_ext: int, addr: int) bytes[source]
unlock(key: bytes) bytes[source]
upload(size: int) bytes[source]

Module contents

class panda.python.ALTERNATIVE_EXPERIENCE[source]

Bases: object

ALLOW_AEB = 16
DEFAULT = 0
DISABLE_DISENGAGE_ON_GAS = 1
DISABLE_STOCK_AEB = 2
RAISE_LONGITUDINAL_LIMITS_TO_ISO_MAX = 8
class panda.python.Panda(serial: str | None = None, claim: bool = True, disable_checks: bool = True, can_speed_kbps: int = 500)[source]

Bases: object

CAN_HEALTH_PACKET_VERSION = 5
CAN_HEALTH_STRUCT = <_struct.Struct object>
CAN_PACKET_VERSION = 4
CAN_SEND_TIMEOUT_MS = 10
F4_DEVICES = [b'\x01', b'\x02', b'\x03', b'\x05', b'\x06']
FLAG_CHRYSLER_RAM_DT = 1
FLAG_CHRYSLER_RAM_HD = 2
FLAG_FORD_CANFD = 2
FLAG_FORD_LONG_CONTROL = 1
FLAG_GM_HW_CAM = 1
FLAG_GM_HW_CAM_LONG = 2
FLAG_HONDA_ALT_BRAKE = 1
FLAG_HONDA_BOSCH_LONG = 2
FLAG_HONDA_GAS_INTERCEPTOR = 16
FLAG_HONDA_NIDEC_ALT = 4
FLAG_HONDA_RADARLESS = 8
FLAG_HYUNDAI_ALT_LIMITS = 64
FLAG_HYUNDAI_CAMERA_SCC = 8
FLAG_HYUNDAI_CANFD_ALT_BUTTONS = 32
FLAG_HYUNDAI_CANFD_HDA2 = 16
FLAG_HYUNDAI_CANFD_HDA2_ALT_STEERING = 128
FLAG_HYUNDAI_EV_GAS = 1
FLAG_HYUNDAI_HYBRID_GAS = 2
FLAG_HYUNDAI_LONG = 4
FLAG_NISSAN_ALT_EPS_BUS = 1
FLAG_SUBARU_GEN2 = 1
FLAG_SUBARU_LONG = 2
FLAG_SUBARU_PREGLOBAL_REVERSED_DRIVER_TORQUE = 1
FLAG_TESLA_LONG_CONTROL = 2
FLAG_TESLA_POWERTRAIN = 1
FLAG_TOYOTA_ALT_BRAKE = 256
FLAG_TOYOTA_GAS_INTERCEPTOR = 2048
FLAG_TOYOTA_LTA = 1024
FLAG_TOYOTA_STOCK_LONGITUDINAL = 512
FLAG_VOLKSWAGEN_LONG_CONTROL = 1
GMLAN_CAN2 = 1
GMLAN_CAN3 = 2
H7_DEVICES = [b'\x07', b'\x08', b'\t', b'\n']
HARNESS_STATUS_FLIPPED = 2
HARNESS_STATUS_NC = 0
HARNESS_STATUS_NORMAL = 1
HAS_OBD = (b'\x03', b'\x05', b'\x06', b'\x07', b'\x08', b'\t', b'\n')
HEALTH_PACKET_VERSION = 15
HEALTH_STRUCT = <_struct.Struct object>
HW_TYPE_BLACK_PANDA = b'\x03'
HW_TYPE_CUATRO = b'\n'
HW_TYPE_DOS = b'\x06'
HW_TYPE_GREY_PANDA = b'\x02'
HW_TYPE_PEDAL = b'\x04'
HW_TYPE_RED_PANDA = b'\x07'
HW_TYPE_RED_PANDA_V2 = b'\x08'
HW_TYPE_TRES = b'\t'
HW_TYPE_UNKNOWN = b'\x00'
HW_TYPE_UNO = b'\x05'
HW_TYPE_WHITE_PANDA = b'\x01'
INTERNAL_DEVICES = (b'\x05', b'\x06', b'\t', b'\n')
MAX_FAN_RPMs = {b'\x05': 5100, b'\x06': 6500, b'\t': 6600, b'\n': 6600}
REQUEST_IN = 192
REQUEST_OUT = 64
SAFETY_ALLOUTPUT = 17
SAFETY_BODY = 27
SAFETY_CHRYSLER = 9
SAFETY_ELM327 = 3
SAFETY_FAW = 26
SAFETY_FORD = 6
SAFETY_GM = 4
SAFETY_GM_ASCM = 18
SAFETY_HONDA_BOSCH = 20
SAFETY_HONDA_BOSCH_GIRAFFE = 5
SAFETY_HONDA_NIDEC = 1
SAFETY_HYUNDAI = 8
SAFETY_HYUNDAI_CANFD = 28
SAFETY_HYUNDAI_COMMUNITY = 24
SAFETY_HYUNDAI_LEGACY = 23
SAFETY_MAZDA = 13
SAFETY_NISSAN = 14
SAFETY_NOOUTPUT = 19
SAFETY_SILENT = 0
SAFETY_STELLANTIS = 25
SAFETY_SUBARU = 11
SAFETY_SUBARU_PREGLOBAL = 22
SAFETY_TESLA = 10
SAFETY_TOYOTA = 2
SAFETY_VOLKSWAGEN_MQB = 15
SAFETY_VOLKSWAGEN_PQ = 21
SERIAL_DEBUG = 0
SERIAL_ESP = 1
SERIAL_LIN1 = 2
SERIAL_LIN2 = 3
SERIAL_SOM_DEBUG = 4
USB_PIDS = (56814, 56780)
call_control_api(msg)[source]
can_clear(bus)[source]

Clears all messages from the specified internal CAN ringbuffer as though it were drained.

Args:
bus (int): can bus number to clear a tx queue, or 0xFFFF to clear the

global can rx queue.

can_health(can_number)[source]
can_recv()[source]
can_reset_communications()[source]
can_send(addr, dat, bus, timeout=10)[source]
can_send_many(arr, timeout=10)[source]
close()[source]
connect(claim=True, wait=False)[source]
property connected: bool
enable_deepsleep()[source]
flash(fn=None, code=None, reconnect=True)[source]
static flash_static(handle, code, mcu_type)[source]
static flasher_present(handle: BaseHandle) bool[source]
force_relay_drive(intercept_relay_drive, ignition_relay_drive)[source]
get_datetime()[source]
get_dfu_serial()[source]
get_fan_rpm()[source]
get_interrupt_call_rate(irqnum)[source]
get_mcu_type() McuType[source]
get_microsecond_timer()[source]
get_packets_versions()[source]
get_secret()[source]
get_serial()[source]

Returns the comma-issued dongle ID from our provisioning

get_signature() bytes[source]
static get_signature_from_firmware(fn) bytes[source]
get_type()[source]
get_uid()[source]

Returns the UID from the MCU

get_usb_serial()[source]

Returns the serial number reported from the USB descriptor; matches the MCU UID

get_version()[source]
has_obd()[source]
health()[source]
is_internal()[source]
isotp_recv(addr, bus=0, sendaddr=None, subaddr=None)[source]
isotp_send(addr, dat, bus, recvaddr=None, subaddr=None)[source]
classmethod list()[source]
read_som_gpio() bool[source]
reconnect()[source]
recover(timeout: int | None = 60, reset: bool = True) bool[source]
reset(enter_bootstub=False, enter_bootloader=False, reconnect=True)[source]
send_heartbeat(engaged=True)[source]
serial_clear(port_number)[source]

Clears all messages (tx and rx) from the specified internal uart ringbuffer as though it were drained.

Args:

port_number (int): port number of the uart to clear.

serial_read(port_number)[source]
serial_write(port_number, ln)[source]
set_can_data_speed_kbps(bus, speed)[source]
set_can_enable(bus_num, enable)[source]
set_can_loopback(enable)[source]
set_can_speed_kbps(bus, speed)[source]
set_canfd_non_iso(bus, non_iso)[source]
set_clock_source_period(period)[source]
set_datetime(dt)[source]
set_fan_power(percentage)[source]
set_gmlan(bus=2)[source]
set_green_led(enabled)[source]
set_heartbeat_disabled()[source]
set_ir_power(percentage)[source]
set_obd(obd)[source]
set_power_save(power_save_enabled=0)[source]
set_safety_mode(mode=0, param=0)[source]
set_siren(enabled)[source]
set_uart_baud(uart, rate)[source]
set_uart_callback(uart, install)[source]
set_uart_parity(uart, parity)[source]
classmethod spi_connect(serial, ignore_version=False)[source]
classmethod spi_list()[source]
up_to_date(fn=None) bool[source]
classmethod usb_connect(serial, claim=True)[source]
classmethod usb_list()[source]
static wait_for_dfu(dfu_serial: str | None, timeout: int | None = None) bool[source]
static wait_for_panda(serial: str | None, timeout: int) bool[source]
panda.python.calculate_checksum(data)[source]
panda.python.ensure_can_health_packet_version(fn)
panda.python.ensure_can_packet_version(fn)
panda.python.ensure_health_packet_version(fn)
panda.python.ensure_version(desc, lib_field, panda_field, fn)[source]
panda.python.pack_can_buffer(arr)[source]
panda.python.unpack_can_buffer(dat)[source]