MCPcopy Create free account
hub / github.com/AstroPrint/AstroBox / decode_uint16

Function decode_uint16

src/ext/makerbot_driver/Encoder/Coding.py:71–80  ·  view source on GitHub ↗

Decode a 2-byte string as a 16-bit integer @param data byte array of size 2 that represents the integer @return decoded integer

(data)

Source from the content-addressed store, hash-verified

69
70
71def decode_uint16(data):
72 """
73 Decode a 2-byte string as a 16-bit integer
74 @param data byte array of size 2 that represents the integer
75 @return decoded integer
76 """
77 #Byte arrays need to be converted into arrays to be unpackable by struct
78 if isinstance(data, bytearray):
79 data = array.array('B', data)
80 return struct.unpack('<H', data)[0]
81
82
83def encode_axis(axis):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected