Skip to main content

python implementation of X2Cscope

Project description

pyX2Cscope Logo

pyX2Cscope

  • pyX2Cscope is the Python implementation of the X2Cscope plugin from MPLABX.
  • This will let the user use the functionality of X2Cscope even outside mplabx enviroment / Standalone.
  • It allows user to:
    • Automated Unit Tests (TDD) using pytest
    • BDD(behaviour driven development), Framework: "Cucumber"
    • Different user interface
    • Data collection for machine learning and training models
    • Run-Time data analysis
    • Use of Real Time AI model
    • HiL(Hardware in the loop) testing and tuning

Getting Started with Scripting

  1. You can install the module using pip:
    pip install pyx2cscope
  2. Go to the Examples directory in the pyX2Cscope project to check out the available examples or create a new .py file according to your requirements.
  3. start with importing pyX2Cscope: import pyx2cscope
  4. Choose the communication interface from the interfaces' module. Currently, Only Serial is supported: CAN and LIN coming in near future:
from xc2scope import X2CScope
  1. Initiate the X2CScope and provide the desired COM port, by default baud rate is set to 115200. . If there's a need to change the baud rate, include the baud_rate parameter with your preferred baud rate, In the same way other setting could be made:
x2cScope = X2CScope(port="COM16", elf_file=elf_file)
  1. Replace the elf_file with the path to the ELF file of your project.
  2. Create a Variable object for the variable you want to monitor:
variable = x2cScope.get_variable('Variable_name')
  1. Replace 'Variable_name' with the name of the variable you want to monitor. You can create multiple variable objects as required.
  2. Once you have gone through these steps, you can use the get_value() function to retrieve the value of the variable:
variable.get_value() 
  1. To set the value for the respective variable set_value():
variable.set_value(value)

Scope Functionality

  1. To use the scope functionality, add channel to the scope: add_scope_channel(variable: Variable) :
x2cScope.add_scope_channel(variable1)
x2cScope.add_scope_channel(variable2)
  1. To remove channel: remove_scope_channel(variable: Variable):
x2cScope.remove_scope_channel(variable2)
  1. Up to 8 channels can be added.
  2. To Set up Trigger, any available variable can be selected, by default works on no trigger configuration.
x2cscope.set_scope_trigger(variable: Variable, trigger_level: int, trigger_mode: int, trigger_delay: int, trigger_edge: int)
  1. Trigger Parameters:
srcChannel: TriggerChannel (variable)
Level: trigger_level
Trigger_mode: 1 for triggered, 0 for Auto (No trigger)
Trigger_delay = Value > 0 Pre-trigger, Value < 0 Post trigger
Trigger_Edge: Rising (1) or Falling (0)

Example

x2cScope.set_scope_trigger(variable3, trigger_level=500, trigger_mode=1, trigger_delay=50, trigger_edge=1)
  1. clear_trigger(): Clears and diable trigger
x2cscope.clear_trigger()
  1. set_sample_time(sample_time: int): This paramater defines a pre-scaler when the scope is in the sampling mode. This can be used to extend total sampling time at cost of resolution. 0 = every sample, 1 = every 2nd sample, 2 = every 3rd sample .....

x2cScope.set_sample_time(2)
  1. is_scope_data_ready(self) -> bool: Returns Scope sampling state. Returns: true if sampling has completed, false if it’s yet in progress.

while not x2cScope.is_scope_data_ready():
    time.sleep(0.1)
  1. get_scope_channel_data(valid_data=False) -> Dict[str, List[Number]]: Once sampling is completed, this function could be used to get the sampled data.

data = x2cScope.get_scope_channel_data()
  1. This data now could be used according to the preference.

Getting Started with pyX2Cscope reference GUI

  1. pyX2Cscope-GUI is based on Serial interface.

  2. The Firmware of the microcontroller should have the X2Cscope library/Peripheral enabled.

  3. Select the COM Port, Baud Rate from the drop-down menus and the ELF file of the project, the microcontroller programmed with.

    COM-port

  4. Sample time can be changed during run time as well, by default its set to 500ms.

  5. Press on Connect

  6. Once the connection between pyX2Cscope and Microcontroller takes place, the buttons will be enabled.

Contribute

If you discover a bug or have an idea for an improvement, we encourage you to contribute! You can do so by following these steps:

  1. Fork the pyX2Cscope repository.
  2. Create a new branch for your changes.
  3. Make the necessary changes and commit them.
  4. Push your changes to your forked repository.
  5. Open a pull request on the main pyX2Cscope repository, describing your changes.

We appreciate your contribution!


Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyx2cscope-0.2.0.tar.gz (259.9 kB view details)

Uploaded Source

Built Distribution

pyx2cscope-0.2.0-py2.py3-none-any.whl (284.5 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file pyx2cscope-0.2.0.tar.gz.

File metadata

  • Download URL: pyx2cscope-0.2.0.tar.gz
  • Upload date:
  • Size: 259.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.10.14 Linux/6.5.0-1022-azure

File hashes

Hashes for pyx2cscope-0.2.0.tar.gz
Algorithm Hash digest
SHA256 63e6126e692f87b6da79c37c29dd87b5b2e02e95cb0636a3a9135f6caf5f7694
MD5 9ef154ccfd892693505e464347632cfc
BLAKE2b-256 1d07ba22c05a71cc666182ccc21ca267b6a71809cdfe58765f21eebc500a6b4f

See more details on using hashes here.

Provenance

File details

Details for the file pyx2cscope-0.2.0-py2.py3-none-any.whl.

File metadata

  • Download URL: pyx2cscope-0.2.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 284.5 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.10.14 Linux/6.5.0-1022-azure

File hashes

Hashes for pyx2cscope-0.2.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 82c242da4078a63120f798d8cd850f2241b972fa490f65d94d772c642e3b7ed0
MD5 4597faba7a7b7f4f35c7791b5d7b4d7e
BLAKE2b-256 2bc1cad417220f250d40865218a168055471b8c41d255f4a33089eca7a3bedb3

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page