Skip to content

Commit 3d97395

Browse files
committed
Added cmd_nb to new classes
1 parent 5192143 commit 3d97395

File tree

3 files changed

+30
-7
lines changed

3 files changed

+30
-7
lines changed

changelog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ 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

77
## [0.2.2] [Github repo]
8+
### Fix
9+
- WS_DEVICE cmd_nb fix for cmd method
810
## [0.2.1] 2020-02-17 [Github repo]
911
### Fix
1012
- WS_DEVICE now works with esp8266 too.

setup.py

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

1414

1515
setup(name='upydevice',
16-
version='0.2.1',
16+
version='0.2.2',
1717
description='Python library to interface with wireless/serial MicroPython devices',
1818
long_description=readme(),
1919
long_description_content_type='text/markdown',

upydevice/upydevice.py

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626

2727
name = 'upydevice'
28-
version = '0.2.1'
28+
version = '0.2.2'
2929

3030

3131
class W_UPYDEVICE:
@@ -2664,14 +2664,35 @@ def get_datalog(self, dvars=None, fs=None, time_out=None, units=None):
26642664
temp_dict['u'] = units
26652665
self.datalog = temp_dict
26662666

2667+
def cmd(self, cmd, silent=False, rtn=False, ssl=False, nb_queue=None):
2668+
if not self.connected:
2669+
self.open_wconn(ssl=ssl, auth=True)
2670+
self.wr_cmd(cmd, silent=True)
2671+
if self.connected:
2672+
self.close_wconn()
2673+
self.get_output()
2674+
if not silent:
2675+
print(self.response)
2676+
if rtn:
2677+
return self.output
2678+
if nb_queue is not None:
2679+
nb_queue.put((self.output), block=False)
2680+
26672681
def cmd_nb(self, command, silent=False, rtn=True, long_string=False,
26682682
rtn_resp=False, follow=False, pipe=None, multiline=False,
26692683
dlog=False):
2670-
self.dev_process_raw = multiprocessing.Process(
2671-
target=self.wr_cmd, args=(command, silent, rtn, long_string, rtn_resp,
2672-
follow, pipe, multiline, dlog,
2673-
self.output_queue))
2674-
self.dev_process_raw.start()
2684+
# do a
2685+
if self.connected:
2686+
self.dev_process_raw = multiprocessing.Process(
2687+
target=self.wr_cmd, args=(command, silent, rtn, long_string, rtn_resp,
2688+
follow, pipe, multiline, dlog,
2689+
self.output_queue))
2690+
self.dev_process_raw.start()
2691+
else:
2692+
self.dev_process_raw = multiprocessing.Process(
2693+
target=self.cmd, args=(command, silent, False, False,
2694+
self.output_queue))
2695+
self.dev_process_raw.start()
26752696

26762697
def get_nb_opt(self):
26772698
try:

0 commit comments

Comments
 (0)