ecom.checksum
Module Contents
Classes
A checksum verifier that can add and verify a CRC16 checksum. |
Functions
|
Calculate a CRC16 checksum from the data. |
- ecom.checksum.calculateChecksum(data: bytes, polynomial: int = 34833) int [source]
Calculate a CRC16 checksum from the data.
- Parameters:
data – The data to calculate the checksum from.
polynomial – The polynomial to use for the crc calculation in nominal form.
- Returns:
The calculated checksum.
- class ecom.checksum.ChecksumVerifier(database: ecom.database.CommunicationDatabase, checksumDatapointName='checksum')[source]
Bases:
ecom.verification.MessageVerifier
A checksum verifier that can add and verify a CRC16 checksum.
- verify(data: bytes, message: ecom.message.MessageType, header: ecom.datatypes.TypeInfo[ecom.datatypes.StructType], messageSize: int)[source]
Verify the integrity of the message.
- Raises:
VerificationError – if the message fails the verification check and the original data can’t be recovered.
- Parameters:
data – The raw data of the message. May also include other trailing data.
message – The type of message.
header – The header type information of the message.
messageSize – The size of the message, as calculated with the unverified data.
- Returns:
None if the message was verified successfully or the bytes of the error corrected message and any bytes from the given data that were not part of the message.
- addVerificationData(data: bytes, message: ecom.message.MessageType, header: ecom.datatypes.TypeInfo[ecom.datatypes.StructType]) bytes [source]
Add extra verification data to a message.
- Parameters:
data – The message data.
message – The type of message.
header – The header type information of the message.
- Returns:
The message with verification data.