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

Function transmit

app/rcc/scripts/output/binary_packet.js:5–14  ·  view source on GitHub ↗

* Binary packet with STX/ETX framing and XOR checksum. * Common in PLCs, industrial sensors, and embedded protocols.

(value)

Source from the content-addressed store, hash-verified

3 * Common in PLCs, industrial sensors, and embedded protocols.
4 */
5function transmit(value) {
6 var STX = String.fromCharCode(0x02);
7 var ETX = String.fromCharCode(0x03);
8 var cmd = String.fromCharCode(0x01);
9 var val = String.fromCharCode(Math.round(value) & 0xFF);
10
11 // XOR checksum over cmd + value
12 var chk = String.fromCharCode(0x01 ^ (Math.round(value) & 0xFF));
13 return STX + cmd + val + chk + ETX;
14}

Callers

nothing calls this directly

Calls 1

roundMethod · 0.80

Tested by

no test coverage detected