Refs #384. Reintegrated the branch for LibOpenBLT's Python bindings development with the trunk.

git-svn-id: https://svn.code.sf.net/p/openblt/code/trunk@436 5dc33758-31d5-4daf-9ae8-b24bf3d40d73
This commit is contained in:
Frank Voorburg 2018-03-06 21:38:03 +00:00
parent a3890205d2
commit bc71ebb458
6 changed files with 1401 additions and 8 deletions

View File

@ -0,0 +1,41 @@
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.
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.

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

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.0',
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 *************************************

View File

@ -39,7 +39,7 @@
#include "session.h" /* Communication session module */
#include "xcploader.h" /* XCP loader module */
#include "xcptpuart.h" /* XCP UART transport layer */
#include "xcptpcan.h" /* XCP CAN transport layer */
#include "xcptpcan.h" /* XCP CAN transport layer */
#include "xcptpusb.h" /* XCP USB transport layer */
#include "xcptpnet.h" /* XCP TCP/IP transport layer */
@ -290,7 +290,7 @@ LIBOPENBLT_EXPORT void BltSessionStop(void)
/************************************************************************************//**
** \brief Requests the target to erase the specified range of memory on the target.
** Note that the target automatically aligns this to the erasable memory
** block sizes. This typically results in more memory being erased that the
** block sizes. This typically results in more memory being erased than the
** range that was specified here. Refer to the target implementation for
** details.
** \param address The starting memory address for the erase operation.

View File

@ -122,8 +122,8 @@ typedef struct t_blt_session_settings_xcp_v10
{
uint16_t timeoutT1; /**< Command response timeout in milliseconds. */
uint16_t timeoutT3; /**< Start programming timeout in milliseconds. */
uint16_t timeoutT4; /**< Erase memory timeout in milliseonds. */
uint16_t timeoutT5; /**< Program memory and reset timeout in milliseonds. */
uint16_t timeoutT4; /**< Erase memory timeout in milliseconds. */
uint16_t timeoutT5; /**< Program memory and reset timeout in milliseconds.*/
uint16_t timeoutT7; /**< Busy wait timer timeout in milliseonds. */
char const * seedKeyFile; /**< Seed/key algorithm library filename. */
uint8_t connectMode; /**< Connection mode parameter in XCP connect command.*/
@ -165,10 +165,10 @@ typedef struct t_blt_transport_settings_xcp_v10_can
uint32_t useExtended; /**< Boolean to configure 29-bit CAN identifiers. */
} tBltTransportSettingsXcpV10Can;
/** \brief Structure layout of the XCP version 1.0 RS232 transport layer settings. The
* portName field is platform dependent. On Linux based systems this should be
* the filename of the tty-device, such as "/dev/tty0". On Windows based systems
* it should be the name of the COM-port, such as "COM1".
/** \brief Structure layout of the XCP version 1.0 NET transport layer settings. The
* address field can be set to either the IP address or the hostname, such as
* "192.168.178.23" or "mymicro.mydomain.com". The port should be set to the
* TCP port number that the bootloader target listens on.
*/
typedef struct t_blt_transport_settings_xcp_v10_net
{