lenz-flashtool 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (26) hide show
  1. lenz_flashtool-0.1.0/.gitignore +12 -0
  2. lenz_flashtool-0.1.0/LICENSE +22 -0
  3. lenz_flashtool-0.1.0/PKG-INFO +148 -0
  4. lenz_flashtool-0.1.0/README.md +108 -0
  5. lenz_flashtool-0.1.0/lenz_flashtool/__init__.py +68 -0
  6. lenz_flashtool-0.1.0/lenz_flashtool/biss/__init__.py +42 -0
  7. lenz_flashtool-0.1.0/lenz_flashtool/biss/cli.py +391 -0
  8. lenz_flashtool-0.1.0/lenz_flashtool/biss/commands.py +157 -0
  9. lenz_flashtool-0.1.0/lenz_flashtool/biss/crc.py +54 -0
  10. lenz_flashtool-0.1.0/lenz_flashtool/biss/registers.py +185 -0
  11. lenz_flashtool-0.1.0/lenz_flashtool/encproc/__init__.py +48 -0
  12. lenz_flashtool-0.1.0/lenz_flashtool/encproc/processing.py +464 -0
  13. lenz_flashtool-0.1.0/lenz_flashtool/flashtool/__init__.py +37 -0
  14. lenz_flashtool-0.1.0/lenz_flashtool/flashtool/core.py +1680 -0
  15. lenz_flashtool-0.1.0/lenz_flashtool/flashtool/errors.py +7 -0
  16. lenz_flashtool-0.1.0/lenz_flashtool/flashtool/hex_utils.py +842 -0
  17. lenz_flashtool-0.1.0/lenz_flashtool/flashtool/logging.py +161 -0
  18. lenz_flashtool-0.1.0/lenz_flashtool/flashtool/operations.py +140 -0
  19. lenz_flashtool-0.1.0/lenz_flashtool/flashtool/uart.py +254 -0
  20. lenz_flashtool-0.1.0/lenz_flashtool/testing/__init__.py +6 -0
  21. lenz_flashtool-0.1.0/lenz_flashtool/testing/mock_flashtool.py +426 -0
  22. lenz_flashtool-0.1.0/lenz_flashtool/utils/__init__.py +28 -0
  23. lenz_flashtool-0.1.0/lenz_flashtool/utils/plot.py +115 -0
  24. lenz_flashtool-0.1.0/lenz_flashtool/utils/progress.py +125 -0
  25. lenz_flashtool-0.1.0/lenz_flashtool/utils/termcolors.py +76 -0
  26. lenz_flashtool-0.1.0/pyproject.toml +49 -0
@@ -0,0 +1,12 @@
1
+ __pycache__/
2
+ *.pyc
3
+ *.pyo
4
+ *.pyd
5
+ .venv/
6
+ venv/
7
+ env/
8
+ *.egg-info/
9
+ dist/
10
+ build/
11
+ _bak/
12
+ *.log
@@ -0,0 +1,22 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2020-2025 Design Bureau fo Robotic Systems, llc.
4
+ LENZ ENCODERS is Trademark of Design Bureau fo Robotic Systems, llc.
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in all
14
+ copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ SOFTWARE.
@@ -0,0 +1,148 @@
1
+ Metadata-Version: 2.4
2
+ Name: lenz-flashtool
3
+ Version: 0.1.0
4
+ Summary: FlashTool library for BiSS C Firmware Update and Calibration by LENZ Encoders
5
+ Project-URL: Homepage, https://github.com/lenzencoders/lenz-flashtool-lib
6
+ Project-URL: Source, https://github.com/lenzencoders/lenz-flashtool-lib
7
+ Project-URL: Documentation, https://flashtool.lenzencoders.com
8
+ Author-email: LENZ ENCODERS <devs@lenzencoders.com>
9
+ License: MIT License
10
+
11
+ Copyright (c) 2020-2025 Design Bureau fo Robotic Systems, llc.
12
+ LENZ ENCODERS is Trademark of Design Bureau fo Robotic Systems, llc.
13
+
14
+ Permission is hereby granted, free of charge, to any person obtaining a copy
15
+ of this software and associated documentation files (the "Software"), to deal
16
+ in the Software without restriction, including without limitation the rights
17
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
18
+ copies of the Software, and to permit persons to whom the Software is
19
+ furnished to do so, subject to the following conditions:
20
+
21
+ The above copyright notice and this permission notice shall be included in all
22
+ copies or substantial portions of the Software.
23
+
24
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
25
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
27
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
29
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30
+ SOFTWARE.
31
+ License-File: LICENSE
32
+ Keywords: angle,biss,encoder,flashtool,lenz
33
+ Classifier: License :: OSI Approved :: MIT License
34
+ Classifier: Operating System :: OS Independent
35
+ Classifier: Programming Language :: Python :: 3
36
+ Requires-Python: >=3.8
37
+ Requires-Dist: numpy>=1.21.0
38
+ Requires-Dist: pyserial>=3.5
39
+ Description-Content-Type: text/markdown
40
+
41
+
42
+ # lenz-flashtool
43
+
44
+ FlashTool library for BiSS C Firmware Update and Calibration by LENZ Encoders.
45
+
46
+ 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.
47
+
48
+ ## Features
49
+
50
+ - Control LENZ BiSS C encoders via serial communication.
51
+ - Upload firmware and calibration data.
52
+ - Read encoder status, serial numbers, and error flags.
53
+ - Utilities for CRC calculation, hex data generation, and colored logging output.
54
+
55
+ ## Installation
56
+
57
+ ### From local folder
58
+ ```bash
59
+ pip install .
60
+ ```
61
+
62
+ ### From PyPI
63
+ ```bash
64
+ pip install lenz-flashtool
65
+ ```
66
+
67
+ ### From GitHub
68
+ ```bash
69
+ pip install git+https://github.com/lenzencoders/lenz-flashtool-lib.git
70
+ ```
71
+
72
+ ## Requirements
73
+
74
+ - Python 3.8 or higher
75
+ - `pyserial>=3.5` (for serial communication)
76
+ - `numpy>=1.21.0` (for data handling)
77
+
78
+ ## Usage
79
+
80
+ ### Basic Example
81
+ ```python
82
+ from lenz_flashtool import FlashTool, init_logging
83
+
84
+ # Set up logging
85
+ #
86
+ # Level Integer Value
87
+ # logging.CRITICAL 50
88
+ # logging.ERROR 40
89
+ # logging.WARNING 30
90
+ # logging.INFO 20
91
+ # logging.DEBUG 10
92
+ # logging.NOTSET 0
93
+ init_logging(logfilename="flashtool.log", stdout_level=20, file_level=10)
94
+
95
+ # Initialize FlashTool
96
+ with FlashTool(port_description_prefixes=('XR21V')) as lenz:
97
+ # Power cycle the encoder
98
+ lenz.encoder_power_cycle()
99
+
100
+ # Read serial number
101
+ bootloader_ver, serial_num, mfg_date, program_ver = lenz.biss_read_snum()
102
+ print(f"Encoder Serial Number: {serial_num}")
103
+ # The connection is automatically closed when exiting the 'with' block
104
+ ```
105
+ ### Note on Naming
106
+ 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.
107
+
108
+ ## Documentation
109
+
110
+ For detailed API documentation, examples, and usage instructions, visit the [LENZ FlashTool Documentation](https://flashtool.lenzencoders.com).
111
+
112
+ ## Development
113
+
114
+ ### Install Locally
115
+ ```bash
116
+ git clone https://github.com/lenzencoders/lenz-flashtool-lib.git
117
+ cd lenz-flashtool-lib
118
+ pip install .
119
+ ```
120
+
121
+ ### Run Tests
122
+ ```bash
123
+ pip install pytest
124
+ pytest tests/
125
+ ```
126
+
127
+ ## Contributing
128
+
129
+ Contributions are welcome! Please:
130
+ 1. Fork the repository.
131
+ 2. Create a feature branch (`git checkout -b feature/my-feature`).
132
+ 3. Commit your changes (`git commit -m "Add my feature"`).
133
+ 4. Push to the branch (`git push origin feature/my-feature`).
134
+ 5. Open a pull request.
135
+
136
+ Report issues at [github.com/lenzencoders/lenz-flashtool-lib/issues](https://github.com/lenzencoders/lenz-flashtool-lib/issues).
137
+
138
+ ## License
139
+
140
+ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
141
+
142
+ ## Contact
143
+
144
+ For support or inquiries, contact LENZ ENCODERS at [info@lenzencoders.com](mailto:devs@lenzencoders.com).
145
+ ```
146
+
147
+
148
+
@@ -0,0 +1,108 @@
1
+
2
+ # lenz-flashtool
3
+
4
+ FlashTool library for BiSS C Firmware Update and Calibration by LENZ Encoders.
5
+
6
+ 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.
7
+
8
+ ## Features
9
+
10
+ - Control LENZ BiSS C encoders via serial communication.
11
+ - Upload firmware and calibration data.
12
+ - Read encoder status, serial numbers, and error flags.
13
+ - Utilities for CRC calculation, hex data generation, and colored logging output.
14
+
15
+ ## Installation
16
+
17
+ ### From local folder
18
+ ```bash
19
+ pip install .
20
+ ```
21
+
22
+ ### From PyPI
23
+ ```bash
24
+ pip install lenz-flashtool
25
+ ```
26
+
27
+ ### From GitHub
28
+ ```bash
29
+ pip install git+https://github.com/lenzencoders/lenz-flashtool-lib.git
30
+ ```
31
+
32
+ ## Requirements
33
+
34
+ - Python 3.8 or higher
35
+ - `pyserial>=3.5` (for serial communication)
36
+ - `numpy>=1.21.0` (for data handling)
37
+
38
+ ## Usage
39
+
40
+ ### Basic Example
41
+ ```python
42
+ from lenz_flashtool import FlashTool, init_logging
43
+
44
+ # Set up logging
45
+ #
46
+ # Level Integer Value
47
+ # logging.CRITICAL 50
48
+ # logging.ERROR 40
49
+ # logging.WARNING 30
50
+ # logging.INFO 20
51
+ # logging.DEBUG 10
52
+ # logging.NOTSET 0
53
+ init_logging(logfilename="flashtool.log", stdout_level=20, file_level=10)
54
+
55
+ # Initialize FlashTool
56
+ with FlashTool(port_description_prefixes=('XR21V')) as lenz:
57
+ # Power cycle the encoder
58
+ lenz.encoder_power_cycle()
59
+
60
+ # Read serial number
61
+ bootloader_ver, serial_num, mfg_date, program_ver = lenz.biss_read_snum()
62
+ print(f"Encoder Serial Number: {serial_num}")
63
+ # The connection is automatically closed when exiting the 'with' block
64
+ ```
65
+ ### Note on Naming
66
+ 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.
67
+
68
+ ## Documentation
69
+
70
+ For detailed API documentation, examples, and usage instructions, visit the [LENZ FlashTool Documentation](https://flashtool.lenzencoders.com).
71
+
72
+ ## Development
73
+
74
+ ### Install Locally
75
+ ```bash
76
+ git clone https://github.com/lenzencoders/lenz-flashtool-lib.git
77
+ cd lenz-flashtool-lib
78
+ pip install .
79
+ ```
80
+
81
+ ### Run Tests
82
+ ```bash
83
+ pip install pytest
84
+ pytest tests/
85
+ ```
86
+
87
+ ## Contributing
88
+
89
+ Contributions are welcome! Please:
90
+ 1. Fork the repository.
91
+ 2. Create a feature branch (`git checkout -b feature/my-feature`).
92
+ 3. Commit your changes (`git commit -m "Add my feature"`).
93
+ 4. Push to the branch (`git push origin feature/my-feature`).
94
+ 5. Open a pull request.
95
+
96
+ Report issues at [github.com/lenzencoders/lenz-flashtool-lib/issues](https://github.com/lenzencoders/lenz-flashtool-lib/issues).
97
+
98
+ ## License
99
+
100
+ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
101
+
102
+ ## Contact
103
+
104
+ For support or inquiries, contact LENZ ENCODERS at [info@lenzencoders.com](mailto:devs@lenzencoders.com).
105
+ ```
106
+
107
+
108
+
@@ -0,0 +1,68 @@
1
+ """
2
+
3
+ FlashTool library for BiSS C Firmware Update and Calibration.
4
+
5
+ This library provides functions for interfacing with BiSS C encoders using LENZ FlashTool, performing firmware updates,
6
+ and executing calibration routines.
7
+
8
+ Author:
9
+ LENZ ENCODERS, 2020-2025
10
+ """
11
+
12
+ #
13
+ # r'''
14
+ # _ _____ _ _ _____ _____ _ _ ____ ___ ____ _____ ____ ____
15
+ # | | | ____| \ | |__ / | ____| \ | |/ ___/ _ \| _ \| ____| _ \/ ___|
16
+ # | | | _| | \| | / / | _| | \| | | | | | | | | | _| | |_) \___ \
17
+ # | |___| |___| |\ |/ /_ | |___| |\ | |__| |_| | |_| | |___| _ < ___) |
18
+ # |_____|_____|_| \_/____| |_____|_| \_|\____\___/|____/|_____|_| \_|____/
19
+ # '''
20
+
21
+ from .utils import plot, plot2, TermColors
22
+ from .biss import (
23
+ ERROR_FLAGS, BISS_COMMANDSTATE, biss_commands, BiSSBank
24
+ )
25
+ from .flashtool import (
26
+ UartCmd,
27
+ FlashTool,
28
+ FlashToolError,
29
+ generate_hex_line,
30
+ init_logging,
31
+ get_nonce,
32
+ _readhex,
33
+ biss_send_hex,
34
+ biss_send_dif
35
+ )
36
+ from .testing import MockFlashTool
37
+ from .encproc import LenzEncoderProcessor
38
+
39
+ __all__ = [
40
+ # Constants
41
+ 'ERROR_FLAGS',
42
+ 'BISS_COMMANDSTATE',
43
+ 'biss_commands',
44
+ 'BiSSBank',
45
+
46
+ # Command constants
47
+ 'UartCmd',
48
+
49
+ # Core classes
50
+ 'FlashTool',
51
+ 'FlashToolError',
52
+ 'MockFlashTool',
53
+ 'LenzEncoderProcessor',
54
+
55
+ # Utility functions and classes
56
+ 'generate_hex_line',
57
+ 'init_logging',
58
+ 'get_nonce',
59
+ '_readhex',
60
+ 'biss_send_dif',
61
+ 'biss_send_hex',
62
+ 'plot',
63
+ 'plot2',
64
+ 'TermColors'
65
+ ]
66
+
67
+ __version__ = "0.1.0"
68
+ __author__ = "LENZ ENCODERS"
@@ -0,0 +1,42 @@
1
+ """
2
+
3
+ LENZ BiSS Protocol Implementation
4
+
5
+ Provides BiSS encoder protocol standarts and utilities.
6
+
7
+ Author:
8
+ LENZ ENCODERS, 2020-2025
9
+ """
10
+
11
+ #
12
+ # r'''
13
+ # _ _____ _ _ _____ _____ _ _ ____ ___ ____ _____ ____ ____
14
+ # | | | ____| \ | |__ / | ____| \ | |/ ___/ _ \| _ \| ____| _ \/ ___|
15
+ # | | | _| | \| | / / | _| | \| | | | | | | | | | _| | |_) \___ \
16
+ # | |___| |___| |\ |/ /_ | |___| |\ | |__| |_| | |_| | |___| _ < ___) |
17
+ # |_____|_____|_| \_/____| |_____|_| \_|\____\___/|____/|_____|_| \_|____/
18
+ #
19
+
20
+ from .commands import (
21
+ BISS_COMMANDSTATE,
22
+ ERROR_FLAGS,
23
+ biss_commands,
24
+ interpret_biss_commandstate,
25
+ interpret_error_flags
26
+ )
27
+ from .crc import biss_crc6_calc
28
+ from .registers import (
29
+ BiSSBank,
30
+ )
31
+
32
+ __all__ = [
33
+ 'BISS_COMMANDSTATE',
34
+ 'ERROR_FLAGS',
35
+ 'biss_commands',
36
+ 'interpret_biss_commandstate',
37
+ 'interpret_error_flags',
38
+
39
+ 'biss_crc6_calc',
40
+
41
+ 'BiSSBank'
42
+ ]