本文整理汇总了Python中Encoder.unpack_response方法的典型用法代码示例。如果您正苦于以下问题:Python Encoder.unpack_response方法的具体用法?Python Encoder.unpack_response怎么用?Python Encoder.unpack_response使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Encoder
的用法示例。
在下文中一共展示了Encoder.unpack_response方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_communication_stats
# 需要导入模块: import Encoder [as 别名]
# 或者: from Encoder import unpack_response [as 别名]
def get_communication_stats(self):
"""
Get some communication statistics about traffic on the tool network from the Host.
"""
payload = struct.pack(
'<B',
host_query_command_dict['GET_COMMUNICATION_STATS'],
)
response = self.writer.send_query_payload(payload)
[response_code,
packetsReceived,
packetsSent,
nonResponsivePacketsSent,
packetRetries,
noiseBytes] = Encoder.unpack_response('<BLLLLL', response)
info = {
'PacketsReceived' : packetsReceived,
'PacketsSent' : packetsSent,
'NonResponsivePacketsSent' : nonResponsivePacketsSent,
'PacketRetries' : packetRetries,
'NoiseBytes' : noiseBytes,
}
return info
示例2: extended_stop
# 需要导入模块: import Encoder [as 别名]
# 或者: from Encoder import unpack_response [as 别名]
def extended_stop(self, halt_steppers, clear_buffer):
"""
Stop the stepper motor motion and/or reset the command buffer. This differs from the
reset and abort commands in that a soft reset of all functions isnt called.
@param boolean halt_steppers: A flag that if true will stop the steppers
@param boolean clear_buffer: A flag that, if true, will clear the buffer
"""
bitfield = 0
if halt_steppers:
bitfield |= 0x01
if clear_buffer:
bitfield |= 0x02
payload = struct.pack(
'<Bb',
host_query_command_dict['EXTENDED_STOP'],
bitfield,
)
response = self.writer.send_query_payload(payload)
[response_code, extended_stop_response] = Encoder.unpack_response('<BB', response)
if extended_stop_response != 0:
raise ExtendedStopError
示例3: get_build_stats
# 需要导入模块: import Encoder [as 别名]
# 或者: from Encoder import unpack_response [as 别名]
def get_build_stats(self):
"""
Get some statistics about the print currently running, or the last print if no print is active
"""
payload = struct.pack(
'<B',
host_query_command_dict['GET_BUILD_STATS'],
)
response = self.writer.send_query_payload(payload)
[response_code,
build_state,
build_hours,
build_minutes,
line_number,
reserved] = Encoder.unpack_response('<BBBBLL', response)
info = {
'BuildState' : build_state,
'BuildHours' : build_hours,
'BuildMinutes' : build_minutes,
'LineNumber' : line_number,
'Reserved' : reserved
}
return info
示例4: get_advanced_version
# 需要导入模块: import Encoder [as 别名]
# 或者: from Encoder import unpack_response [as 别名]
def get_advanced_version(self):
"""
Get the firmware version number of the connected machine
@return Version number
"""
payload = struct.pack(
'<BH',
host_query_command_dict['GET_ADVANCED_VERSION'],
s3g_version,
)
response = self.writer.send_query_payload(payload)
[response_code,
version,
internal_version,
reserved_a,
reserved_b] = Encoder.unpack_response('<BHHHH', response)
version_info = {
'Version' : version,
'InternalVersion' : internal_version,
'ReservedA' : reserved_a,
'ReservedB' : reserved_b,
}
return version_info
示例5: get_tool_status
# 需要导入模块: import Encoder [as 别名]
# 或者: from Encoder import unpack_response [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
示例6: get_motor1_speed
# 需要导入模块: import Encoder [as 别名]
# 或者: from Encoder import unpack_response [as 别名]
def get_motor1_speed(self, tool_index):
"""
Gets the toohead's motor speed in Rotations per Minute (RPM)
@param int tool_index: The tool index that will be queried for Motor speed
@return int Duration of each rotation, in miliseconds
"""
response = self.tool_query(tool_index, slave_query_command_dict['GET_MOTOR_1_SPEED_RPM'])
[response_code, speed] = Encoder.unpack_response('<BI', response)
return speed
示例7: get_motor1_speed_PWM
# 需要导入模块: import Encoder [as 别名]
# 或者: from Encoder import unpack_response [as 别名]
def get_motor1_speed_PWM(self, tool_index):
"""
Gets the toohead's motor speed in as a 0 - 255 / 255 PWM duty cycle.
@param int tool_index: The tool index that will be queried for Motor speed
@return byte pwm : PWM duty cycle, 0% = 0, 100% = 255
"""
response = self.tool_query(tool_index, slave_query_command_dict['GET_MOTOR_1_SPEED_PWM'])
[response_code, pwm] = Encoder.unpack_response('<BB', response)
return pwm
示例8: get_platform_temperature
# 需要导入模块: import Encoder [as 别名]
# 或者: from Encoder import unpack_response [as 别名]
def get_platform_temperature(self, tool_index):
"""
Retrieve the build platform temperature
@param int tool_index: Toolhead Index
@return int temperature: reported by the toolhead
"""
response = self.tool_query(tool_index, slave_query_command_dict['GET_PLATFORM_TEMP'])
[response_code, temperature] = Encoder.unpack_response('<BH', response)
return temperature
示例9: get_platform_target_temperature
# 需要导入模块: import Encoder [as 别名]
# 或者: from Encoder import unpack_response [as 别名]
def get_platform_target_temperature(self, tool_index):
"""
Retrieve the build platform target temperature (setpoint)
@param int tool_index: Toolhead Index
@return int temperature: that the build platform is attempting to achieve
"""
response = self.tool_query(tool_index, slave_query_command_dict['GET_PLATFORM_TARGET_TEMP'])
[response_code, temperature] = Encoder.unpack_response('<BH', response)
return temperature
示例10: is_finished
# 需要导入模块: import Encoder [as 别名]
# 或者: from Encoder import unpack_response [as 别名]
def is_finished(self):
"""
Checks if the steppers are still executing a command
"""
payload = struct.pack(
'<B',
host_query_command_dict['IS_FINISHED'],
)
response = self.writer.send_query_payload(payload)
[response_code, isFinished] = Encoder.unpack_response('<B?', response)
return isFinished
示例11: get_version
# 需要导入模块: import Encoder [as 别名]
# 或者: from Encoder import unpack_response [as 别名]
def get_version(self):
"""
Get the firmware version number of the connected machine
@return Version number
"""
payload = struct.pack(
'<BH',
host_query_command_dict['GET_VERSION'],
s3g_version,
)
response = self.writer.send_query_payload(payload)
[response_code, version] = Encoder.unpack_response('<BH', response)
return version
示例12: get_toolhead_version
# 需要导入模块: import Encoder [as 别名]
# 或者: from Encoder import unpack_response [as 别名]
def get_toolhead_version(self, tool_index):
"""
Get the firmware version number of the specified toolhead
@return double Version number
"""
payload = struct.pack(
'<H',
s3g_version
)
response = self.tool_query(tool_index,slave_query_command_dict['GET_VERSION'], payload)
[response_code, version] = Encoder.unpack_response('<BH', response)
return version
示例13: end_capture_to_file
# 需要导入模块: import Encoder [as 别名]
# 或者: from Encoder import unpack_response [as 别名]
def end_capture_to_file(self):
"""
Send the end capture signal to the bot, so it stops capturing data and writes all commands out to a file on the SD card
@return The number of bytes written to file
"""
payload = struct.pack(
'<B',
host_query_command_dict['END_CAPTURE'],
)
response = self.writer.send_query_payload(payload)
[response_code, sdResponse] = Encoder.unpack_response('<BI', response)
return sdResponse
示例14: get_available_buffer_size
# 需要导入模块: import Encoder [as 别名]
# 或者: from Encoder import unpack_response [as 别名]
def get_available_buffer_size(self):
"""
Gets the available buffer size
@return Available buffer size, in bytes
"""
payload = struct.pack(
'<B',
host_query_command_dict['GET_AVAILABLE_BUFFER_SIZE'],
)
response = self.writer.send_query_payload(payload)
[response_code, buffer_size] = Encoder.unpack_response('<BI', response)
return buffer_size
示例15: capture_to_file
# 需要导入模块: import Encoder [as 别名]
# 或者: from Encoder import unpack_response [as 别名]
def capture_to_file(self, filename):
"""
Capture all subsequent commands up to the 'end capture' command to a file with the given filename on an SD card.
@param str filename: The name of the file to write to on the SD card
"""
payload = struct.pack(
'<B',
host_query_command_dict['CAPTURE_TO_FILE'],
)
payload += filename
payload += '\x00'
response = self.writer.send_query_payload(payload)
[response_code, sd_response_code] = Encoder.unpack_response('<BB', response)
if sd_response_code != sd_error_dict['SUCCESS']:
raise SDCardError(sd_response_code)