get_data_from_frame
Tobias Müller, M. Eng edited this page 5 years ago

📜 Table of Contents


get_data_from_frame

Definition
def get_data_from_frame(self, bytearray_of_frame):
Description

The "get_data_from_frame" method is used to decode data from the received byte-frame, what you get from the Xtender-System. If CRC-Check is active, it will check the byte-frame and raises a Value_Error, if a CRC-Error was detected. It can only be used with a known Object_ID, otherwise it will raise a Value-Error. This method return a list with two elements. The first is a boolean value, which is true, if the xtender-system detects an error and the second element of the list then contains the error-id. If no error occures, then the first element is false und the second element contains the answer of your request. The returned value of the second element is a string, integer or float, depending of the service (read/write) of the request frame and of the format of the received Property_Data.

Arguments

The "self" argument is pointing to the object, which calls the method.

The "bytearray_of_frame" argument is the frame what you get, when you receive data from the serial port.

Return Value

Type -> list

list[0]: Type -> boolean

list[1]: Type -> depending of the service (read/write) of the request frame and of the format of the received Property_Data

Example Code
>>> # create an object of the Xcom-API-Class
>>> Object = Xcom_API()
>>> 
>>> # create a variable with a received frame
>>> Frame =  bytearray(b'\\xAA\\x37\\x65\\x00\\x00\\x00\\x01\\x00\\x00\\x00\\x0E\\x00\\xAA\\x66\\x02\\x01\\x01\\x00\\xB8\\x0B\\x00\\x00\\x01\\x00\\x00\\x40\\x42\\x42\\x8B\\x46')
>>> 
>>> # call the Method 'get_data_from_frame'
>>> Answer = Object.get_data_from_frame(Frame)
>>> 
>>> # print Answer
>>> print(Answer)
    (False, 48.5625)

Hochschule Anhalt | Anhalt University of Applied Sciences | Department 6 EMW
Xcom-API

Tobias Müller, M. Eng.
📧 Tobias.Mueller@HS-Anhalt.de

© es-lab.de, 31.10.2017