MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / _extract_be

Function _extract_be

tests/scripts/test_cpp_regressions.py:1236–1246  ·  view source on GitHub ↗

Mirror of the fixed Motorola (big-endian) sawtooth extractor.

(frame: bytes, start_bit: int, length: int)

Source from the content-addressed store, hash-verified

1234
1235
1236def _extract_be(frame: bytes, start_bit: int, length: int) -> int:
1237 """Mirror of the fixed Motorola (big-endian) sawtooth extractor."""
1238 value = 0
1239 bit_pos = start_bit
1240 for _ in range(length):
1241 byte_idx = bit_pos // 8
1242 if byte_idx < len(frame):
1243 bit = (frame[byte_idx] >> (bit_pos % 8)) & 1
1244 value = (value << 1) | bit
1245 bit_pos = (bit_pos + 15) if (bit_pos % 8 == 0) else (bit_pos - 1)
1246 return value
1247
1248
1249def _extract_be_old(frame: bytes, start_bit: int, length: int) -> int:

Calls

no outgoing calls

Tested by

no test coverage detected