UC2-REST 0.2.0.34__tar.gz → 0.2.0.35__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. {uc2_rest-0.2.0.34 → uc2_rest-0.2.0.35}/PKG-INFO +1 -1
  2. {uc2_rest-0.2.0.34 → uc2_rest-0.2.0.35}/UC2_REST.egg-info/PKG-INFO +1 -1
  3. {uc2_rest-0.2.0.34 → uc2_rest-0.2.0.35}/uc2rest/__version__.py +1 -1
  4. {uc2_rest-0.2.0.34 → uc2_rest-0.2.0.35}/uc2rest/canota.py +29 -1
  5. {uc2_rest-0.2.0.34 → uc2_rest-0.2.0.35}/uc2rest/home.py +2 -0
  6. {uc2_rest-0.2.0.34 → uc2_rest-0.2.0.35}/uc2rest/motor.py +3 -1
  7. {uc2_rest-0.2.0.34 → uc2_rest-0.2.0.35}/uc2rest/mserial.py +3 -3
  8. {uc2_rest-0.2.0.34 → uc2_rest-0.2.0.35}/LICENSE +0 -0
  9. {uc2_rest-0.2.0.34 → uc2_rest-0.2.0.35}/README.md +0 -0
  10. {uc2_rest-0.2.0.34 → uc2_rest-0.2.0.35}/UC2_REST.egg-info/SOURCES.txt +0 -0
  11. {uc2_rest-0.2.0.34 → uc2_rest-0.2.0.35}/UC2_REST.egg-info/dependency_links.txt +0 -0
  12. {uc2_rest-0.2.0.34 → uc2_rest-0.2.0.35}/UC2_REST.egg-info/not-zip-safe +0 -0
  13. {uc2_rest-0.2.0.34 → uc2_rest-0.2.0.35}/UC2_REST.egg-info/requires.txt +0 -0
  14. {uc2_rest-0.2.0.34 → uc2_rest-0.2.0.35}/UC2_REST.egg-info/top_level.txt +0 -0
  15. {uc2_rest-0.2.0.34 → uc2_rest-0.2.0.35}/setup.cfg +0 -0
  16. {uc2_rest-0.2.0.34 → uc2_rest-0.2.0.35}/setup.py +0 -0
  17. {uc2_rest-0.2.0.34 → uc2_rest-0.2.0.35}/uc2rest/MockSerial.py +0 -0
  18. {uc2_rest-0.2.0.34 → uc2_rest-0.2.0.35}/uc2rest/UC2Client.py +0 -0
  19. {uc2_rest-0.2.0.34 → uc2_rest-0.2.0.35}/uc2rest/__init__.py +0 -0
  20. {uc2_rest-0.2.0.34 → uc2_rest-0.2.0.35}/uc2rest/analog.py +0 -0
  21. {uc2_rest-0.2.0.34 → uc2_rest-0.2.0.35}/uc2rest/camera.py +0 -0
  22. {uc2_rest-0.2.0.34 → uc2_rest-0.2.0.35}/uc2rest/camera_trigger.py +0 -0
  23. {uc2_rest-0.2.0.34 → uc2_rest-0.2.0.35}/uc2rest/can.py +0 -0
  24. {uc2_rest-0.2.0.34 → uc2_rest-0.2.0.35}/uc2rest/cmdrecorder.py +0 -0
  25. {uc2_rest-0.2.0.34 → uc2_rest-0.2.0.35}/uc2rest/digitalin.py +0 -0
  26. {uc2_rest-0.2.0.34 → uc2_rest-0.2.0.35}/uc2rest/digitalout.py +0 -0
  27. {uc2_rest-0.2.0.34 → uc2_rest-0.2.0.35}/uc2rest/fan.py +0 -0
  28. {uc2_rest-0.2.0.34 → uc2_rest-0.2.0.35}/uc2rest/galvo.py +0 -0
  29. {uc2_rest-0.2.0.34 → uc2_rest-0.2.0.35}/uc2rest/gripper.py +0 -0
  30. {uc2_rest-0.2.0.34 → uc2_rest-0.2.0.35}/uc2rest/laser.py +0 -0
  31. {uc2_rest-0.2.0.34 → uc2_rest-0.2.0.35}/uc2rest/lcddisplay.py +0 -0
  32. {uc2_rest-0.2.0.34 → uc2_rest-0.2.0.35}/uc2rest/ledmatrix.py +0 -0
  33. {uc2_rest-0.2.0.34 → uc2_rest-0.2.0.35}/uc2rest/logger.py +0 -0
  34. {uc2_rest-0.2.0.34 → uc2_rest-0.2.0.35}/uc2rest/message.py +0 -0
  35. {uc2_rest-0.2.0.34 → uc2_rest-0.2.0.35}/uc2rest/modules.py +0 -0
  36. {uc2_rest-0.2.0.34 → uc2_rest-0.2.0.35}/uc2rest/motor_config.py +0 -0
  37. {uc2_rest-0.2.0.34 → uc2_rest-0.2.0.35}/uc2rest/objective.py +0 -0
  38. {uc2_rest-0.2.0.34 → uc2_rest-0.2.0.35}/uc2rest/pid.py +0 -0
  39. {uc2_rest-0.2.0.34 → uc2_rest-0.2.0.35}/uc2rest/rotator.py +0 -0
  40. {uc2_rest-0.2.0.34 → uc2_rest-0.2.0.35}/uc2rest/slm.py +0 -0
  41. {uc2_rest-0.2.0.34 → uc2_rest-0.2.0.35}/uc2rest/state.py +0 -0
  42. {uc2_rest-0.2.0.34 → uc2_rest-0.2.0.35}/uc2rest/temperature.py +0 -0
  43. {uc2_rest-0.2.0.34 → uc2_rest-0.2.0.35}/uc2rest/utils.py +0 -0
  44. {uc2_rest-0.2.0.34 → uc2_rest-0.2.0.35}/uc2rest/wifi.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: UC2-REST
3
- Version: 0.2.0.34
3
+ Version: 0.2.0.35
4
4
  Summary: This pacage will help you to drive the ESP32-driven microscopy control modules from UC2
5
5
  Home-page: https://github.com/openUC2/UC2-REST
6
6
  Author: Benedict Diederich
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: UC2-REST
3
- Version: 0.2.0.34
3
+ Version: 0.2.0.35
4
4
  Summary: This pacage will help you to drive the ESP32-driven microscopy control modules from UC2
5
5
  Home-page: https://github.com/openUC2/UC2-REST
6
6
  Author: Benedict Diederich
@@ -6,7 +6,7 @@ __version__.py
6
6
 
7
7
  __title__ = 'UC2-REST'
8
8
  __description__ = 'This pacage will help you to drive the ESP32-driven microscopy control modules from UC2'
9
- __version__ = "v0.2.0.34"
9
+ __version__ = "v0.2.0.35"
10
10
  __author__ = 'Benedict Diederich'
11
11
  __author_email__ = 'benedictdied@gmail.com'
12
12
  __license__ = 'GPL v3'
@@ -58,7 +58,11 @@ class CANOTA(object):
58
58
  """
59
59
  self._parent = parent
60
60
  self.nCallbacks = nCallbacks
61
-
61
+
62
+ # Threading event: set to True to request cancellation of any running
63
+ # streaming upload.
64
+ self._cancel_event = threading.Event()
65
+
62
66
  # Initialize callback functions for different types of OTA events
63
67
  self.init_callback_functions(self.nCallbacks)
64
68
 
@@ -294,6 +298,15 @@ class CANOTA(object):
294
298
  # MD5) and wait for ``{"ota_status":"success"|"error"}``.
295
299
  # ========================================================================
296
300
 
301
+ def cancel_streaming_ota(self):
302
+ """Request cancellation of any running streaming upload.
303
+
304
+ The upload worker checks this flag at every chunk boundary and will
305
+ abort cleanly (restoring the parent serial connection) on the next
306
+ iteration.
307
+ """
308
+ self._cancel_event.set()
309
+
297
310
  def start_can_streaming_ota(self, can_id: int, firmware_path: str,
298
311
  progress_callback=None, status_callback=None,
299
312
  port: str = None, baud: int = STREAMING_BAUD):
@@ -349,6 +362,8 @@ class CANOTA(object):
349
362
  crc32, num_chunks, progress_callback, status_callback)
350
363
  )
351
364
  upload_thread.daemon = True
365
+ # Reset any previous cancellation before starting the new upload
366
+ self._cancel_event.clear()
352
367
  upload_thread.start()
353
368
 
354
369
  return upload_thread
@@ -434,6 +449,12 @@ class CANOTA(object):
434
449
  chunk_no = 0
435
450
 
436
451
  while sent < firmware_size:
452
+ # Honour cancellation requests between chunks
453
+ if self._cancel_event.is_set():
454
+ if status_callback:
455
+ status_callback("Upload cancelled by user", False)
456
+ return
457
+
437
458
  end = min(sent + CHUNK_SIZE, firmware_size)
438
459
  payload = firmware_data[sent:end]
439
460
  chunk_no += 1
@@ -445,6 +466,11 @@ class CANOTA(object):
445
466
  # Block until the master ACKs at least ``sent`` bytes.
446
467
  deadline = time.time() + ACK_TIMEOUT_S
447
468
  while last_ack < sent:
469
+ # Check for cancellation inside the ACK wait loop as well
470
+ if self._cancel_event.is_set():
471
+ if status_callback:
472
+ status_callback("Upload cancelled by user", False)
473
+ return
448
474
  last_ack, err = self._drain_acks(ser, ack_buf, last_ack)
449
475
  if err is not None:
450
476
  if status_callback:
@@ -545,6 +571,8 @@ class CANOTA(object):
545
571
  buf = bytearray()
546
572
  while time.time() < deadline:
547
573
  chunk = ser.read(ser.in_waiting or 1)
574
+ # debug print of chunks
575
+ # self._parent.logger.debug(f"Received chunk: {chunk}")
548
576
  if chunk:
549
577
  buf.extend(chunk)
550
578
  obj = self._try_extract_json_status(bytes(buf))
@@ -322,6 +322,8 @@ class Home(object):
322
322
 
323
323
  timeout = timeout if isBlocking else 0
324
324
  nResponses = 2 # one for command received, one for home reached
325
+ if timeout and timeout > 1000:
326
+ timeout = timeout / 1000.0
325
327
 
326
328
  # if we get a return, we will receive the latest position feedback from the driver by means of the axis that moves the longest
327
329
  r = self._parent.post_json(path, payload, getReturn=isBlocking, timeout=timeout, nResponses=nResponses)
@@ -402,8 +402,10 @@ class Motor(object):
402
402
  return self.move_axis_by_name(axis="A", steps=steps, speed=speed, acceleration=acceleration, is_blocking=is_blocking, is_absolute=is_absolute, is_enabled=is_enabled, timeout=timeout, is_reduced=is_reduced)
403
403
 
404
404
  def move_xyz(self, steps=(0,0,0), speed=(1000,1000,1000), acceleration=None, is_blocking=False, is_absolute=False, is_enabled=True, timeout=gTIMEOUT, is_reduced=False):
405
- if len(speed)!= 3:
405
+ if not (type(speed)==list) or len(speed)!= 3:
406
406
  speed = (speed,speed,speed)
407
+ if acceleration is None:
408
+ acceleration = (self.DEFAULT_ACCELERATION,self.DEFAULT_ACCELERATION,self.DEFAULT_ACCELERATION)
407
409
 
408
410
  # motor axis is 1,2,3,0 => X,Y,Z,T # FIXME: Hardcoded
409
411
  r = self.move_xyza(steps=(0,steps[0],steps[1],steps[2]), acceleration=(0,acceleration[0],acceleration[1],acceleration[2]), speed=(0,speed[0],speed[1],speed[2]), is_blocking=is_blocking, is_absolute=is_absolute, is_enabled=is_enabled, timeout=timeout, is_reduced=is_reduced)
@@ -490,8 +490,8 @@ class Serial:
490
490
  except Exception as e:
491
491
  if self.DEBUG:
492
492
  self._logger.error(e) # TODO: write failed: Device not configured - why?!
493
- # attempt to reconnect
494
- self.reconnect()
493
+ # attempt to reconnect # TODO: do we want that?
494
+ # self.reconnect()
495
495
  return "Failed to Send"
496
496
  self.commands[identifier]=command # FIXME: Need to clear this after the response is received
497
497
  if nResponses <= 0 or not self.is_connected or self.manufacturer=="UC2Mock":
@@ -526,7 +526,7 @@ class Serial:
526
526
  iRetry = 0
527
527
  while self.running:
528
528
  time.sleep(0.002)
529
- isTimeout = time.time()-t0>timeout
529
+ isTimeout = (time.time()-t0)>timeout
530
530
  if self.resetLastCommand or isTimeout or not self.is_connected:
531
531
  self.resetLastCommand = False
532
532
  if self.DEBUG:
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes