UC2-REST 0.2.0.32__tar.gz → 0.2.0.33__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 (46) hide show
  1. {uc2_rest-0.2.0.32 → uc2_rest-0.2.0.33}/PKG-INFO +1 -1
  2. {uc2_rest-0.2.0.32 → uc2_rest-0.2.0.33}/UC2_REST.egg-info/PKG-INFO +1 -1
  3. {uc2_rest-0.2.0.32 → uc2_rest-0.2.0.33}/uc2rest/UC2Client.py +25 -49
  4. {uc2_rest-0.2.0.32 → uc2_rest-0.2.0.33}/uc2rest/__version__.py +1 -1
  5. uc2_rest-0.2.0.33/uc2rest/canota.py +801 -0
  6. uc2_rest-0.2.0.33/uc2rest/galvo.py +312 -0
  7. {uc2_rest-0.2.0.32 → uc2_rest-0.2.0.33}/uc2rest/home.py +44 -3
  8. {uc2_rest-0.2.0.32 → uc2_rest-0.2.0.33}/uc2rest/motor.py +1 -3
  9. {uc2_rest-0.2.0.32 → uc2_rest-0.2.0.33}/uc2rest/mserial.py +17 -44
  10. {uc2_rest-0.2.0.32 → uc2_rest-0.2.0.33}/uc2rest/rotator.py +1 -1
  11. uc2_rest-0.2.0.33/uc2rest/wifi.py +44 -0
  12. uc2_rest-0.2.0.32/uc2rest/canota.py +0 -256
  13. uc2_rest-0.2.0.32/uc2rest/galvo.py +0 -116
  14. uc2_rest-0.2.0.32/uc2rest/wifi.py +0 -98
  15. {uc2_rest-0.2.0.32 → uc2_rest-0.2.0.33}/LICENSE +0 -0
  16. {uc2_rest-0.2.0.32 → uc2_rest-0.2.0.33}/README.md +0 -0
  17. {uc2_rest-0.2.0.32 → uc2_rest-0.2.0.33}/UC2_REST.egg-info/SOURCES.txt +0 -0
  18. {uc2_rest-0.2.0.32 → uc2_rest-0.2.0.33}/UC2_REST.egg-info/dependency_links.txt +0 -0
  19. {uc2_rest-0.2.0.32 → uc2_rest-0.2.0.33}/UC2_REST.egg-info/not-zip-safe +0 -0
  20. {uc2_rest-0.2.0.32 → uc2_rest-0.2.0.33}/UC2_REST.egg-info/requires.txt +0 -0
  21. {uc2_rest-0.2.0.32 → uc2_rest-0.2.0.33}/UC2_REST.egg-info/top_level.txt +0 -0
  22. {uc2_rest-0.2.0.32 → uc2_rest-0.2.0.33}/setup.cfg +0 -0
  23. {uc2_rest-0.2.0.32 → uc2_rest-0.2.0.33}/setup.py +0 -0
  24. {uc2_rest-0.2.0.32 → uc2_rest-0.2.0.33}/uc2rest/MockSerial.py +0 -0
  25. {uc2_rest-0.2.0.32 → uc2_rest-0.2.0.33}/uc2rest/__init__.py +0 -0
  26. {uc2_rest-0.2.0.32 → uc2_rest-0.2.0.33}/uc2rest/analog.py +0 -0
  27. {uc2_rest-0.2.0.32 → uc2_rest-0.2.0.33}/uc2rest/camera.py +0 -0
  28. {uc2_rest-0.2.0.32 → uc2_rest-0.2.0.33}/uc2rest/camera_trigger.py +0 -0
  29. {uc2_rest-0.2.0.32 → uc2_rest-0.2.0.33}/uc2rest/can.py +0 -0
  30. {uc2_rest-0.2.0.32 → uc2_rest-0.2.0.33}/uc2rest/cmdrecorder.py +0 -0
  31. {uc2_rest-0.2.0.32 → uc2_rest-0.2.0.33}/uc2rest/digitalin.py +0 -0
  32. {uc2_rest-0.2.0.32 → uc2_rest-0.2.0.33}/uc2rest/digitalout.py +0 -0
  33. {uc2_rest-0.2.0.32 → uc2_rest-0.2.0.33}/uc2rest/gripper.py +0 -0
  34. {uc2_rest-0.2.0.32 → uc2_rest-0.2.0.33}/uc2rest/laser.py +0 -0
  35. {uc2_rest-0.2.0.32 → uc2_rest-0.2.0.33}/uc2rest/lcddisplay.py +0 -0
  36. {uc2_rest-0.2.0.32 → uc2_rest-0.2.0.33}/uc2rest/ledmatrix.py +0 -0
  37. {uc2_rest-0.2.0.32 → uc2_rest-0.2.0.33}/uc2rest/logger.py +0 -0
  38. {uc2_rest-0.2.0.32 → uc2_rest-0.2.0.33}/uc2rest/message.py +0 -0
  39. {uc2_rest-0.2.0.32 → uc2_rest-0.2.0.33}/uc2rest/modules.py +0 -0
  40. {uc2_rest-0.2.0.32 → uc2_rest-0.2.0.33}/uc2rest/motor_config.py +0 -0
  41. {uc2_rest-0.2.0.32 → uc2_rest-0.2.0.33}/uc2rest/objective.py +0 -0
  42. {uc2_rest-0.2.0.32 → uc2_rest-0.2.0.33}/uc2rest/pid.py +0 -0
  43. {uc2_rest-0.2.0.32 → uc2_rest-0.2.0.33}/uc2rest/slm.py +0 -0
  44. {uc2_rest-0.2.0.32 → uc2_rest-0.2.0.33}/uc2rest/state.py +0 -0
  45. {uc2_rest-0.2.0.32 → uc2_rest-0.2.0.33}/uc2rest/temperature.py +0 -0
  46. {uc2_rest-0.2.0.32 → uc2_rest-0.2.0.33}/uc2rest/utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: UC2-REST
3
- Version: 0.2.0.32
3
+ Version: 0.2.0.33
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.32
3
+ Version: 0.2.0.33
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
@@ -30,18 +30,19 @@ from .message import Message
30
30
  from .can import CAN
31
31
  from .canota import CANOTA
32
32
  from .camera_trigger import CameraTrigger
33
+
34
+ # requests is no longer used for direct ESP communication (serial-only).
35
+ # Kept as optional import for other modules that may need HTTP (e.g. firmware downloads).
33
36
  try:
34
37
  import requests
35
- except:
36
- print("No requests available - running on pyscript?")
38
+ except Exception:
39
+ requests = None
37
40
 
38
41
  class UC2Client(object):
39
- # headers = {'ESP32-version': '*'}
40
42
  headers={"Content-Type":"application/json"}
41
43
  getmessage = ""
42
44
  is_connected = False
43
45
 
44
- is_wifi = False
45
46
  is_serial = False
46
47
  BAUDRATE = 115200
47
48
 
@@ -52,12 +53,13 @@ class UC2Client(object):
52
53
  This client connects to the UC2-REST microcontroller that can be found here
53
54
  https://github.com/openUC2/UC2-REST
54
55
 
56
+ Communication is via USB/serial only.
57
+ The host/port parameters are deprecated and will be ignored.
58
+
55
59
  generally speaking you send/receive JSON documents that will cause an:
56
60
  1. action => "/XXX_act"
57
61
  2. getting => "/XXX_get"
58
62
  3. setting => "/XXX_set"
59
-
60
- you can send commands through wifi/http or usb/serial
61
63
  '''
62
64
  if True: #logger is None:
63
65
  self.logger = Logger()
@@ -67,28 +69,27 @@ class UC2Client(object):
67
69
  # perhaps we are in the browser?
68
70
  self.isPyScript = isPyScript
69
71
 
70
- # initialize communication channel (# connect to wifi or usb)
72
+ # Deprecation notice for WiFi mode
73
+ if host is not None and serialport is None and SerialManager is None:
74
+ self.logger.warning(
75
+ "WiFi/HTTP communication has been removed. "
76
+ "Please use serialport= instead. Ignoring host parameter."
77
+ )
78
+
79
+ # initialize communication channel (serial only)
71
80
  if serialport is not None:
72
81
  # use USB connection
73
82
  self.serial = Serial(serialport, baudrate, parent=self, identity=identity, DEBUG=DEBUG, skipFirmwareCheck=skipFirmwareCheck)
74
83
  self.is_serial = True
75
84
  self.is_connected = self.serial.is_connected
76
85
  self.serial.DEBUG = DEBUG
77
- elif host is not None:
78
- # use client in wireless mode
79
- self.is_wifi = True
80
- self.host = host
81
- self.port = port
82
-
83
- # check if host is up
84
- self.logger.debug(f"Connecting to microscope {self.host}:{self.port}")
85
- #self.is_connected = self.isConnected()
86
86
  elif SerialManager is not None:
87
- # we are trying to access the controller from .a web browser
87
+ # we are trying to access the controller from a web browser
88
88
  self.serial = SerialManagerWrapper(SerialManager, parent=self)
89
89
  self.isPyScript = True
90
+ self.is_serial = True
90
91
  else:
91
- self.logger.error("No ESP32 device is connected - check IP or Serial port!")
92
+ self.logger.error("No ESP32 device is connected - please provide a serialport!")
92
93
 
93
94
 
94
95
  # import libraries depending on API version
@@ -164,42 +165,17 @@ class UC2Client(object):
164
165
  self.modules = Modules(parent=self)
165
166
 
166
167
  def post_json(self, path, payload, getReturn=True, nResponses=1, timeout=1):
167
- if self.is_wifi:
168
- # FIXME: this is not working
169
- url = f"http://{self.host}:{self.port}{path}"
170
- try:
171
- if timeout==0: timeout=.2
172
- r = requests.post(url, json=payload, headers=self.headers, timeout=timeout)
173
- returnMessage = r.json()
174
- returnMessage["success"] = r.status_code==200
175
- except Exception as e:
176
- print(e)
177
- returnMessage = {}
178
- returnMessage["error"] = str(e)
179
- returnMessage["success"] = 0
180
- return returnMessage
181
- elif self.is_serial or self.isPyScript:
182
- if timeout <=0:
183
- getReturn = False
184
- return self.serial.post_json(path, payload, getReturn=getReturn, nResponses=nResponses, timeout=timeout)
185
- else:
186
- self.logger.error("No ESP32 device is connected - check IP or Serial port!")
187
- return None
168
+ if timeout <=0:
169
+ getReturn = False
170
+ return self.serial.post_json(path, payload, getReturn=getReturn, nResponses=nResponses, timeout=timeout)
188
171
 
189
172
  def get_json(self, path, getReturn=True, timeout=1):
190
- if self.is_wifi:
191
- # FIXME: this is not working
192
- url = f"http://{self.host}:{self.port}{path}"
193
- r = requests.get(url, headers=self.headers, timeout=timeout)
194
- return r.json()
195
- elif self.is_serial or self.isPyScript:
196
- # timeout is not used anymore
197
- if timeout <=0:
173
+ if self.is_serial or self.isPyScript:
174
+ if timeout <= 0:
198
175
  getReturn = False
199
176
  return self.serial.post_json(path, payload=None, getReturn=getReturn, nResponses=1, timeout=timeout)
200
- #return self.serial.read_json()<
201
177
  else:
202
- self.logger.error("No ESP32 device is connected - check IP or Serial port!")
178
+ self.logger.error("No ESP32 device is connected - serial not initialized!")
203
179
  return None
204
180
 
205
181
  def setDebugging(self, debug=False):
@@ -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.32"
9
+ __version__ = "v0.2.0.33"
10
10
  __author__ = 'Benedict Diederich'
11
11
  __author_email__ = 'benedictdied@gmail.com'
12
12
  __license__ = 'GPL v3'