|
1 <!DOCTYPE html> |
|
2 <html><head> |
|
3 <title>eric7.MicroPython.MicroPythonSerialDeviceInterface</title> |
|
4 <meta charset="UTF-8"> |
|
5 <link rel="stylesheet" href="styles.css"> |
|
6 </head> |
|
7 <body> |
|
8 <a NAME="top" ID="top"></a> |
|
9 <h1>eric7.MicroPython.MicroPythonSerialDeviceInterface</h1> |
|
10 |
|
11 <p> |
|
12 Module implementing an interface to talk to a connected MicroPython device via |
|
13 a serial link. |
|
14 </p> |
|
15 <h3>Global Attributes</h3> |
|
16 |
|
17 <table> |
|
18 <tr><td>None</td></tr> |
|
19 </table> |
|
20 <h3>Classes</h3> |
|
21 |
|
22 <table> |
|
23 |
|
24 <tr> |
|
25 <td><a href="#MicroPythonSerialDeviceInterface">MicroPythonSerialDeviceInterface</a></td> |
|
26 <td>Class implementing an interface to talk to a connected MicroPython device via a serial link.</td> |
|
27 </tr> |
|
28 </table> |
|
29 <h3>Functions</h3> |
|
30 |
|
31 <table> |
|
32 <tr><td>None</td></tr> |
|
33 </table> |
|
34 <hr /> |
|
35 <hr /> |
|
36 <a NAME="MicroPythonSerialDeviceInterface" ID="MicroPythonSerialDeviceInterface"></a> |
|
37 <h2>MicroPythonSerialDeviceInterface</h2> |
|
38 |
|
39 <p> |
|
40 Class implementing an interface to talk to a connected MicroPython device via |
|
41 a serial link. |
|
42 </p> |
|
43 <h3>Derived from</h3> |
|
44 MicroPythonDeviceInterface |
|
45 <h3>Class Attributes</h3> |
|
46 |
|
47 <table> |
|
48 <tr><td>PasteModePrompt</td></tr><tr><td>TracebackMarker</td></tr> |
|
49 </table> |
|
50 <h3>Class Methods</h3> |
|
51 |
|
52 <table> |
|
53 <tr><td>None</td></tr> |
|
54 </table> |
|
55 <h3>Methods</h3> |
|
56 |
|
57 <table> |
|
58 |
|
59 <tr> |
|
60 <td><a href="#MicroPythonSerialDeviceInterface.__init__">MicroPythonSerialDeviceInterface</a></td> |
|
61 <td>Constructor</td> |
|
62 </tr> |
|
63 <tr> |
|
64 <td><a href="#MicroPythonSerialDeviceInterface.__executeAsyncPaste">__executeAsyncPaste</a></td> |
|
65 <td>Private method to execute a series of commands over a period of time without returning any result (asynchronous execution).</td> |
|
66 </tr> |
|
67 <tr> |
|
68 <td><a href="#MicroPythonSerialDeviceInterface.__executeAsyncRaw">__executeAsyncRaw</a></td> |
|
69 <td>Private method to execute a series of commands over a period of time without returning any result (asynchronous execution).</td> |
|
70 </tr> |
|
71 <tr> |
|
72 <td><a href="#MicroPythonSerialDeviceInterface.__execute_paste">__execute_paste</a></td> |
|
73 <td>Private method to send commands to the connected device using 'paste' mode and return the result.</td> |
|
74 </tr> |
|
75 <tr> |
|
76 <td><a href="#MicroPythonSerialDeviceInterface.__execute_raw">__execute_raw</a></td> |
|
77 <td>Private method to send commands to the connected device using 'raw REPL' mode and return the result.</td> |
|
78 </tr> |
|
79 <tr> |
|
80 <td><a href="#MicroPythonSerialDeviceInterface.__pasteOff">__pasteOff</a></td> |
|
81 <td>Private method to switch 'paste' mode off.</td> |
|
82 </tr> |
|
83 <tr> |
|
84 <td><a href="#MicroPythonSerialDeviceInterface.__pasteOn">__pasteOn</a></td> |
|
85 <td>Private method to switch the connected device to 'paste' mode.</td> |
|
86 </tr> |
|
87 <tr> |
|
88 <td><a href="#MicroPythonSerialDeviceInterface.__rawOff">__rawOff</a></td> |
|
89 <td>Private method to switch 'raw' mode off.</td> |
|
90 </tr> |
|
91 <tr> |
|
92 <td><a href="#MicroPythonSerialDeviceInterface.__rawOn">__rawOn</a></td> |
|
93 <td>Private method to switch the connected device to 'raw' mode.</td> |
|
94 </tr> |
|
95 <tr> |
|
96 <td><a href="#MicroPythonSerialDeviceInterface.__readSerial">__readSerial</a></td> |
|
97 <td>Private slot to read all available serial data and emit it with the "dataReceived" signal for further processing.</td> |
|
98 </tr> |
|
99 <tr> |
|
100 <td><a href="#MicroPythonSerialDeviceInterface.connectToDevice">connectToDevice</a></td> |
|
101 <td>Public slot to connect to the device.</td> |
|
102 </tr> |
|
103 <tr> |
|
104 <td><a href="#MicroPythonSerialDeviceInterface.disconnectFromDevice">disconnectFromDevice</a></td> |
|
105 <td>Public slot to disconnect from the device.</td> |
|
106 </tr> |
|
107 <tr> |
|
108 <td><a href="#MicroPythonSerialDeviceInterface.execute">execute</a></td> |
|
109 <td>Public method to send commands to the connected device and return the result.</td> |
|
110 </tr> |
|
111 <tr> |
|
112 <td><a href="#MicroPythonSerialDeviceInterface.executeAsync">executeAsync</a></td> |
|
113 <td>Public method to execute a series of commands over a period of time without returning any result (asynchronous execution).</td> |
|
114 </tr> |
|
115 <tr> |
|
116 <td><a href="#MicroPythonSerialDeviceInterface.handlePreferencesChanged">handlePreferencesChanged</a></td> |
|
117 <td>Public slot to handle a change of the preferences.</td> |
|
118 </tr> |
|
119 <tr> |
|
120 <td><a href="#MicroPythonSerialDeviceInterface.isConnected">isConnected</a></td> |
|
121 <td>Public method to get the connection status.</td> |
|
122 </tr> |
|
123 <tr> |
|
124 <td><a href="#MicroPythonSerialDeviceInterface.probeDevice">probeDevice</a></td> |
|
125 <td>Public method to check the device is responding.</td> |
|
126 </tr> |
|
127 <tr> |
|
128 <td><a href="#MicroPythonSerialDeviceInterface.write">write</a></td> |
|
129 <td>Public method to write data to the connected device.</td> |
|
130 </tr> |
|
131 </table> |
|
132 <h3>Static Methods</h3> |
|
133 |
|
134 <table> |
|
135 <tr><td>None</td></tr> |
|
136 </table> |
|
137 |
|
138 <a NAME="MicroPythonSerialDeviceInterface.__init__" ID="MicroPythonSerialDeviceInterface.__init__"></a> |
|
139 <h4>MicroPythonSerialDeviceInterface (Constructor)</h4> |
|
140 <b>MicroPythonSerialDeviceInterface</b>(<i>parent=None</i>) |
|
141 |
|
142 <p> |
|
143 Constructor |
|
144 </p> |
|
145 <dl> |
|
146 |
|
147 <dt><i>parent</i> (QObject)</dt> |
|
148 <dd> |
|
149 reference to the parent object |
|
150 </dd> |
|
151 </dl> |
|
152 <a NAME="MicroPythonSerialDeviceInterface.__executeAsyncPaste" ID="MicroPythonSerialDeviceInterface.__executeAsyncPaste"></a> |
|
153 <h4>MicroPythonSerialDeviceInterface.__executeAsyncPaste</h4> |
|
154 <b>__executeAsyncPaste</b>(<i>commandsList</i>) |
|
155 |
|
156 <p> |
|
157 Private method to execute a series of commands over a period of time |
|
158 without returning any result (asynchronous execution). |
|
159 </p> |
|
160 <dl> |
|
161 |
|
162 <dt><i>commandsList</i> (list of str)</dt> |
|
163 <dd> |
|
164 list of commands to be execute on the device |
|
165 </dd> |
|
166 </dl> |
|
167 <a NAME="MicroPythonSerialDeviceInterface.__executeAsyncRaw" ID="MicroPythonSerialDeviceInterface.__executeAsyncRaw"></a> |
|
168 <h4>MicroPythonSerialDeviceInterface.__executeAsyncRaw</h4> |
|
169 <b>__executeAsyncRaw</b>(<i>commandsList</i>) |
|
170 |
|
171 <p> |
|
172 Private method to execute a series of commands over a period of time |
|
173 without returning any result (asynchronous execution). |
|
174 </p> |
|
175 <dl> |
|
176 |
|
177 <dt><i>commandsList</i> (list of bytes)</dt> |
|
178 <dd> |
|
179 list of commands to be execute on the device |
|
180 </dd> |
|
181 </dl> |
|
182 <a NAME="MicroPythonSerialDeviceInterface.__execute_paste" ID="MicroPythonSerialDeviceInterface.__execute_paste"></a> |
|
183 <h4>MicroPythonSerialDeviceInterface.__execute_paste</h4> |
|
184 <b>__execute_paste</b>(<i>commands, timeout=0</i>) |
|
185 |
|
186 <p> |
|
187 Private method to send commands to the connected device using 'paste' mode |
|
188 and return the result. |
|
189 </p> |
|
190 <p> |
|
191 If no serial connection is available, empty results will be returned. |
|
192 </p> |
|
193 <dl> |
|
194 |
|
195 <dt><i>commands</i> (str or list of str)</dt> |
|
196 <dd> |
|
197 list of commands to be executed |
|
198 </dd> |
|
199 <dt><i>timeout</i> (int (optional))</dt> |
|
200 <dd> |
|
201 per command timeout in milliseconds (0 for configured default) |
|
202 (defaults to 0) |
|
203 </dd> |
|
204 </dl> |
|
205 <dl> |
|
206 <dt>Return:</dt> |
|
207 <dd> |
|
208 tuple containing stdout and stderr output of the device |
|
209 </dd> |
|
210 </dl> |
|
211 <dl> |
|
212 <dt>Return Type:</dt> |
|
213 <dd> |
|
214 tuple of (bytes, bytes) |
|
215 </dd> |
|
216 </dl> |
|
217 <a NAME="MicroPythonSerialDeviceInterface.__execute_raw" ID="MicroPythonSerialDeviceInterface.__execute_raw"></a> |
|
218 <h4>MicroPythonSerialDeviceInterface.__execute_raw</h4> |
|
219 <b>__execute_raw</b>(<i>commands, timeout=0</i>) |
|
220 |
|
221 <p> |
|
222 Private method to send commands to the connected device using 'raw REPL' mode |
|
223 and return the result. |
|
224 </p> |
|
225 <p> |
|
226 If no serial connection is available, empty results will be returned. |
|
227 </p> |
|
228 <dl> |
|
229 |
|
230 <dt><i>commands</i> (str or list of str)</dt> |
|
231 <dd> |
|
232 list of commands to be executed |
|
233 </dd> |
|
234 <dt><i>timeout</i> (int (optional))</dt> |
|
235 <dd> |
|
236 per command timeout in milliseconds (0 for configured default) |
|
237 (defaults to 0) |
|
238 </dd> |
|
239 </dl> |
|
240 <dl> |
|
241 <dt>Return:</dt> |
|
242 <dd> |
|
243 tuple containing stdout and stderr output of the device |
|
244 </dd> |
|
245 </dl> |
|
246 <dl> |
|
247 <dt>Return Type:</dt> |
|
248 <dd> |
|
249 tuple of (bytes, bytes) |
|
250 </dd> |
|
251 </dl> |
|
252 <a NAME="MicroPythonSerialDeviceInterface.__pasteOff" ID="MicroPythonSerialDeviceInterface.__pasteOff"></a> |
|
253 <h4>MicroPythonSerialDeviceInterface.__pasteOff</h4> |
|
254 <b>__pasteOff</b>(<i></i>) |
|
255 |
|
256 <p> |
|
257 Private method to switch 'paste' mode off. |
|
258 </p> |
|
259 <a NAME="MicroPythonSerialDeviceInterface.__pasteOn" ID="MicroPythonSerialDeviceInterface.__pasteOn"></a> |
|
260 <h4>MicroPythonSerialDeviceInterface.__pasteOn</h4> |
|
261 <b>__pasteOn</b>(<i></i>) |
|
262 |
|
263 <p> |
|
264 Private method to switch the connected device to 'paste' mode. |
|
265 </p> |
|
266 <p> |
|
267 Note: switching to paste mode is done with synchronous writes. |
|
268 </p> |
|
269 <dl> |
|
270 <dt>Return:</dt> |
|
271 <dd> |
|
272 flag indicating success |
|
273 </dd> |
|
274 </dl> |
|
275 <dl> |
|
276 <dt>Return Type:</dt> |
|
277 <dd> |
|
278 bool |
|
279 </dd> |
|
280 </dl> |
|
281 <a NAME="MicroPythonSerialDeviceInterface.__rawOff" ID="MicroPythonSerialDeviceInterface.__rawOff"></a> |
|
282 <h4>MicroPythonSerialDeviceInterface.__rawOff</h4> |
|
283 <b>__rawOff</b>(<i></i>) |
|
284 |
|
285 <p> |
|
286 Private method to switch 'raw' mode off. |
|
287 </p> |
|
288 <a NAME="MicroPythonSerialDeviceInterface.__rawOn" ID="MicroPythonSerialDeviceInterface.__rawOn"></a> |
|
289 <h4>MicroPythonSerialDeviceInterface.__rawOn</h4> |
|
290 <b>__rawOn</b>(<i></i>) |
|
291 |
|
292 <p> |
|
293 Private method to switch the connected device to 'raw' mode. |
|
294 </p> |
|
295 <p> |
|
296 Note: switching to raw mode is done with synchronous writes. |
|
297 </p> |
|
298 <dl> |
|
299 <dt>Return:</dt> |
|
300 <dd> |
|
301 flag indicating success |
|
302 </dd> |
|
303 </dl> |
|
304 <dl> |
|
305 <dt>Return Type:</dt> |
|
306 <dd> |
|
307 bool |
|
308 </dd> |
|
309 </dl> |
|
310 <a NAME="MicroPythonSerialDeviceInterface.__readSerial" ID="MicroPythonSerialDeviceInterface.__readSerial"></a> |
|
311 <h4>MicroPythonSerialDeviceInterface.__readSerial</h4> |
|
312 <b>__readSerial</b>(<i></i>) |
|
313 |
|
314 <p> |
|
315 Private slot to read all available serial data and emit it with the |
|
316 "dataReceived" signal for further processing. |
|
317 </p> |
|
318 <a NAME="MicroPythonSerialDeviceInterface.connectToDevice" ID="MicroPythonSerialDeviceInterface.connectToDevice"></a> |
|
319 <h4>MicroPythonSerialDeviceInterface.connectToDevice</h4> |
|
320 <b>connectToDevice</b>(<i>connection</i>) |
|
321 |
|
322 <p> |
|
323 Public slot to connect to the device. |
|
324 </p> |
|
325 <dl> |
|
326 |
|
327 <dt><i>connection</i> (str)</dt> |
|
328 <dd> |
|
329 name of the connection to be used |
|
330 </dd> |
|
331 </dl> |
|
332 <dl> |
|
333 <dt>Return:</dt> |
|
334 <dd> |
|
335 flag indicating success |
|
336 </dd> |
|
337 </dl> |
|
338 <dl> |
|
339 <dt>Return Type:</dt> |
|
340 <dd> |
|
341 bool |
|
342 </dd> |
|
343 </dl> |
|
344 <a NAME="MicroPythonSerialDeviceInterface.disconnectFromDevice" ID="MicroPythonSerialDeviceInterface.disconnectFromDevice"></a> |
|
345 <h4>MicroPythonSerialDeviceInterface.disconnectFromDevice</h4> |
|
346 <b>disconnectFromDevice</b>(<i></i>) |
|
347 |
|
348 <p> |
|
349 Public slot to disconnect from the device. |
|
350 </p> |
|
351 <a NAME="MicroPythonSerialDeviceInterface.execute" ID="MicroPythonSerialDeviceInterface.execute"></a> |
|
352 <h4>MicroPythonSerialDeviceInterface.execute</h4> |
|
353 <b>execute</b>(<i>commands, *, mode="raw", timeout=0</i>) |
|
354 |
|
355 <p> |
|
356 Public method to send commands to the connected device and return the |
|
357 result. |
|
358 </p> |
|
359 <p> |
|
360 If no serial connection is available, empty results will be returned. |
|
361 </p> |
|
362 <dl> |
|
363 |
|
364 <dt><i>commands</i> (str or list of str)</dt> |
|
365 <dd> |
|
366 list of commands to be executed |
|
367 </dd> |
|
368 <dt><i>mode=</i> (str)</dt> |
|
369 <dd> |
|
370 submit mode to be used (one of 'raw' or 'paste') (defaults to |
|
371 'raw') |
|
372 </dd> |
|
373 <dt><i>timeout=</i> (int (optional))</dt> |
|
374 <dd> |
|
375 per command timeout in milliseconds (0 for configured default) |
|
376 (defaults to 0) |
|
377 </dd> |
|
378 </dl> |
|
379 <dl> |
|
380 <dt>Return:</dt> |
|
381 <dd> |
|
382 tuple containing stdout and stderr output of the device |
|
383 </dd> |
|
384 </dl> |
|
385 <dl> |
|
386 <dt>Return Type:</dt> |
|
387 <dd> |
|
388 tuple of (bytes, bytes) |
|
389 </dd> |
|
390 </dl> |
|
391 <dl> |
|
392 |
|
393 <dt>Raises <b>ValueError</b>:</dt> |
|
394 <dd> |
|
395 raised in case of an unsupported submit mode |
|
396 </dd> |
|
397 </dl> |
|
398 <a NAME="MicroPythonSerialDeviceInterface.executeAsync" ID="MicroPythonSerialDeviceInterface.executeAsync"></a> |
|
399 <h4>MicroPythonSerialDeviceInterface.executeAsync</h4> |
|
400 <b>executeAsync</b>(<i>commandsList, submitMode</i>) |
|
401 |
|
402 <p> |
|
403 Public method to execute a series of commands over a period of time |
|
404 without returning any result (asynchronous execution). |
|
405 </p> |
|
406 <dl> |
|
407 |
|
408 <dt><i>commandsList</i> (list of str)</dt> |
|
409 <dd> |
|
410 list of commands to be execute on the device |
|
411 </dd> |
|
412 <dt><i>submitMode</i> (str (one of 'raw' or 'paste'))</dt> |
|
413 <dd> |
|
414 mode to be used to submit the commands |
|
415 </dd> |
|
416 </dl> |
|
417 <dl> |
|
418 |
|
419 <dt>Raises <b>ValueError</b>:</dt> |
|
420 <dd> |
|
421 raised to indicate an unknown submit mode |
|
422 </dd> |
|
423 </dl> |
|
424 <a NAME="MicroPythonSerialDeviceInterface.handlePreferencesChanged" ID="MicroPythonSerialDeviceInterface.handlePreferencesChanged"></a> |
|
425 <h4>MicroPythonSerialDeviceInterface.handlePreferencesChanged</h4> |
|
426 <b>handlePreferencesChanged</b>(<i></i>) |
|
427 |
|
428 <p> |
|
429 Public slot to handle a change of the preferences. |
|
430 </p> |
|
431 <a NAME="MicroPythonSerialDeviceInterface.isConnected" ID="MicroPythonSerialDeviceInterface.isConnected"></a> |
|
432 <h4>MicroPythonSerialDeviceInterface.isConnected</h4> |
|
433 <b>isConnected</b>(<i></i>) |
|
434 |
|
435 <p> |
|
436 Public method to get the connection status. |
|
437 </p> |
|
438 <dl> |
|
439 <dt>Return:</dt> |
|
440 <dd> |
|
441 flag indicating the connection status |
|
442 </dd> |
|
443 </dl> |
|
444 <dl> |
|
445 <dt>Return Type:</dt> |
|
446 <dd> |
|
447 bool |
|
448 </dd> |
|
449 </dl> |
|
450 <a NAME="MicroPythonSerialDeviceInterface.probeDevice" ID="MicroPythonSerialDeviceInterface.probeDevice"></a> |
|
451 <h4>MicroPythonSerialDeviceInterface.probeDevice</h4> |
|
452 <b>probeDevice</b>(<i></i>) |
|
453 |
|
454 <p> |
|
455 Public method to check the device is responding. |
|
456 </p> |
|
457 <p> |
|
458 If the device has not been flashed with a MicroPython firmware, the |
|
459 probe will fail. |
|
460 </p> |
|
461 <dl> |
|
462 <dt>Return:</dt> |
|
463 <dd> |
|
464 flag indicating a communicating MicroPython device |
|
465 </dd> |
|
466 </dl> |
|
467 <dl> |
|
468 <dt>Return Type:</dt> |
|
469 <dd> |
|
470 bool |
|
471 </dd> |
|
472 </dl> |
|
473 <a NAME="MicroPythonSerialDeviceInterface.write" ID="MicroPythonSerialDeviceInterface.write"></a> |
|
474 <h4>MicroPythonSerialDeviceInterface.write</h4> |
|
475 <b>write</b>(<i>data</i>) |
|
476 |
|
477 <p> |
|
478 Public method to write data to the connected device. |
|
479 </p> |
|
480 <dl> |
|
481 |
|
482 <dt><i>data</i> (bytes or bytearray)</dt> |
|
483 <dd> |
|
484 data to be written |
|
485 </dd> |
|
486 </dl> |
|
487 <div align="right"><a href="#top">Up</a></div> |
|
488 <hr /> |
|
489 </body></html> |