smallneuron 1.0.2__tar.gz → 1.1.1__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 (29) hide show
  1. {smallneuron-1.0.2/src/smallneuron.egg-info → smallneuron-1.1.1}/PKG-INFO +1 -1
  2. {smallneuron-1.0.2 → smallneuron-1.1.1}/pyproject.toml +1 -1
  3. {smallneuron-1.0.2 → smallneuron-1.1.1}/src/smallneuron/smallneuron.py +4 -4
  4. smallneuron-1.0.2/src/smallneuron/snhttp.py → smallneuron-1.1.1/src/smallneuron/snapi.py +9 -12
  5. {smallneuron-1.0.2 → smallneuron-1.1.1}/src/smallneuron/snserial.py +29 -15
  6. {smallneuron-1.0.2 → smallneuron-1.1.1/src/smallneuron.egg-info}/PKG-INFO +1 -1
  7. {smallneuron-1.0.2 → smallneuron-1.1.1}/src/smallneuron.egg-info/SOURCES.txt +1 -1
  8. {smallneuron-1.0.2 → smallneuron-1.1.1}/.gitignore +0 -0
  9. {smallneuron-1.0.2 → smallneuron-1.1.1}/LICENSE +0 -0
  10. {smallneuron-1.0.2 → smallneuron-1.1.1}/README.md +0 -0
  11. {smallneuron-1.0.2 → smallneuron-1.1.1}/example.py +0 -0
  12. {smallneuron-1.0.2 → smallneuron-1.1.1}/setup.cfg +0 -0
  13. {smallneuron-1.0.2 → smallneuron-1.1.1}/src/smallneuron/__init__.py +0 -0
  14. {smallneuron-1.0.2 → smallneuron-1.1.1}/src/smallneuron/build +0 -0
  15. {smallneuron-1.0.2 → smallneuron-1.1.1}/src/smallneuron/gpio_h3.c +0 -0
  16. {smallneuron-1.0.2 → smallneuron-1.1.1}/src/smallneuron/gpio_h3.h +0 -0
  17. {smallneuron-1.0.2 → smallneuron-1.1.1}/src/smallneuron/gpio_h3.so +0 -0
  18. {smallneuron-1.0.2 → smallneuron-1.1.1}/src/smallneuron/logger.py +0 -0
  19. {smallneuron-1.0.2 → smallneuron-1.1.1}/src/smallneuron/sndummy.py +0 -0
  20. {smallneuron-1.0.2 → smallneuron-1.1.1}/src/smallneuron/sngpio.py +0 -0
  21. {smallneuron-1.0.2 → smallneuron-1.1.1}/src/smallneuron/sninput.py +0 -0
  22. {smallneuron-1.0.2 → smallneuron-1.1.1}/src/smallneuron/snmqtt.py +0 -0
  23. {smallneuron-1.0.2 → smallneuron-1.1.1}/src/smallneuron/sntimer.py +0 -0
  24. {smallneuron-1.0.2 → smallneuron-1.1.1}/src/smallneuron.egg-info/dependency_links.txt +0 -0
  25. {smallneuron-1.0.2 → smallneuron-1.1.1}/src/smallneuron.egg-info/top_level.txt +0 -0
  26. {smallneuron-1.0.2 → smallneuron-1.1.1}/src/smallneuron_pelainux.egg-info/PKG-INFO +0 -0
  27. {smallneuron-1.0.2 → smallneuron-1.1.1}/src/smallneuron_pelainux.egg-info/SOURCES.txt +0 -0
  28. {smallneuron-1.0.2 → smallneuron-1.1.1}/src/smallneuron_pelainux.egg-info/dependency_links.txt +0 -0
  29. {smallneuron-1.0.2 → smallneuron-1.1.1}/src/smallneuron_pelainux.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: smallneuron
3
- Version: 1.0.2
3
+ Version: 1.1.1
4
4
  Summary: Small Neuron Workflow
5
5
  Author-email: Andres Artigas <andres@artigas.cl>
6
6
  Project-URL: Homepage, https://github.com/pypa/sampleproject
@@ -3,7 +3,7 @@ requires = ["setuptools", "setuptools-scm"]
3
3
 
4
4
  [project]
5
5
  name = "smallneuron"
6
- version = "1.0.2"
6
+ version = "1.1.1"
7
7
  authors = [
8
8
  { name="Andres Artigas", email="andres@artigas.cl" },
9
9
  ]
@@ -286,7 +286,7 @@ class SnWatcher():
286
286
  self.event=event
287
287
  self.event_args=event_args
288
288
  self.event_pattern=event_pattern
289
- self.stop=False
289
+ self.stoploop=False
290
290
  self.thread=None
291
291
  log.debug("SnWatcher created")
292
292
 
@@ -299,7 +299,7 @@ class SnWatcher():
299
299
  '''
300
300
  log.debug("SnWatcher.run")
301
301
  if self.thread == None:
302
- self.stop=False
302
+ self.stoploop=False
303
303
  try:
304
304
  log.debug("SnWatcher.run Thread create")
305
305
  self.thread=threading.Thread(target=SnWatcher._check, args=(self,[bridge,bridge_args,mode, period]))
@@ -319,7 +319,7 @@ class SnWatcher():
319
319
  log.debug("SnWatcher._check loop start",args)
320
320
  try:
321
321
  [bridge,args,mode, period] = args
322
- while not self.stop:
322
+ while not self.stoploop:
323
323
  resp=bridge.check(**args)
324
324
 
325
325
  # Si la respuesta no es un dict
@@ -347,6 +347,6 @@ class SnWatcher():
347
347
  log.error(traceback.format_exc())
348
348
 
349
349
  def stop(self):
350
- self.stop=True
350
+ self.stoploop=True
351
351
  self.thread.join()
352
352
  self.thread=None
@@ -87,24 +87,21 @@ class HttpEvent (Resource):
87
87
  else:
88
88
  return None, 405
89
89
 
90
+ api.add_resource(PlannerServer, '/<string:action>','/<string:action>/<string:kart_id>') # Kart list status, and plan
91
+ api.add_resource(Order, '/order', '/order/<int:order_id>') # POST New order, GET Order status ,DELETE Order , '/order/<int:order_id>', endpoint="order_id"
92
+ api.add_resource(Task, '/task/<int:task_id>') # End task
93
+ api.add_resource(Kart, '/kart/<string:kart_id>', '/kart/<string:component>/<string:code>') # Checkin and send event
90
94
 
91
95
  class SnHttp(Flask):
92
96
  def __init__(self):
93
97
  super().__init__(__name__)
94
98
  self.app = Flask(__name__)
95
99
  self.api = Api(self.app)
100
+
101
+ def add_resource(self, resource, *urls, **kwargs):
102
+ self.api.add_resource(resource, urls, kwargs)
96
103
 
97
- def addEvent(self, event_name, path):
98
- self.api.add_resource(HttpEvent, path )
99
-
100
- def start(self):
104
+ def start(self, service_port=9000):
101
105
  self.app.config['MAX_CONTENT_LENGTH'] = 1024 * 1024 * 1024
102
- self.app.run(debug=False, host= '0.0.0.0')
103
-
106
+ self.app.run(debug=False, host= '0.0.0.0', port=service_port)
104
107
 
105
- if __name__ == '__main__':
106
- except KeyboardInterrupt:
107
- pass
108
- finally:
109
- pass
110
- #stopAllKarts()
@@ -6,6 +6,7 @@
6
6
  # pip install pyserial
7
7
  #
8
8
  import serial
9
+ import time
9
10
  import re
10
11
  import threading
11
12
  import os.path
@@ -17,33 +18,45 @@ log=Logger("smallneuron.SnSerial")
17
18
  def eventWait(snserial):
18
19
  try:
19
20
  log.info("reader started")
21
+ fails=0
20
22
  while True:
21
- line = snserial.read_until(snserial.eol)
22
-
23
- for e in snserial.events:
24
- if re.search(e[1], line) != None:
25
- if snserial.eventManager == None:
26
- log.error("Warning eventManager not defined")
27
- else:
28
- snserial.eventManager.putEvent(e[0], {"data": str(line)})
29
- log.info("event ", e[0], line)
30
- break
23
+ try:
24
+ line = snserial.read_until(snserial.eol)
25
+ fails=0
26
+ for e in snserial.events:
27
+ if re.search(e[1], line) != None:
28
+ if snserial.eventManager == None:
29
+ log.error("Warning eventManager not defined")
30
+ else:
31
+ snserial.eventManager.putEvent(e[0], {"data": str(line)})
32
+ log.info("event ", e[0], line)
33
+ break
34
+ except Exception as e:
35
+ fails=fails+1
36
+ if fails > 10:
37
+ raise("Falla multiples veces lectura serial "+str(fails))
38
+ log.error("Reintentamos lectura "+str(e) )
39
+ time.sleep(1)
40
+ snserial.close()
41
+ snserial.rotateOpen()
42
+
31
43
  except Exception as e:
32
44
  log.error(e)
33
45
  log.error(traceback.format_exc())
34
46
  snserial.eventManager.putEvent("panic", str(e))
35
- exit(1)
47
+
36
48
 
37
49
 
38
50
  class SnSerial(serial.Serial):
39
51
  def __init__(self, eventManager, port, baudrate, bytesize, parity, stopbits, endofline: bytes = b"\r"):
40
52
  super().__init__(baudrate=baudrate, bytesize=bytesize, parity=parity, stopbits=stopbits)
41
- self.rotateOpen(port=port)
53
+ self.originalPort=port
54
+ self.rotateOpen()
42
55
  self.eventManager = eventManager
43
56
  self.eol = endofline
44
57
  self.events = []
45
58
  log.info("start")
46
-
59
+
47
60
  def addEvent(self, event, pattern=".*"):
48
61
  self.events.append((event, pattern))
49
62
 
@@ -60,12 +73,13 @@ class SnSerial(serial.Serial):
60
73
  threading.Thread(target=lambda: eventWait(self)).start()
61
74
 
62
75
  # Intentara abrir la puerta termina con 0 (cero) y falla lo cambiara el final por 1 (uno)
63
- def rotateOpen(self, port):
76
+ def rotateOpen(self):
77
+ port=self.originalPort
64
78
  if not os.path.exists(port):
65
79
  port=port[:-1]+"1"
66
80
  log.debug("snserial port not exist, trying ",port)
67
81
  self.port=port # al parecer esto abre el puerto
68
- self.open() # pero para estar seguro
82
+ self.open() # pero para estar seguro
69
83
  log.debug("snserial port:", port)
70
84
 
71
85
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: smallneuron
3
- Version: 1.0.2
3
+ Version: 1.1.1
4
4
  Summary: Small Neuron Workflow
5
5
  Author-email: Andres Artigas <andres@artigas.cl>
6
6
  Project-URL: Homepage, https://github.com/pypa/sampleproject
@@ -10,9 +10,9 @@ src/smallneuron/gpio_h3.h
10
10
  src/smallneuron/gpio_h3.so
11
11
  src/smallneuron/logger.py
12
12
  src/smallneuron/smallneuron.py
13
+ src/smallneuron/snapi.py
13
14
  src/smallneuron/sndummy.py
14
15
  src/smallneuron/sngpio.py
15
- src/smallneuron/snhttp.py
16
16
  src/smallneuron/sninput.py
17
17
  src/smallneuron/snmqtt.py
18
18
  src/smallneuron/snserial.py
File without changes
File without changes
File without changes
File without changes
File without changes