Before AI comes a byte-level contract
A sensor sends two bytes, converted to a temperature for AI. The packet is intact and length correct, yet the model sees an impossible value—or a wrong but plausible one. We examine the choices between transmitted data and physical value using a synthetic protocol, not a commercial sensor or EL-AI device specification.
Two bytes do not specify an integer by themselves
Each eight-bit byte codes 0–255. Hex sequence 9c ff means bytes 156,255. Little-endian gives u=156+256·255=65436; big-endian gives u=256·156+255=40191. No bit changes; positional weights change. Reading digits in another order is a useful weight analogy, not a way to infer a protocol.
Byte order is not bit order within a byte, and it does not specify signedness. In signed sixteen-bit two’s complement, u below 32768 represents itself; otherwise it represents u−65536. This is format semantics, not a repair applied only to strange readings. Our bytes yield signed little-endian −100 and signed big-endian −25345.
A scale still separates code from physical value
Our hypothetical protocol uses 0.01 °C per count and zero offset: T=s·v+o. s is Celsius per count, v the interpreted integer, o a Celsius offset. Correct decoding of 9c ff gives −1 °C; alternate order and sign yield 654.36, −253.45 or 401.91 °C. These are four interpretations, not four environmental measurements. Downstream AI cannot automatically recover the intended contract.
| Format | Integer | Temperature (°C) |
|---|---|---|
| <h | -100 | -1.0 |
| <H | 65436 | 654.36 |
| >h | -25345 | -253.45 |
| >H | 40191 | 401.91 |

Python makes choices explicit: < h means a standard two-byte signed little-endian integer, > h big-endian, H unsigned. Native @ depends on platform and may include alignment in compound formats. External exchange needs an explicit contract rather than assuming matching machines. Consulted documentation and executed Python version are distinguished in the archive.
Plausibility can let an error through
A hypothetical −40 to 125 °C operating range rejects three first-example interpretations. But bytes 01 02 give signed values 5.13 °C little-endian and 2.58 big-endian, both plausible. Swapping bytes can escape alarms while changing an AI decision. Range checks help but do not prove the format; use known protocol examples too.
Byte integrity is separate. A checksum can confirm matching transmitted bytes without validating sign, scale or units. We run no transmission or checksum experiment here; the logical distinction is that preserving a message does not preserve its meaning under a different receiver contract.
Sensor status and temperature are different data types
A protocol may reserve a missing-reading code. We hypothetically reserve 0x7fff, bytes ff 7f, rather than feeding AI 327.67 °C. decode checks two-byte length, then sentinel, then sign and scale; it returns None for missing status. It does not silently replace missing with zero, which could be a valid temperature.
The script checks manual conversion, int.from_bytes and struct across all 65536 signed sixteen-bit codes. Enumeration verifies the chosen conversion, not any actual sensor protocol, cable reliability or calibration. Two-byte parsing has constant work in this model, but we claim no microcontroller latency, memory or energy measurements. Execution used host Python 3.14.0.
The first model to verify is the message model
Temperature can be wrong before the network starts. Byte order, sign, scale, offset and status codes must be explicit and versioned. Connect embedded AI using known-byte-to-physical-value checks through the whole path, then measure the actual platform. A better AI cannot automatically repair a reversed acquisition contract.
Python struct — Byte order, standard size and alignment.
import struct,json,sys
from pathlib import Path
raw=bytes.fromhex('9c ff');rows=[]
for order in ['little','big']:
for signed in [True,False]:
value=int.from_bytes(raw,byteorder=order,signed=signed);rows.append(dict(order=order,signed=signed,count=value,temperatureC=.01*value))
assert int.from_bytes(raw,'little',signed=True)==-100
def decode(data):
if len(data)!=2:raise ValueError('Expected exactly two bytes')
u=int.from_bytes(data,'little',signed=False)
if u==0x7fff:return None
signed=u if u<32768 else u-65536
return .01*signed
assert decode(raw)==-1 and decode(bytes.fromhex('ff 7f')) is None
try:decode(b'')
except ValueError:pass
else:raise AssertionError('Invalid length accepted')
for value in range(-32768,32768):
data=struct.pack('<h',value);u=data[0]+256*data[1];manual=u if u<32768 else u-65536
assert struct.unpack('<h',data)[0]==value==manual==int.from_bytes(data,'little',signed=True)
ambiguous=bytes.fromhex('01 02');both=[.01*int.from_bytes(ambiguous,x,signed=True) for x in ['little','big']]
assert both==[5.13,2.58]
r=dict(python=sys.version.split()[0],seed=None,scope='Hypothetical signed 16-bit sensor protocol, not a real sensor datasheet or device measurement',wireHex=raw.hex(' '),scaleCPerCount=.01,rows=rows,ambiguousHex=ambiguous.hex(' '),bothPlausibleC=both,exhaustiveCodesChecked=65536,reservedExample='0x7fff hypothetically reserved: must decode status rather than a numeric temperature')
Path(__file__).with_name('results.json').write_text(json.dumps(r,indent=2),encoding='utf8')
Code, data, and instructions · JSON. Educational calculations executed with Python 3.14.0; figures with Matplotlib 3.11.2. AI-assisted analysis, without claiming peer review or human review. Original illustrative ImageGen cover: it does not document EL-AI people, premises, or installations. Sources accessed 25 October 2026.

