Skip to content
Snippets Groups Projects
Commit 588a136c authored by fxk8y's avatar fxk8y :spider:
Browse files

Adding fxCyan envelope generator

parent a194f288
No related branches found
No related tags found
No related merge requests found
......@@ -7,6 +7,11 @@ from inspect import signature
from socket import socket, AF_INET, SOCK_DGRAM
#########################################################################################
### TODO: How to distinguish this from "the other fxCyan" (the protocol envelope) ? ####
#########################################################################################
class fxCyanDefaults:
port = 4213
......
import struct
# from crccheck import …
###########################################################################################
### TODO: How to distinguish this from "the other fxCyan" (the LED protocol family) ? ####
###########################################################################################
class FxCyan:
header = b'fxCyan'
@staticmethod
def makePacket(payload: bytes) -> bytes:
'Wraps the payload in the standardized `fxCyan`-envelope'
length = struct.pack('>H', len(payload)) # format = big-endian uint16_t
crc = FxCyan.crc(payload)
return FxCyan.header + length + payload + crc
@staticmethod
def crc(data: bytes) -> bytes:
'Calculates and returns the CRC sum of the data'
# TODO: implement!
return bytes.fromhex('1337AA1337')
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment