init upload + readme + error handling

This commit is contained in:
2022-12-21 08:51:09 +01:00
commit 37cdda8f33
16 changed files with 2909 additions and 0 deletions

47
python/README.rst Normal file
View File

@@ -0,0 +1,47 @@
Python wrapper for LibOpenBLT
=============================
The OpenBLT Host Library (`LibOpenBLT <https://www.feaser.com/openblt/doku.php?id=manual:libopenblt>`_) contains an application programming interface (API) for communicating with a microcontroller target, running the OpenBLT bootloader, for making firmware updates on the target. The goal of the OpenBLT Host Library is to empower you to quickly and efficiently create your own firmware update tool, in case you dont prefer the standard MicroBoot and BootCommander tools that are included in the OpenBLT bootloader package.
This package contains the python wrapper for LibOpenBLT, which enables you to quickly develop your own firmware update tool in the Python programming language.
Install the package
-------------------
Run the following command from the directory that contains the **setup.py** file (assuming setuptools is installed):
::
python setup.py install
Alternatively, you can use **pip** by running this command from the directory that contains the **setup.py** file:
::
pip install .
Using the package
-----------------
Basic code snippet to call the BltVersionGetString()-function which displays the version of LibOpenBLT:
::
import openblt
print('LibOpenBLT version:', openblt.version_get_string())
Have a look at the function headers inside openblt.lib for details on how to call the functions, including examples. A video tutorial about getting started with the Python bindings is available in this `blog article <https://www.feaser.com/en/blog/?p=208>`_.
Run-time libraries
------------------
Copy the LibOpenBLT related run-time libraries into your python program's directory. Refer to the following section on the OpenBLT Wiki for a overview of these run-time libraries:
https://www.feaser.com/openblt/doku.php?id=manual:libopenblt#run-time_libraries.
These run-time libraries can be found in the ./Host directory of the OpenBLT bootloader package. These run-time libraries should also be included, when distributing your program.
Specific on Windows
------------------
Under Microsoft Windows, the LibOpenBLT shared library (libopenblt.dll) is 64-bit ever since OpenBLT version 1.14. Therefore you need to run your Python application, that makes use of LibOpenBLT, using the 64-bit Python interpreter.
If you use the LibOpenBLT shared library from before OpenBLT version 1.14 or if you rebuilt it yourself as 32-bit, you need to run your Python application using the 32-bit Python interpreter.

View File

@@ -0,0 +1,94 @@
"""
Package **openblt** is a python wrapper for the OpenBLT Host Library (`LibOpenBLT <https://www.feaser.com/openblt/doku.php?id=manual:libopenblt>`_).
Have a look at the function headers inside openblt.lib for details on how to call the functions, including examples.
"""
__docformat__ = 'reStructuredText'
# ***************************************************************************************
# File Name: __init__.py
#
# ---------------------------------------------------------------------------------------
# C O P Y R I G H T
# ---------------------------------------------------------------------------------------
# Copyright (c) 2018 by Feaser http://www.feaser.com All rights reserved
#
# ---------------------------------------------------------------------------------------
# L I C E N S E
# ---------------------------------------------------------------------------------------
# This file is part of OpenBLT. OpenBLT is free software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published by the Free
# Software Foundation, either version 3 of the License, or (at your option) any later
# version.
#
# OpenBLT is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
# without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
# PURPOSE. See the GNU General Public License for more details.
#
# You have received a copy of the GNU General Public License along with OpenBLT. It
# should be located in ".\Doc\license.html". If not, contact Feaser to obtain a copy.
#
# ***************************************************************************************
# ***************************************************************************************
# Imports
# ***************************************************************************************
from openblt.lib import BLT_RESULT_OK
from openblt.lib import BLT_RESULT_ERROR_GENERIC
# ***************************************************************************************
# V E R S I O N I N F O R M A T I O N
# ***************************************************************************************
from openblt.lib import version_get_number
from openblt.lib import version_get_string
# ***************************************************************************************
# S E S S I O N / T R A N S P O R T L A Y E R S
# ***************************************************************************************
from openblt.lib import BLT_SESSION_XCP_V10
from openblt.lib import BLT_TRANSPORT_XCP_V10_RS232
from openblt.lib import BLT_TRANSPORT_XCP_V10_CAN
from openblt.lib import BLT_TRANSPORT_XCP_V10_USB
from openblt.lib import BLT_TRANSPORT_XCP_V10_NET
from openblt.lib import BltSessionSettingsXcpV10
from openblt.lib import BltTransportSettingsXcpV10Rs232
from openblt.lib import BltTransportSettingsXcpV10Can
from openblt.lib import BltTransportSettingsXcpV10Net
from openblt.lib import session_init
from openblt.lib import session_terminate
from openblt.lib import session_start
from openblt.lib import session_stop
from openblt.lib import session_clear_memory
from openblt.lib import session_write_data
from openblt.lib import session_read_data
# ***************************************************************************************
# F I R M W A R E D A T A
# ***************************************************************************************
from openblt.lib import BLT_FIRMWARE_PARSER_SRECORD
from openblt.lib import firmware_terminate
from openblt.lib import firmware_init
from openblt.lib import firmware_load_from_file
from openblt.lib import firmware_save_to_file
from openblt.lib import firmware_get_segment_count
from openblt.lib import firmware_get_segment
from openblt.lib import firmware_add_data
from openblt.lib import firmware_remove_data
from openblt.lib import firmware_clear_data
# ***************************************************************************************
# G E N E R I C U T I L I T I E S
# ***************************************************************************************
from openblt.lib import util_crc16_calculate
from openblt.lib import util_crc32_calculate
from openblt.lib import util_time_get_system_time
from openblt.lib import util_time_delay_ms
from openblt.lib import util_crypto_aes256_encrypt
from openblt.lib import util_crypto_aes256_decrypt
# ********************************* end of __init__.py **********************************

File diff suppressed because it is too large Load Diff

BIN
python/dist/openblt-1.3.7-py3.9.egg vendored Normal file

Binary file not shown.

View File

@@ -0,0 +1,57 @@
Metadata-Version: 1.0
Name: openblt
Version: 1.3.7
Summary: Python wrapper for the OpenBLT host library (LibOpenBLT).
Home-page: https://www.feaser.com/openblt/doku.php?id=manual:libopenblt
Author: Frank Voorburg
Author-email: voorburg@feaser.com
License: UNKNOWN
Description: Python wrapper for LibOpenBLT
=============================
The OpenBLT Host Library (`LibOpenBLT <https://www.feaser.com/openblt/doku.php?id=manual:libopenblt>`_) contains an application programming interface (API) for communicating with a microcontroller target, running the OpenBLT bootloader, for making firmware updates on the target. The goal of the OpenBLT Host Library is to empower you to quickly and efficiently create your own firmware update tool, in case you don’t prefer the standard MicroBoot and BootCommander tools that are included in the OpenBLT bootloader package.
This package contains the python wrapper for LibOpenBLT, which enables you to quickly develop your own firmware update tool in the Python programming language.
Install the package
-------------------
Run the following command from the directory that contains the **setup.py** file (assuming setuptools is installed):
::
python setup.py install
Alternatively, you can use **pip** by running this command from the directory that contains the **setup.py** file:
::
pip install .
Using the package
-----------------
Basic code snippet to call the BltVersionGetString()-function which displays the version of LibOpenBLT:
::
import openblt
print('LibOpenBLT version:', openblt.version_get_string())
Have a look at the function headers inside openblt.lib for details on how to call the functions, including examples. A video tutorial about getting started with the Python bindings is available in this `blog article <https://www.feaser.com/en/blog/?p=208>`_.
Run-time libraries
------------------
Copy the LibOpenBLT related run-time libraries into your python program's directory. Refer to the following section on the OpenBLT Wiki for a overview of these run-time libraries:
https://www.feaser.com/openblt/doku.php?id=manual:libopenblt#run-time_libraries.
These run-time libraries can be found in the ./Host directory of the OpenBLT bootloader package. These run-time libraries should also be included, when distributing your program.
Specific on Windows
------------------
Under Microsoft Windows, the LibOpenBLT shared library (libopenblt.dll) is 64-bit ever since OpenBLT version 1.14. Therefore you need to run your Python application, that makes use of LibOpenBLT, using the 64-bit Python interpreter.
If you use the LibOpenBLT shared library from before OpenBLT version 1.14 or if you rebuilt it yourself as 32-bit, you need to run your Python application using the 32-bit Python interpreter.
Platform: UNKNOWN

View File

@@ -0,0 +1,8 @@
README.rst
setup.py
openblt/__init__.py
openblt/lib.py
openblt.egg-info/PKG-INFO
openblt.egg-info/SOURCES.txt
openblt.egg-info/dependency_links.txt
openblt.egg-info/top_level.txt

View File

@@ -0,0 +1 @@

View File

@@ -0,0 +1 @@
openblt

View File

@@ -0,0 +1,94 @@
"""
Package **openblt** is a python wrapper for the OpenBLT Host Library (`LibOpenBLT <https://www.feaser.com/openblt/doku.php?id=manual:libopenblt>`_).
Have a look at the function headers inside openblt.lib for details on how to call the functions, including examples.
"""
__docformat__ = 'reStructuredText'
# ***************************************************************************************
# File Name: __init__.py
#
# ---------------------------------------------------------------------------------------
# C O P Y R I G H T
# ---------------------------------------------------------------------------------------
# Copyright (c) 2018 by Feaser http://www.feaser.com All rights reserved
#
# ---------------------------------------------------------------------------------------
# L I C E N S E
# ---------------------------------------------------------------------------------------
# This file is part of OpenBLT. OpenBLT is free software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published by the Free
# Software Foundation, either version 3 of the License, or (at your option) any later
# version.
#
# OpenBLT is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
# without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
# PURPOSE. See the GNU General Public License for more details.
#
# You have received a copy of the GNU General Public License along with OpenBLT. It
# should be located in ".\Doc\license.html". If not, contact Feaser to obtain a copy.
#
# ***************************************************************************************
# ***************************************************************************************
# Imports
# ***************************************************************************************
from openblt.lib import BLT_RESULT_OK
from openblt.lib import BLT_RESULT_ERROR_GENERIC
# ***************************************************************************************
# V E R S I O N I N F O R M A T I O N
# ***************************************************************************************
from openblt.lib import version_get_number
from openblt.lib import version_get_string
# ***************************************************************************************
# S E S S I O N / T R A N S P O R T L A Y E R S
# ***************************************************************************************
from openblt.lib import BLT_SESSION_XCP_V10
from openblt.lib import BLT_TRANSPORT_XCP_V10_RS232
from openblt.lib import BLT_TRANSPORT_XCP_V10_CAN
from openblt.lib import BLT_TRANSPORT_XCP_V10_USB
from openblt.lib import BLT_TRANSPORT_XCP_V10_NET
from openblt.lib import BltSessionSettingsXcpV10
from openblt.lib import BltTransportSettingsXcpV10Rs232
from openblt.lib import BltTransportSettingsXcpV10Can
from openblt.lib import BltTransportSettingsXcpV10Net
from openblt.lib import session_init
from openblt.lib import session_terminate
from openblt.lib import session_start
from openblt.lib import session_stop
from openblt.lib import session_clear_memory
from openblt.lib import session_write_data
from openblt.lib import session_read_data
# ***************************************************************************************
# F I R M W A R E D A T A
# ***************************************************************************************
from openblt.lib import BLT_FIRMWARE_PARSER_SRECORD
from openblt.lib import firmware_terminate
from openblt.lib import firmware_init
from openblt.lib import firmware_load_from_file
from openblt.lib import firmware_save_to_file
from openblt.lib import firmware_get_segment_count
from openblt.lib import firmware_get_segment
from openblt.lib import firmware_add_data
from openblt.lib import firmware_remove_data
from openblt.lib import firmware_clear_data
# ***************************************************************************************
# G E N E R I C U T I L I T I E S
# ***************************************************************************************
from openblt.lib import util_crc16_calculate
from openblt.lib import util_crc32_calculate
from openblt.lib import util_time_get_system_time
from openblt.lib import util_time_delay_ms
from openblt.lib import util_crypto_aes256_encrypt
from openblt.lib import util_crypto_aes256_decrypt
# ********************************* end of __init__.py **********************************

1215
python/openblt/lib.py Normal file

File diff suppressed because it is too large Load Diff

53
python/setup.py Normal file
View File

@@ -0,0 +1,53 @@
#!/usr/bin/env python
"""
Setuptools setup specification for package 'openblt'.
"""
__docformat__ = 'reStructuredText'
# ***************************************************************************************
# File Name: setup.py
#
# ---------------------------------------------------------------------------------------
# C O P Y R I G H T
# ---------------------------------------------------------------------------------------
# Copyright (c) 2018 by Feaser http://www.feaser.com All rights reserved
#
# ---------------------------------------------------------------------------------------
# L I C E N S E
# ---------------------------------------------------------------------------------------
# This file is part of OpenBLT. OpenBLT is free software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published by the Free
# Software Foundation, either version 3 of the License, or (at your option) any later
# version.
#
# OpenBLT is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
# without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
# PURPOSE. See the GNU General Public License for more details.
#
# You have received a copy of the GNU General Public License along with OpenBLT. It
# should be located in ".\Doc\license.html". If not, contact Feaser to obtain a copy.
#
# ***************************************************************************************
# ***************************************************************************************
# Imports
# ***************************************************************************************
from setuptools import setup
# ***************************************************************************************
# Implementation
# ***************************************************************************************
setup ( \
name = 'openblt',
version = '1.3.7',
description = 'Python wrapper for the OpenBLT host library (LibOpenBLT).',
long_description = open('README.rst', 'r').read(),
author = 'Frank Voorburg',
author_email = 'voorburg@feaser.com',
url = 'https://www.feaser.com/openblt/doku.php?id=manual:libopenblt',
packages = ['openblt'],
)
# ********************************* end of setup.py *************************************