mirror of
https://github.com/dptech-corp/Uni-Lab-OS.git
synced 2026-02-15 12:15:11 +00:00
Compare commits
2 Commits
9e214c56c1
...
1cd07915e7
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1cd07915e7 | ||
|
|
b600fc666d |
@@ -145,12 +145,22 @@ class RunzeMultiplePump:
|
|||||||
total_steps_vel = 48000 if mode == RunzeSyringePumpMode.AccuratePosVel else 6000
|
total_steps_vel = 48000 if mode == RunzeSyringePumpMode.AccuratePosVel else 6000
|
||||||
return total_steps, total_steps_vel
|
return total_steps, total_steps_vel
|
||||||
|
|
||||||
|
def _receive(self, data: bytes) -> str:
|
||||||
|
"""
|
||||||
|
Keep this method as original. Always use chr to decode, avoid "/0"
|
||||||
|
"""
|
||||||
|
if not data:
|
||||||
|
return ""
|
||||||
|
# **Do not use decode method
|
||||||
|
ascii_string = "".join(chr(byte) for byte in data)
|
||||||
|
return ascii_string
|
||||||
|
|
||||||
def send_command(self, full_command: str) -> str:
|
def send_command(self, full_command: str) -> str:
|
||||||
"""Send command to hardware and get response"""
|
"""Send command to hardware and get response"""
|
||||||
full_command_data = bytearray(full_command, "ascii")
|
full_command_data = bytearray(full_command, "ascii")
|
||||||
self.hardware_interface.write(full_command_data)
|
self.hardware_interface.write(full_command_data)
|
||||||
time.sleep(0.05)
|
time.sleep(0.05)
|
||||||
response = self.hardware_interface.read_until(b"\n")
|
response = self.hardware_interface.read_until(b"\n") # \n should direct use, not \\n
|
||||||
output = self._receive(response)
|
output = self._receive(response)
|
||||||
return output
|
return output
|
||||||
|
|
||||||
@@ -175,11 +185,6 @@ class RunzeMultiplePump:
|
|||||||
output = self.send_command(full_command)[3:-3]
|
output = self.send_command(full_command)[3:-3]
|
||||||
return output
|
return output
|
||||||
|
|
||||||
def _receive(self, data: bytes) -> str:
|
|
||||||
if not data:
|
|
||||||
return ""
|
|
||||||
ascii_string = "".join(chr(byte) for byte in data) # *Do not use decode('ascii', errors='ignore')
|
|
||||||
return ascii_string
|
|
||||||
|
|
||||||
def _run(self, address: str, command: str) -> str:
|
def _run(self, address: str, command: str) -> str:
|
||||||
"""
|
"""
|
||||||
|
|||||||
Reference in New Issue
Block a user