Dane Sabo 3299181c70 Auto sync: 2025-09-02 22:47:53 (10335 files changed)
M  lazy-lock.json

M  lua/custom/configs/lspconfig.lua

M  lua/custom/init.lua

A  lua/custom/journal.lua

A  nvim_venv/bin/Activate.ps1

A  nvim_venv/bin/activate

A  nvim_venv/bin/activate.csh

A  nvim_venv/bin/activate.fish
2025-09-02 22:47:53 -04:00

37 lines
969 B
Python

"""Modbus TLS frame implementation."""
from __future__ import annotations
from pymodbus.framer.base import FramerBase
class FramerTLS(FramerBase):
"""Modbus TLS frame type.
Layout::
[ MBAP Header ] [ Function Code] [ Data ]
[ tid ][ pid ][ length ][ uid ]
2b 2b 2b 1b 1b Nb
length = uid + function code + data
"""
MIN_SIZE = 8
def decode(self, data: bytes) -> tuple[int, int, int, bytes]:
"""Decode MDAP+PDU."""
tid = int.from_bytes(data[0:2], 'big')
dev_id = int(data[6])
return len(data), dev_id, tid, data[7:]
def encode(self, pdu: bytes, device_id: int, tid: int) -> bytes:
"""Encode MDAP+PDU."""
frame = (
tid.to_bytes(2, 'big') +
b'\x00\x00' +
(len(pdu) + 1).to_bytes(2, 'big') +
device_id.to_bytes(1, 'big') +
pdu
)
return frame