Advamation Python Library

Version: 2014-06-26
Status: beta
Requires:Python >=2.6 / 3.x
SeeAlso:advamation.h/.c
Author: Advamation, Roland Koebler (support@advamation.de)
Copyright: (c) Advamation (info@advamation.de)
License:open-source / MIT
RCS:advamation.py,v 1.9 2014/06/26 13:00:37 rk Exp

Generic functionality, used in various Advamation software.



1   enums

1.1   class AM_ERROR_CODE

Error-codes.

All errors are < 0.

Usage:class AM_ERROR_CODE

1.2   class AM_CMD

Advamation RS485-/I2C-protocol commands.

Usage:class AM_CMD

1.3   class AM_LOG_LEVEL

Log-levels (identical to G_LOG_LEVEL_... of GLib)

Usage:class AM_LOG_LEVEL

2   Exceptions

2.1   class LibraryNotInitialized(Exception)

Library not initialized.

Usage:class LibraryNotInitialized(Exception)

2.2   class AM_ERROR(Exception)

Exception for AM_ERROR.* error-codes.

Usage:

class AM_ERROR(Exception)

Attributes:
  • code: the AM_ERROR-error-code
  • message: human-readable name of the error-code
  • errno: last errno-code
  • errno_str: string describing errno-number
SeeAlso:

advamation.h

2.3   AM_ERROR_errcheck(result, _func, _arguments)

ctypes-errcheck-function: Raise AM_ERROR(result) if result < 0.

Usage:AM_ERROR_errcheck(result, _func, _arguments)

3   misc.

3.1   crc_smbus(crc, byte)

CRC: SMBus PEC.

Calculate CRC/PEC according to SMBus.

Usage:

crc_smbus(crc, byte)

Parameters:
  • crc: current CRC (or 0)
  • byte: data-byte
Returns:

new crc

3.2   bytes2list(bytestring)

Convert a bytestring to a list of ints.

Only necessary in Python 2, since Python 3 bytestrings can already be accessed similar to a list-of-integers.

Usage:bytes2list(bytestring)
Requires:Python 2

4   UI-functions

4.1   am_error2str(code)

Map AM_ERROR_CODE.* to a string.

Usage:am_error2str(code)
Returns:the string or "unknown"