@@ -62,12 +62,12 @@ async def move_by(self, length, speed=None) -> None:
6262 speed = self .speed
6363
6464 # move
65- with Connection .open_serial_port (self .port ) as connection :
66- connection .enable_alerts ()
67- device = connection .detect_devices ( )[0 ]
65+ async with Connection .open_serial_port_async (self .port ) as connection :
66+ await connection .enable_alerts_async ()
67+ device = ( await connection .detect_devices_async () )[0 ]
6868 # TODO: raise xxx if len(device_list) is not 1 (0 -> no device found, >1 -> try to find correct one)
6969 axis = device .get_axis (1 )
70- axis .move_relative (
70+ await axis .move_relative_async (
7171 length ,
7272 self .length_unit ,
7373 velocity = speed ,
@@ -80,21 +80,21 @@ async def check_position(self) -> float:
8080 """
8181 Get the current position of the Zaber motor.
8282 """
83- with Connection .open_serial_port (self .port ) as connection :
84- connection .enable_alerts ()
85- device = connection .detect_devices ( )[0 ]
83+ async with Connection .open_serial_port_async (self .port ) as connection :
84+ await connection .enable_alerts_async ()
85+ device = ( connection .detect_devices_async () )[0 ]
8686 axis = device .get_axis (1 )
87- return axis .get_position (unit = self .length_unit )
87+ return await axis .get_position (unit = self .length_unit )
8888
8989 async def move_to (self , position ) -> None :
9090 """
9191 Move Zaber motor to a given position.
9292 Args:
9393 position: value to which the motor moves
9494 """
95- with Connection .open_serial_port (self .port ) as connection :
96- connection .enable_alerts ()
97- device = connection .detect_devices ()[0 ]
95+ async with Connection .open_serial_port (self .port ) as connection :
96+ await connection .enable_alerts_async ()
97+ device = await connection .detect_devices_async ()[0 ]
9898 axis = device .get_axis (1 )
9999 await axis .move_absolute_async (
100100 position ,
0 commit comments