pyP2Monitor
1.0.0
Monitor a P2 furnace activity reading data on serial port
|
The class managing message from the furnace. More...
Public Member Functions | |
def | __init__ |
Instanciate a new P2Msg object. | |
def | setHeader |
Set the P2msg header. | |
def | setDataSz |
Set the data size if sizeChk is True and data already set, check for validity. | |
def | setData |
Set the P2Msg data field If sizeChk is True and data size already set check for validity. | |
def | setChecksum |
Set the cheksum If no arguments process the checksum from header and datas if checksum argument set and check is True set the checksum value and check its validity. | |
def | prepare |
Prepare a message to be ready to send. | |
def | resetValid |
Reset the value of the P2Msg::valid flag. | |
def | getDataSz |
Return the data size. | |
def | getChecksum |
Return the checksum. | |
def | getHeader |
Return the header. | |
def | getData |
Return the data. | |
def | __print__ |
Alias for P2Msg::getStr() | |
def | getStr |
Return a string representing the message in hexadecimal notation. | |
def | getRaw |
Return the raw str representing the message. | |
def | dump |
Display all the informations on the message. | |
def | dumpData |
Return a string trying to display every printable ASCII character. | |
def | dispInitMsg |
A try to display initialisation message. | |
def | failed |
Return the not valid flag. | |
def | calcChecksum |
Return the checksum as an integer for this message. | |
def | check |
Check the message checksum. |
Static Public Member Functions | |
def | str2list |
Cast an ascii string into a list of bytes (type cast only) | |
def | hex2list |
Convert a string with 2 digits hexadecimal numbers into a list of integers. | |
def | formatList |
Format an integer list. |
Data Fields | |
header | |
The message header or command identifier. | |
datas | |
The message data. | |
dataSz | |
The data length in bytes. | |
checksum | |
The message checksum. | |
valid | |
A flag telling wether the message is in a valid state or not. |
Static Public Attributes | |
int | FMT_INT = 1 |
Huge integer format. | |
int | FMT_RAW_STR = 2 |
Raw string format. | |
int | FMT_HEX_STR = 3 |
Hexadecimal representation string. | |
int | FMT_LIST = 4 |
Integer list. |
def __init__ | ( | self, | |
header = None , |
|||
datas = None |
|||
) |
def calcChecksum | ( | self | ) |
Return the checksum as an integer for this message.
Process and return the current message checksum
Definition at line 454 of file p2msg.py.
References P2Msg.datas, P2Query.datas, P2Msg.dataSz, and P2Msg.header.
Referenced by P2Msg.setChecksum().
def check | ( | self | ) |
Check the message checksum.
Process the checksum and check if it is the same than the stored checksum
Definition at line 467 of file p2msg.py.
References P2Msg.checksum, and P2Msg.getChecksum().
Referenced by P2Msg.getRaw(), and P2Msg.setChecksum().
def dispInitMsg | ( | self | ) |
A try to display initialisation message.
This functions try to display P2 furnace initialisation message in a more readable format
Definition at line 405 of file p2msg.py.
References P2Msg.datas, P2Query.datas, P2Msg.dumpData(), and P2Msg.header.
def dumpData | ( | self, | |
data, | |||
chrRange = [' ' |
|||
) |
Return a string trying to display every printable ASCII character.
The returned string represente each data's bytes sperated with a space. Printable character are displayed as a single char when other value are displayed in 2 digits hexadecimal notation
data | The data to parse |
chrRange | The character range to display |
Definition at line 393 of file p2msg.py.
Referenced by P2Msg.dispInitMsg().
def failed | ( | self | ) |
Return the not valid flag.
Definition at line 446 of file p2msg.py.
References P2Msg.valid.
Referenced by P2Msg.getRaw().
|
static |
Format an integer list.
lst | The list to format |
fmt | The wanted data format |
TypeError | On invalid type for parameters |
def getChecksum | ( | self, | |
fmt = FMT_INT |
|||
) |
Return the checksum.
fmt | The wanted data format |
TypeError | On invalid type for parameters |
Definition at line 271 of file p2msg.py.
References P2Msg.checksum.
Referenced by P2Msg.check(), and P2Msg.getRaw().
def getData | ( | self, | |
fmt = FMT_LIST |
|||
) |
Return the data.
fmt | The wanted data format |
Definition at line 331 of file p2msg.py.
References P2Msg.datas, and P2Query.datas.
Referenced by P2Msg.getRaw().
def getDataSz | ( | self, | |
fmt = FMT_INT |
|||
) |
Return the data size.
fmt | The wanted data format |
TypeError | On invalid type for parameters |
Definition at line 246 of file p2msg.py.
References P2Msg.dataSz.
Referenced by P2Msg.getRaw().
def getHeader | ( | self, | |
fmt = FMT_LIST |
|||
) |
Return the header.
fmt | The wanted data format |
Definition at line 321 of file p2msg.py.
References P2Msg.header.
Referenced by P2Msg.getRaw().
def getRaw | ( | self | ) |
Return the raw str representing the message.
Definition at line 359 of file p2msg.py.
References P2Msg.check(), P2Msg.failed(), P2Msg.getChecksum(), P2ComError.getData(), P2DbStore.getData(), P2Msg.getData(), P2Msg.getDataSz(), and P2Msg.getHeader().
def getStr | ( | self | ) |
Return a string representing the message in hexadecimal notation.
Definition at line 342 of file p2msg.py.
References P2Msg.checksum, P2Msg.datas, P2Query.datas, and P2Msg.header.
Referenced by P2Msg.__print__(), and P2Msg.setChecksum().
|
static |
Convert a string with 2 digits hexadecimal numbers into a list of integers.
Input string example : "07474E5504"
strArg | A string with 2 hexadecimal digits integer representation (without space) |
Definition at line 94 of file p2msg.py.
Referenced by p2data.csvOutputData(), p2data.datas2Json(), and P2Datas.fillQuery().
def prepare | ( | self, | |
header = None , |
|||
data = None |
|||
) |
Prepare a message to be ready to send.
header | Set to None to leave header unchanged |
data | Set to None to leave data unchanged |
Definition at line 211 of file p2msg.py.
References P2Msg.datas, P2Query.datas, P2Msg.header, P2Msg.setChecksum(), P2Msg.setData(), P2Msg.setDataSz(), P2Msg.setHeader(), and P2Msg.valid.
def resetValid | ( | self, | |
val = True |
|||
) |
Reset the value of the P2Msg::valid flag.
val | The wanted value for the flag |
Definition at line 231 of file p2msg.py.
References P2Msg.valid.
def setChecksum | ( | self, | |
checksum = None , |
|||
check = True |
|||
) |
Set the cheksum If no arguments process the checksum from header and datas if checksum argument set and check is True set the checksum value and check its validity.
checksum | Set to None for checksum processing from P2Msg::header P2Msg::dataSz and P2Msg::datas, else can be a raw sring or an integer array |
check | Is a boolean telling if we check or not the validity of the checksum |
TypeError | On invalid type for parameters |
Definition at line 182 of file p2msg.py.
References P2Msg.calcChecksum(), P2Msg.check(), P2Msg.checksum, P2Msg.getStr(), and P2Msg.valid.
Referenced by P2Msg.prepare().
def setData | ( | self, | |
datas, | |||
sizeChk = True |
|||
) |
Set the P2Msg data field If sizeChk is True and data size already set check for validity.
datas | A raw string or an integer list representing datas |
sizeChk | A boolean telling whether we check datas argument size or not |
TypeError | On invalid type for parameters DEACTIVATE TEST !!! TO REACTIVATE LATER if sizeChk and self.dataSz != len(datas): self.valid = False |
Definition at line 153 of file p2msg.py.
References P2Msg.datas, P2Query.datas, P2Msg.dataSz, and P2Msg.valid.
Referenced by P2Msg.prepare().
def setDataSz | ( | self, | |
recvBuff, | |||
sizeChk = True |
|||
) |
Set the data size if sizeChk is True and data already set, check for validity.
recvBuff | Is either a raw string from the furnace begining with the data size (header removed) or an integer representing the data size |
sizeChk | A boolean telling if we have to check or not the data size (in the case where recvBuff is a raw string from serial port) |
TypeError | On invalid type for parameters |
Definition at line 130 of file p2msg.py.
References P2Msg.datas, P2Query.datas, P2Msg.dataSz, and P2Msg.valid.
Referenced by P2Msg.prepare().
def setHeader | ( | self, | |
header | |||
) |
Set the P2msg header.
header | The frame header (as string or integer array) |
TypeError | On invalid type for header param |
Definition at line 108 of file p2msg.py.
References P2Msg.header, and P2Msg.valid.
Referenced by P2Msg.prepare().
|
static |