I have an LCD display that requires that display data be sent serially.
The frame for this packet is like this.
frame=dict(
type=0x10,
sequence=0,
length=46,
line=0,
text=b'01234567890' * 4,
checksum=0,
eof=0x9F
)
If I generate a list of the values in a frame, I might get this.
>>> list(frame.values())
[16, 0, 46, 0, b'01234567890012345678900123456789001234567890', 0, 159]
If I sum this list to populate the checksum, an exception is raised. I can sum the list without the bytearray and I can sum the bytes object but cannot sum it together. It seems that this would be handy to do.
What is an elegant way to address this case?