本文整理汇总了Python中Encoder.decode_bitfield方法的典型用法代码示例。如果您正苦于以下问题:Python Encoder.decode_bitfield方法的具体用法?Python Encoder.decode_bitfield怎么用?Python Encoder.decode_bitfield使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Encoder
的用法示例。
在下文中一共展示了Encoder.decode_bitfield方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_tool_status
# 需要导入模块: import Encoder [as 别名]
# 或者: from Encoder import decode_bitfield [as 别名]
def get_tool_status(self, tool_index):
"""
Retrieve some information about the tool
@param int tool_index: The tool we would like to query for information
@return A dictionary containing status information about the tool_index
ExtruderReady : The extruder has reached target temp
ExtruderNotPluggedIn : The extruder thermocouple is not detected by the bot
ExturderOverMaxTemp : The temperature measured at the extruder is greater than max allowed
ExtruderNotHeating : In the first 40 seconds after target temp was set, the extruder is not heating up as expected
ExtruderDroppingTemp : After reaching and maintaining temperature, the extruder temp has dropped 30 degrees below target
PlatformError: an error was detected with the platform heater (if the tool supports one).
The platform heater will fail if an error is detected with the sensor (thermocouple)
or if the temperature reading appears to be unreasonable.
ExtruderError: An error was detected with the extruder heater (if the tool supports one).
The extruder heater will fail if an error is detected with the sensor (thermocouple) or
if the temperature reading appears to be unreasonable
"""
response = self.tool_query(tool_index, slave_query_command_dict['GET_TOOL_STATUS'])
[resonse_code, bitfield] = Encoder.unpack_response('<BB', response)
bitfield = Encoder.decode_bitfield(bitfield)
returnDict = {
"ExtruderReady" : bitfield[0],
"ExtruderNotPluggedIn" : bitfield[1],
"ExtruderOverMaxTemp" : bitfield[2],
"ExtruderNotHeating" : bitfield[3],
"ExtruderDroppingTemp" : bitfield[4],
"PlatformError" : bitfield[6],
"ExtruderError" : bitfield[7],
}
return returnDict
示例2: get_motherboard_status
# 需要导入模块: import Encoder [as 别名]
# 或者: from Encoder import decode_bitfield [as 别名]
def get_motherboard_status(self):
"""
Retrieve bits of information about the motherboard
@return: A python dictionary of various flags and whether theywere set or not at reset
POWER_ERRPR : An error was detected with the system power.
HEAT_SHUTDOWN : The heaters were shutdown because the bot was inactive for over 20 minutes
"""
payload = struct.pack(
'<B',
host_query_command_dict['GET_MOTHERBOARD_STATUS'],
)
response = self.writer.send_query_payload(payload)
[response_code, bitfield] = Encoder.unpack_response('<BB', response)
bitfield = Encoder.decode_bitfield(bitfield)
flags = {
'POWER_ERROR' : bitfield[7],
'HEAT_SHUTDOWN' : bitfield[6],
}
return flags