moons-motor 0.0.7__tar.gz → 0.0.9__tar.gz

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: moons_motor
3
- Version: 0.0.7
3
+ Version: 0.0.9
4
4
  Summary: This is a python library for controlling the Moons' motor through the serial port.
5
5
  Author-email: miroc <mike8503111@gmail.com>
6
6
  Project-URL: Repository, https://github.com/miroc99/moons_motor.git
@@ -22,15 +22,20 @@ Requires-Dist: requests
22
22
  This is a python library for control moons motor through serial port.
23
23
 
24
24
  ## Compatibility
25
+
25
26
  Now only support Windows.
26
27
 
27
28
  ## Installing
29
+
28
30
  Install through `pip`
31
+
29
32
  ```bash
30
33
  python -m pip install moons_motor
31
34
 
32
35
  ```
36
+
33
37
  ## Usage
38
+
34
39
  ```python
35
40
  from motor import MoonsStepper, StepperModules
36
41
  import simulate
@@ -46,7 +51,9 @@ sleep(5)
46
51
  motor.stop_jog()
47
52
 
48
53
  ```
54
+
49
55
  ## Tested Motor
56
+
50
57
  1. STM17S-3RN
51
58
 
52
59
  ## Reference
@@ -3,15 +3,20 @@
3
3
  This is a python library for control moons motor through serial port.
4
4
 
5
5
  ## Compatibility
6
+
6
7
  Now only support Windows.
7
8
 
8
9
  ## Installing
10
+
9
11
  Install through `pip`
12
+
10
13
  ```bash
11
14
  python -m pip install moons_motor
12
15
 
13
16
  ```
17
+
14
18
  ## Usage
19
+
15
20
  ```python
16
21
  from motor import MoonsStepper, StepperModules
17
22
  import simulate
@@ -27,7 +32,9 @@ sleep(5)
27
32
  motor.stop_jog()
28
33
 
29
34
  ```
35
+
30
36
  ## Tested Motor
37
+
31
38
  1. STM17S-3RN
32
39
 
33
40
  ## Reference
@@ -7,6 +7,7 @@ from rich.console import Console
7
7
  from rich.panel import Panel
8
8
  import queue
9
9
  from moons_motor.subject import Subject
10
+ import time
10
11
 
11
12
 
12
13
  class StepperModules:
@@ -146,25 +147,28 @@ class MoonsStepper(Subject):
146
147
  ports = list(list_ports.comports())
147
148
  for p in ports:
148
149
  m = re.match(
149
- r"USB\s*VID:PID=(\w+):(\w+)\s*SER=([A-Za-z0-9]+)", p.usb_info()
150
+ r"USB\s*VID:PID=(\w+):(\w+)\s*SER=([A-Za-z0-9]*)", p.usb_info()
150
151
  )
152
+ print(m, p.usb_info())
151
153
  if (
152
154
  m
153
155
  and m.group(1) == self.VID
154
156
  and m.group(2) == self.PID
155
- and m.group(3) == self.SERIAL_NUM
157
+ # and m.group(3) == self.SERIAL_NUM
156
158
  ):
157
- print(
158
- f"Device: {p.description} | VID: {m.group(1)} | PID: {m.group(2)} | SER: {m.group(3)} connected"
159
- )
160
-
161
- self.device = p.description
162
-
163
- attempt_connect(p.device, baudrate)
164
- if callback:
165
- callback(self.device, self.Opened)
159
+ print("find vid pid match")
160
+ if m.group(3) == self.SERIAL_NUM or self.SERIAL_NUM == "":
161
+ print(
162
+ f"Device: {p.description} | VID: {m.group(1)} | PID: {m.group(2)} | SER: {m.group(3)} connected"
163
+ )
164
+
165
+ self.device = p.description
166
+
167
+ attempt_connect(p.device, baudrate)
168
+ if callback:
169
+ callback(self.device, self.Opened)
170
+ break
166
171
  break
167
- break
168
172
 
169
173
  if self.only_simulate:
170
174
  self.device = "Simulate"
@@ -199,6 +203,7 @@ class MoonsStepper(Subject):
199
203
  else:
200
204
  self.usedSendQueue.put(self.temp_cmd)
201
205
  if self.ser is not None or not self.only_simulate:
206
+ self.temp_cmd += "\r"
202
207
  self.ser.write(self.temp_cmd.encode("ascii"))
203
208
  if self.is_log_message:
204
209
  print(
@@ -225,7 +230,9 @@ class MoonsStepper(Subject):
225
230
 
226
231
  def start_jog(self, motor_address="", speed=0.15, direction="CW"):
227
232
  self.send(self.addressed_cmd(motor_address, "JS{}".format(speed)))
233
+ time.sleep(0.01)
228
234
  self.send(self.addressed_cmd(motor_address, "CJ"))
235
+ # self.send(self.addressed_cmd(motor_address, "CS{}".format(speed)))
229
236
 
230
237
  def change_jog_speed(self, motor_address="", speed=0.15):
231
238
  self.send(self.addressed_cmd(motor_address, "CS{}".format(speed)))
@@ -253,11 +260,18 @@ class MoonsStepper(Subject):
253
260
 
254
261
  def calibrate(self, motor_address="", speed=0.3, onStart=None, onComplete=None):
255
262
  self.send(self.addressed_cmd(motor_address, "VE{}".format(speed)))
263
+ # time.sleep(0.01)
256
264
  self.send(self.addressed_cmd(motor_address, "DI10"))
265
+ # time.sleep(0.01)
257
266
  self.send(self.addressed_cmd(motor_address, "SH3F"))
267
+ # time.sleep(0.01)
258
268
  self.send(self.addressed_cmd(motor_address, "EP0"))
269
+ # time.sleep(0.01)
259
270
  self.send(self.addressed_cmd(motor_address, "SP0"))
260
271
 
272
+ def alarm_reset(self, motor_address=""):
273
+ self.send(self.addressed_cmd(motor_address, "AR"))
274
+
261
275
  # speed slow= 0.25, medium=1, fast=5
262
276
  def set_transmit_delay(self, motor_address="", delay=15):
263
277
  self.send(self.addressed_cmd(motor_address, "TD{}".format(delay)))
@@ -10,15 +10,18 @@ class MoonsStepperSimulate(Observer):
10
10
  moons_motor: MoonsStepper,
11
11
  universe: int = 0,
12
12
  server_address: str = "http://localhost:3001",
13
+ log_message: bool = True,
13
14
  ):
14
15
  self.server_address = server_address
15
16
  self.universe = universe
16
17
  self.moons_motor = moons_motor
17
18
  self.io = socketio.SimpleClient()
18
19
  self.connected = False
19
- self.is_log_message = True
20
+ self.log_message = True
20
21
 
21
22
  def update(self, event):
23
+ if self.log_message == False:
24
+ return
22
25
  print(f"Simulate send: {event}")
23
26
  self.emit("motor", event)
24
27
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: moons_motor
3
- Version: 0.0.7
3
+ Version: 0.0.9
4
4
  Summary: This is a python library for controlling the Moons' motor through the serial port.
5
5
  Author-email: miroc <mike8503111@gmail.com>
6
6
  Project-URL: Repository, https://github.com/miroc99/moons_motor.git
@@ -22,15 +22,20 @@ Requires-Dist: requests
22
22
  This is a python library for control moons motor through serial port.
23
23
 
24
24
  ## Compatibility
25
+
25
26
  Now only support Windows.
26
27
 
27
28
  ## Installing
29
+
28
30
  Install through `pip`
31
+
29
32
  ```bash
30
33
  python -m pip install moons_motor
31
34
 
32
35
  ```
36
+
33
37
  ## Usage
38
+
34
39
  ```python
35
40
  from motor import MoonsStepper, StepperModules
36
41
  import simulate
@@ -46,7 +51,9 @@ sleep(5)
46
51
  motor.stop_jog()
47
52
 
48
53
  ```
54
+
49
55
  ## Tested Motor
56
+
50
57
  1. STM17S-3RN
51
58
 
52
59
  ## Reference
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "moons_motor"
7
- version = "0.0.7"
7
+ version = "0.0.9"
8
8
  authors = [{ name = "miroc", email = "mike8503111@gmail.com" }]
9
9
  description = "This is a python library for controlling the Moons' motor through the serial port."
10
10
  readme = "README.md"
File without changes
File without changes
File without changes