Skip to content

Commit 5c16af1

Browse files
authored
Merge Carglglz/develop for upydevice 0.3.8 release
Merge develop branch for upydevice 0.3.8 release
2 parents f9f90ce + 743555c commit 5c16af1

16 files changed

+44
-147
lines changed

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2020 Carlos Gil Gonzalez
3+
Copyright (c) 2020 - 2022 Carlos Gil Gonzalez
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

changelog.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html)
66

7-
## [0.3.8] Unreleased Github Repo [develop]
7+
## [0.3.9] Unreleased Github Repo [develop]
8+
## [0.3.8] - 2022-08-29
9+
### Added
10+
- Device `raise_traceback` method to catch Device Exception after follow mode
811
## [0.3.7] - 2022-08-23
912
### Fix
1013
- paste_buff method in BleDevice

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ def readme():
99

1010

1111
setup(name='upydevice',
12-
version='0.3.7',
12+
version='0.3.8',
1313
description='Python library to interface with MicroPython devices',
1414
long_description=readme(),
1515
long_description_content_type='text/markdown',

upydevice/__init__.py

Lines changed: 2 additions & 128 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# MIT License
22
#
3-
# Copyright (c) 2020 Carlos Gil Gonzalez
3+
# Copyright (c) 2020 - 2022 Carlos Gil Gonzalez
44
#
55
# Permission is hereby granted, free of charge, to any person obtaining a copy
66
# of this software and associated documentation files (the "Software"), to deal
@@ -20,132 +20,6 @@
2020
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2121
# SOFTWARE.
2222

23-
"""
24-
Python lib to interface with micropython devices through WebREPL protocol or
25-
through Serial connection.
26-
27-
Example usage:
28-
29-
WIRELESS DEVICE (WebREPL)
30-
>>> from upydevice import W_UPYDEVICE
31-
# Setup and configurate a device :
32-
>>> esp32 = W_UPYDEVICE('192.168.1.56', 'mypass') # (target_ip, password)
33-
# Send command:
34-
>>> esp32.cmd('led.on()')
35-
>>> esp32.cmd("uos.listdir('/')")
36-
['boot.py', 'webrepl_cfg.py', 'main.py'] # this output is stored in [upydevice].output
37-
>>> esp32.output
38-
['boot.py', 'webrepl_cfg.py', 'main.py']
39-
>>> esp32.cmd('foo()')
40-
>>> esp32.cmd('x = [1,2,3];my_var = len(x);print(my_var)')
41-
3
42-
# Soft Reset:
43-
>>> esp32.reset()
44-
Rebooting device...
45-
46-
### closed ###
47-
48-
Done!
49-
50-
SERIAL DEVICE (Picocom, Pyserial)
51-
>>> from upydevice import S_UPYDEVICE
52-
# Setup and configurate a device :
53-
>>> esp32 = S_UPYDEVICE('/dev/tty.SLAB_USBtoUART', 1000, 115200) # defaults (serial_port, timeout=1000, baudrate=9600)
54-
# Send command:
55-
>>> esp32.cmd('led.on()')
56-
>>> esp32.cmd("uos.listdir('/')")
57-
['boot.py', 'webrepl_cfg.py', 'main.py'] # this output is stored in [upydevice].output
58-
>>> esp32.output
59-
['boot.py', 'webrepl_cfg.py', 'main.py']
60-
>>> esp32.cmd('foo()')
61-
>>> esp32.cmd('x = [1,2,3];my_var = len(x);print(my_var)')
62-
3
63-
# Soft Reset:
64-
>>> esp32.reset()
65-
Rebooting device...
66-
Done!
67-
68-
PYBOARD (Picocom, Pyserial)
69-
>>> from upydevice import PYBOARD
70-
# Setup and configurate a device :
71-
pyboard = PYBOARD('/dev/tty.usbmodem3370377430372') # defaults (serial_port, timeout=1000, baudrate=9600)
72-
# Send command:
73-
>>> pyboard.cmd('pyb.LED(1).toggle()',timeout=100)
74-
>>> pyboard.cmd("import uos;uos.listdir('/flash')")
75-
['main.py', 'pybcdc.inf', 'README.txt', 'boot.py', '.fseventsd', '.Trashes'] # this output is stored in [upydevice].output
76-
>>> pyboard.output
77-
['main.py', 'pybcdc.inf', 'README.txt', 'boot.py', '.fseventsd', '.Trashes']
78-
>>> pyboard.cmd('foo()')
79-
>>> pyboard.cmd('x = [1,2,3];my_var = len(x);print(my_var)')
80-
3
81-
# Soft Reset:
82-
>>> pyboard.reset()
83-
Rebooting pyboard...
84-
Done!
85-
86-
GROUP (to send commands to several devices at a time)
87-
# Setup and configurate the devices :
88-
>>> from upydevice import W_UPYDEVICE, PYBOARD, GROUP
89-
# PYBOARD
90-
>>> pyboard = PYBOARD('/dev/tty.usbmodem387E386731342')
91-
# ESP32
92-
>>> esp32_A = W_UPYDEVICE('192.168.1.53', 'mypass')
93-
>>> esp32_B = W_UPYDEVICE('192.168.1.40', 'mypass')
94-
95-
# Setup and configurate the group:
96-
>>> my_group = GROUP([esp32_A, esp32_B, pyboard])
97-
98-
# Each upydevice has a name attribute that can be set at creation momment or after
99-
# pyboard = PYBOARD('/dev/tty.usbmodem387E386731342', name='my_pyboard_1'); or pyboard.name = 'my_pyboard_1')
100-
# If not set an automatic name will be set as 'upydev_class'+'ip or serial port'
101-
102-
# Send command:
103-
>>> my_group.cmd('import machine;import ubinascii;ubinascii.hexlify(machine.unique_id())')
104-
Sending command to wupydev_53
105-
b'30aea4233564'
106-
107-
Sending command to wupydev_40
108-
b'807d3a809b30'
109-
110-
Sending command to pyboard_tty.usbmodem387E386731342
111-
b'33004e000351343134383038'
112-
113-
# There is an option to silent the group messages with group_silent = True, and or each device ouput with device_silent=True
114-
115-
# Output is stored in group output attribute:
116-
>>> my_group.output
117-
{'wupydev_53': b'30aea4233564', 'wupydev_40': b'807d3a809b30', 'pyboard_tty.usbmodem387E386731342': b'33004e000351343134383038'}
118-
119-
# Send command parallel mode **: (experimental mode, may not work 100% of the times, depends on the connection quality (for wireless devices))
120-
>>> my_group.cmd_p('6*12')
121-
Sending command to: wupydev_53, wupydev_40, pyboard_tty.usbmodem387E386731342
122-
72
123-
124-
125-
72
126-
127-
72
128-
129-
Done!
130-
# To see which ouput corresponds to which device use 'id=True' parameter:
131-
132-
>>> my_group.cmd_p('ubinascii.hexlify(machine.unique_id())', id=True)
133-
Sending command to: wupydev_53, wupydev_40, pyboard_tty.usbmodem387E386731342
134-
pyboard_tty.usbmodem387E386731342:b'33004e000351343134383038'
135-
pyboard_tty.usbmodem387E386731342:
136-
pyboard_tty.usbmodem387E386731342:
137-
wupydev_40:b'807d3a809b30'
138-
wupydev_53:b'30aea4233564'
139-
wupydev_40:
140-
wupydev_53:
141-
Done!
142-
>>>
143-
>>> my_group.output
144-
{'wupydev_53': b'30aea4233564', 'wupydev_40': b'807d3a809b30', 'pyboard_tty.usbmodem387E386731342': b'33004e000351343134383038'}
145-
146-
To see more info read the DOCS at the github repo.
147-
"""
148-
14923
from .upydevice import *
15024
name = 'upydevice'
151-
__version__ = '0.3.7'
25+
__version__ = '0.3.8'

upydevice/bledevice.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# MIT License
44
#
5-
# Copyright (c) 2020 Carlos Gil Gonzalez
5+
# Copyright (c) 2020 - 2022 Carlos Gil Gonzalez
66
#
77
# Permission is hereby granted, free of charge, to any person obtaining a copy
88
# of this software and associated documentation files (the "Software"), to deal
@@ -40,12 +40,12 @@
4040
from array import array
4141
import sys
4242
import traceback
43-
import multiprocessing
4443
from binascii import hexlify
4544
from .exceptions import DeviceException, DeviceNotFound
46-
from .decorators import getsource, uparser_dec
45+
from .decorators import getsource
4746
import functools
4847
from unsync import unsync
48+
import re
4949

5050

5151
_WASPDEVS = ['P8', 'PineTime', 'Pixl.js']
@@ -1286,6 +1286,12 @@ def load(self, file):
12861286
self.paste_buff(upy_content)
12871287
self.wr_cmd('\x04', follow=True)
12881288

1289+
def raise_traceback(self):
1290+
if self._traceback.decode() in self.response:
1291+
dev_traceback = re.search(r'\b(Traceback)\b', self.response)
1292+
tr_index = dev_traceback.start()
1293+
raise DeviceException(self.response[tr_index:])
1294+
12891295

12901296
class AsyncBleDevice(BLE_DEVICE):
12911297
def __init__(self, *args, **kargs):

upydevice/decorators.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env python3
22
# MIT License
33
#
4-
# Copyright (c) 2020 Carlos Gil Gonzalez
4+
# Copyright (c) 2020 - 2022 Carlos Gil Gonzalez
55
#
66
# Permission is hereby granted, free of charge, to any person obtaining a copy
77
# of this software and associated documentation files (the "Software"), to deal

upydevice/devgroup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env python3
22
# MIT License
33
#
4-
# Copyright (c) 2020 Carlos Gil Gonzalez
4+
# Copyright (c) 2020 - 2022 Carlos Gil Gonzalez
55
#
66
# Permission is hereby granted, free of charge, to any person obtaining a copy
77
# of this software and associated documentation files (the "Software"), to deal

upydevice/devtools.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# MIT License
44
#
5-
# Copyright (c) 2020 Carlos Gil Gonzalez
5+
# Copyright (c) 2020 - 2022 Carlos Gil Gonzalez
66
#
77
# Permission is hereby granted, free of charge, to any person obtaining a copy
88
# of this software and associated documentation files (the "Software"), to deal

upydevice/exceptions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# MIT License
22
#
3-
# Copyright (c) 2020 Carlos Gil Gonzalez
3+
# Copyright (c) 2020 - 2022 Carlos Gil Gonzalez
44
#
55
# Permission is hereby granted, free of charge, to any person obtaining a copy
66
# of this software and associated documentation files (the "Software"), to deal

upydevice/phantom.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env python3
22
# MIT License
33
#
4-
# Copyright (c) 2020 Carlos Gil Gonzalez
4+
# Copyright (c) 2020 - 2022 Carlos Gil Gonzalez
55
#
66
# Permission is hereby granted, free of charge, to any person obtaining a copy
77
# of this software and associated documentation files (the "Software"), to deal

0 commit comments

Comments
 (0)