Metadata-Version: 2.4
Name: lenz-flashtool
Version: 0.1.8
Summary: FlashTool library for BiSS C Firmware Update and Calibration by LENZ Encoders
Project-URL: Homepage, https://github.com/lenzencoders/lenz-flashtool-lib
Project-URL: Source, https://github.com/lenzencoders/lenz-flashtool-lib
Project-URL: Documentation, https://flashtool.lenzencoders.com
Author-email: LENZ ENCODERS <devs@lenzencoders.com>
License: MIT License
        
        Copyright (c) 2020-2025 Design Bureau fo Robotic Systems, llc.
        LENZ ENCODERS is Trademark of Design Bureau fo Robotic Systems, llc.
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
Keywords: angle,automation,biss,biss encoder,biss-c,calibration,embedded systems,encoder,firmware,flashtool,hardware,lenz,motion control,serial communication,servomotor
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Manufacturing
Classifier: License :: OSI Approved :: MIT License
Classifier: Natural Language :: English
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Communications
Classifier: Topic :: Scientific/Engineering :: Electronic Design Automation (EDA)
Classifier: Topic :: Scientific/Engineering :: Interface Engine/Protocol Translator
Classifier: Topic :: Software Development :: Embedded Systems
Classifier: Topic :: Software Development :: Libraries
Classifier: Topic :: System :: Hardware
Classifier: Topic :: Utilities
Requires-Python: >=3.8
Requires-Dist: colorama>=0.4.6
Requires-Dist: numpy>=1.21.0
Requires-Dist: pyserial>=3.5
Description-Content-Type: text/markdown

# lenz-flashtool
[![PyPI Version](https://img.shields.io/pypi/v/lenz-flashtool)](https://pypi.org/project/lenz-flashtool/)

FlashTool library for BiSS C Firmware Update and Calibration by LENZ Encoders.

This is the source repository for the `lenz-flashtool` Python package, designed to interface with LENZ BiSS C encoders for firmware updates, calibration, and data reading. It provides a `FlashTool` class and utility functions for working with encoder hardware, including hex file manipulation and color formatting utilities.

[**📚 Full Documentation: flashtool.lenzencoders.com**](https://flashtool.lenzencoders.com)

## Features

- Control LENZ BiSS C encoders via serial communication.
- Upload firmware and calibration data.
- Read encoder status, serial numbers, and error flags.
- Utilities for CRC calculation, hex data generation, and colored logging output.

## Installation

### From PyPI (Recommended)
```bash
pip install lenz-flashtool
```

### From local folder
```bash
pip install .
```

### From GitHub
```bash
pip install git+https://github.com/lenzencoders/lenz-flashtool-lib.git
```

## Requirements

- Python 3.8 or higher
- `pyserial>=3.5` (for serial communication)
- `numpy>=1.21.0` (for data handling)
- `colorama>=0.4.6` (for cli colors)

## Usage

### Basic Example
```python
from lenz_flashtool import FlashTool, init_logging

# Set up logging
#
# Level	            Integer Value
# logging.CRITICAL  50
# logging.ERROR     40
# logging.WARNING   30
# logging.INFO      20
# logging.DEBUG     10
# logging.NOTSET    0
init_logging(logfilename="flashtool.log", stdout_level=20, file_level=10)

# Initialize FlashTool
with FlashTool(port_description_prefixes=('XR21V')) as ft:
    # Power cycle the encoder
    ft.encoder_power_cycle()

    # Read serial number
    bootloader_ver, serial_num, mfg_date, program_ver = ft.biss_read_snum()
    print(f"Encoder Serial Number: {serial_num}")
# The connection is automatically closed when exiting the 'with' block
```
### Note on Naming
The package is installed as `lenz-flashtool` (with a hyphen), but imported in Python as `lenz_flashtool` (with an underscore) due to Python’s naming conventions.

## Documentation

For detailed API documentation, examples, and usage instructions, visit the [LENZ FlashTool Documentation](https://flashtool.lenzencoders.com).

## Development

### Install Locally
```bash
git clone https://github.com/lenzencoders/lenz-flashtool-lib.git
cd lenz-flashtool-lib
pip install .
```

### Run Tests
```bash
pip install pytest
pytest tests/
```

## Contributing

Contributions are welcome! Please:
1. Fork the repository.
2. Create a feature branch (`git checkout -b feature/my-feature`).
3. Commit your changes (`git commit -m "Add my feature"`).
4. Push to the branch (`git push origin feature/my-feature`).
5. Open a pull request.

Report issues at [github.com/lenzencoders/lenz-flashtool-lib/issues](https://github.com/lenzencoders/lenz-flashtool-lib/issues).

## License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

## Contact

For support or inquiries, contact LENZ ENCODERS at [info@lenzencoders.com](mailto:devs@lenzencoders.com).
