The pyx2cscope Python package communicates with X2Cscope enabled firmwares running on Microchip microcontrollers. This comprehensive package offers developers a powerful toolkit for embedded software development, combining real-time debugging capabilities with advanced data visualization features directly within the Python environment. pyx2cscope is using lnet protocol to communicate with the embedded hardware via different communication interfaces like UART, CAN, LIN, USB, TCP/IP, etc.
Installation#
Create a virtual environment and install pyx2cscope using the following commands:
Start GUI example#
python -m pyx2cscope
Simplest scripting example#
1"""This script demonstrates the simplest usage of the pyX2Cscope library to interact with variables in an ELF file via a serial connection.
2
3The script initializes the X2CScope with a specified serial port and ELF file, retrieves specific variables,
4reads their values, and writes new values to them.
5"""
6from pyx2cscope.xc2scope import X2CScope
7
8# initialize the x2cscope with serial port, by default baud rate is 115200,
9x2c_scope = X2CScope(port="COM8", elf_file="Path_To_Elf_File")
10
11# Retrieve specific variables.
12speed_reference = x2c_scope.get_variable("motor.apiData.velocityReference")
13speed_measured = x2c_scope.get_variable("motor.apiData.velocityMeasured")
14
15# Read the value of the "motor.apiData.velocityMeasured" variable from the target
16print(speed_measured.get_value())
17# Write a new value to the "motor.apiData.velocityReference" variable on the target
18speed_reference.set_value(1000)
Contents: