Skip to content

Commit ef4d908

Browse files
authored
Merge pull request #104 from openUC2/mergemaster
Mergemaster
2 parents 1614305 + 38a979f commit ef4d908

2 files changed

Lines changed: 20 additions & 5 deletions

File tree

uc2rest/TEST/TEST_GRIPPER.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,12 @@
88
ESP32 = uc2rest.UC2Client(serialport=port, baudrate=115200, DEBUG=True)
99

1010
# open gripper
11-
ESP32.gripper.open(isBlocking=True)
12-
# close gripper
13-
ESP32.gripper.close(isBlocking=True)
11+
for i in range(10):
12+
ESP32.gripper.open(isBlocking=True)
13+
# close gripper^
14+
time.sleep(0.5)
15+
ESP32.gripper.close(isBlocking=True)
16+
time.sleep(0.5)
1417
# set gripper angle
1518
ESP32.gripper.setAngle(90, isBlocking=True)
1619

uc2rest/mserial.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,13 @@
55
import threading
66
import time
77
import sys
8-
from serial.serialutil import SerialException
8+
try:
9+
from serial.serialutil import SerialException
10+
IS_SERIAL = True
11+
except ImportError:
12+
IS_SERIAL = False
13+
class SerialException(Exception):
14+
pass
915

1016
T_SERIAL_WARMUP = 2.5
1117
class Serial:
@@ -51,7 +57,13 @@ def __init__(self, port, baudrate=115200, timeout=5,
5157

5258
# initialize serial connection
5359
self.thread = None
54-
self.serialdevice= self.openDevice(port, baudrate)
60+
if IS_SERIAL:
61+
self.serialdevice= self.openDevice(port, baudrate)
62+
else:
63+
self.serialdevice = MockSerial(port, baudrate, timeout=timeout)
64+
self.is_connected = False
65+
self.manufacturer = "UC2Mock"
66+
self._logger.debug("You have to ensure that the serial device is connected to the computer!")
5567

5668
def breakCurrentCommunication(self):
5769
self.resetLastCommand = True

0 commit comments

Comments
 (0)