|
1 <!DOCTYPE html> |
|
2 <html><head> |
|
3 <title>eric7.MicroPython.MicroPythonDeviceInterface</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.MicroPythonDeviceInterface</h1> |
|
10 |
|
11 <p> |
|
12 Module implementing some file system commands for MicroPython. |
|
13 </p> |
|
14 <h3>Global Attributes</h3> |
|
15 |
|
16 <table> |
|
17 <tr><td>None</td></tr> |
|
18 </table> |
|
19 <h3>Classes</h3> |
|
20 |
|
21 <table> |
|
22 |
|
23 <tr> |
|
24 <td><a href="#MicroPythonDeviceInterface">MicroPythonDeviceInterface</a></td> |
|
25 <td>Class implementing some file system commands for MicroPython.</td> |
|
26 </tr> |
|
27 </table> |
|
28 <h3>Functions</h3> |
|
29 |
|
30 <table> |
|
31 <tr><td>None</td></tr> |
|
32 </table> |
|
33 <hr /> |
|
34 <hr /> |
|
35 <a NAME="MicroPythonDeviceInterface" ID="MicroPythonDeviceInterface"></a> |
|
36 <h2>MicroPythonDeviceInterface</h2> |
|
37 |
|
38 <p> |
|
39 Class implementing some file system commands for MicroPython. |
|
40 </p> |
|
41 <p> |
|
42 Commands are provided to perform operations on the file system of a |
|
43 connected MicroPython device. Supported commands are: |
|
44 <ul> |
|
45 <li>ls: directory listing</li> |
|
46 <li>lls: directory listing with meta data</li> |
|
47 <li>cd: change directory</li> |
|
48 <li>pwd: get the current directory</li> |
|
49 <li>put: copy a file to the connected device</li> |
|
50 <li>putData: write data to a file of the connected device</li> |
|
51 <li>get: get a file from the connected device</li> |
|
52 <li>getData: read data of a file of the connected device</li> |
|
53 <li>rm: remove a file from the connected device</li> |
|
54 <li>rmrf: remove a file/directory recursively (like 'rm -rf' in bash) |
|
55 <li>mkdir: create a new directory</li> |
|
56 <li>rmdir: remove an empty directory</li> |
|
57 <li>fileSystemInfo: get information about the file system |
|
58 </ul> |
|
59 </p> |
|
60 <p> |
|
61 There are additional non file systemcommands. |
|
62 <ul> |
|
63 <li>getBoardData: get information about the connected board</li> |
|
64 <li>getDeviceData: get version info about MicroPython and some implementation |
|
65 information</li> |
|
66 <li>getModules: get a list of built-in modules</li> |
|
67 <li>getTime: get the current time</li> |
|
68 <li>syncTime: synchronize the time of the connected device</li> |
|
69 <li>showTime: show the current time of the connected device</li> |
|
70 </ul> |
|
71 </p> |
|
72 <h3>Signals</h3> |
|
73 <dl> |
|
74 |
|
75 <dt>dataReceived(data)</dt> |
|
76 <dd> |
|
77 emitted to send data received via the serial |
|
78 connection for further processing |
|
79 </dd> |
|
80 <dt>executeAsyncFinished()</dt> |
|
81 <dd> |
|
82 emitted to indicate the end of an |
|
83 asynchronously executed list of commands (e.g. a script) |
|
84 </dd> |
|
85 </dl> |
|
86 <h3>Derived from</h3> |
|
87 QObject |
|
88 <h3>Class Attributes</h3> |
|
89 |
|
90 <table> |
|
91 <tr><td>None</td></tr> |
|
92 </table> |
|
93 <h3>Class Methods</h3> |
|
94 |
|
95 <table> |
|
96 <tr><td>None</td></tr> |
|
97 </table> |
|
98 <h3>Methods</h3> |
|
99 |
|
100 <table> |
|
101 |
|
102 <tr> |
|
103 <td><a href="#MicroPythonDeviceInterface.__init__">MicroPythonDeviceInterface</a></td> |
|
104 <td>Constructor</td> |
|
105 </tr> |
|
106 <tr> |
|
107 <td><a href="#MicroPythonDeviceInterface.__rawOff">__rawOff</a></td> |
|
108 <td>Private method to switch 'raw' mode off.</td> |
|
109 </tr> |
|
110 <tr> |
|
111 <td><a href="#MicroPythonDeviceInterface.__rawOn">__rawOn</a></td> |
|
112 <td>Private method to switch the connected device to 'raw' mode.</td> |
|
113 </tr> |
|
114 <tr> |
|
115 <td><a href="#MicroPythonDeviceInterface.__readSerial">__readSerial</a></td> |
|
116 <td>Private slot to read all available serial data and emit it with the "dataReceived" signal for further processing.</td> |
|
117 </tr> |
|
118 <tr> |
|
119 <td><a href="#MicroPythonDeviceInterface.connectToDevice">connectToDevice</a></td> |
|
120 <td>Public slot to start the manager.</td> |
|
121 </tr> |
|
122 <tr> |
|
123 <td><a href="#MicroPythonDeviceInterface.disconnectFromDevice">disconnectFromDevice</a></td> |
|
124 <td>Public slot to stop the thread.</td> |
|
125 </tr> |
|
126 <tr> |
|
127 <td><a href="#MicroPythonDeviceInterface.execute">execute</a></td> |
|
128 <td>Public method to send commands to the connected device and return the result.</td> |
|
129 </tr> |
|
130 <tr> |
|
131 <td><a href="#MicroPythonDeviceInterface.executeAsync">executeAsync</a></td> |
|
132 <td>Public method to execute a series of commands over a period of time without returning any result (asynchronous execution).</td> |
|
133 </tr> |
|
134 <tr> |
|
135 <td><a href="#MicroPythonDeviceInterface.handlePreferencesChanged">handlePreferencesChanged</a></td> |
|
136 <td>Public slot to handle a change of the preferences.</td> |
|
137 </tr> |
|
138 <tr> |
|
139 <td><a href="#MicroPythonDeviceInterface.isConnected">isConnected</a></td> |
|
140 <td>Public method to get the connection status.</td> |
|
141 </tr> |
|
142 <tr> |
|
143 <td><a href="#MicroPythonDeviceInterface.probeDevice">probeDevice</a></td> |
|
144 <td>Public method to check the device is responding.</td> |
|
145 </tr> |
|
146 <tr> |
|
147 <td><a href="#MicroPythonDeviceInterface.write">write</a></td> |
|
148 <td>Public method to write data to the connected device.</td> |
|
149 </tr> |
|
150 </table> |
|
151 <h3>Static Methods</h3> |
|
152 |
|
153 <table> |
|
154 <tr><td>None</td></tr> |
|
155 </table> |
|
156 |
|
157 <a NAME="MicroPythonDeviceInterface.__init__" ID="MicroPythonDeviceInterface.__init__"></a> |
|
158 <h4>MicroPythonDeviceInterface (Constructor)</h4> |
|
159 <b>MicroPythonDeviceInterface</b>(<i>parent=None</i>) |
|
160 |
|
161 <p> |
|
162 Constructor |
|
163 </p> |
|
164 <dl> |
|
165 |
|
166 <dt><i>parent</i> (QObject)</dt> |
|
167 <dd> |
|
168 reference to the parent object |
|
169 </dd> |
|
170 </dl> |
|
171 <a NAME="MicroPythonDeviceInterface.__rawOff" ID="MicroPythonDeviceInterface.__rawOff"></a> |
|
172 <h4>MicroPythonDeviceInterface.__rawOff</h4> |
|
173 <b>__rawOff</b>(<i></i>) |
|
174 |
|
175 <p> |
|
176 Private method to switch 'raw' mode off. |
|
177 </p> |
|
178 <a NAME="MicroPythonDeviceInterface.__rawOn" ID="MicroPythonDeviceInterface.__rawOn"></a> |
|
179 <h4>MicroPythonDeviceInterface.__rawOn</h4> |
|
180 <b>__rawOn</b>(<i></i>) |
|
181 |
|
182 <p> |
|
183 Private method to switch the connected device to 'raw' mode. |
|
184 </p> |
|
185 <p> |
|
186 Note: switching to raw mode is done with synchronous writes. |
|
187 </p> |
|
188 <dl> |
|
189 <dt>Return:</dt> |
|
190 <dd> |
|
191 flag indicating success |
|
192 @rtype bool |
|
193 </dd> |
|
194 </dl> |
|
195 <a NAME="MicroPythonDeviceInterface.__readSerial" ID="MicroPythonDeviceInterface.__readSerial"></a> |
|
196 <h4>MicroPythonDeviceInterface.__readSerial</h4> |
|
197 <b>__readSerial</b>(<i></i>) |
|
198 |
|
199 <p> |
|
200 Private slot to read all available serial data and emit it with the |
|
201 "dataReceived" signal for further processing. |
|
202 </p> |
|
203 <a NAME="MicroPythonDeviceInterface.connectToDevice" ID="MicroPythonDeviceInterface.connectToDevice"></a> |
|
204 <h4>MicroPythonDeviceInterface.connectToDevice</h4> |
|
205 <b>connectToDevice</b>(<i>port</i>) |
|
206 |
|
207 <p> |
|
208 Public slot to start the manager. |
|
209 </p> |
|
210 <dl> |
|
211 |
|
212 <dt><i>port</i> (str)</dt> |
|
213 <dd> |
|
214 name of the port to be used |
|
215 </dd> |
|
216 </dl> |
|
217 <dl> |
|
218 <dt>Return:</dt> |
|
219 <dd> |
|
220 flag indicating success |
|
221 </dd> |
|
222 </dl> |
|
223 <dl> |
|
224 <dt>Return Type:</dt> |
|
225 <dd> |
|
226 bool |
|
227 </dd> |
|
228 </dl> |
|
229 <a NAME="MicroPythonDeviceInterface.disconnectFromDevice" ID="MicroPythonDeviceInterface.disconnectFromDevice"></a> |
|
230 <h4>MicroPythonDeviceInterface.disconnectFromDevice</h4> |
|
231 <b>disconnectFromDevice</b>(<i></i>) |
|
232 |
|
233 <p> |
|
234 Public slot to stop the thread. |
|
235 </p> |
|
236 <a NAME="MicroPythonDeviceInterface.execute" ID="MicroPythonDeviceInterface.execute"></a> |
|
237 <h4>MicroPythonDeviceInterface.execute</h4> |
|
238 <b>execute</b>(<i>commands</i>) |
|
239 |
|
240 <p> |
|
241 Public method to send commands to the connected device and return the |
|
242 result. |
|
243 </p> |
|
244 <p> |
|
245 If no serial connection is available, empty results will be returned. |
|
246 </p> |
|
247 <dl> |
|
248 |
|
249 <dt><i>commands</i> (str or list of str)</dt> |
|
250 <dd> |
|
251 list of commands to be executed |
|
252 </dd> |
|
253 </dl> |
|
254 <dl> |
|
255 <dt>Return:</dt> |
|
256 <dd> |
|
257 tuple containing stdout and stderr output of the device |
|
258 </dd> |
|
259 </dl> |
|
260 <dl> |
|
261 <dt>Return Type:</dt> |
|
262 <dd> |
|
263 tuple of (bytes, bytes) |
|
264 </dd> |
|
265 </dl> |
|
266 <a NAME="MicroPythonDeviceInterface.executeAsync" ID="MicroPythonDeviceInterface.executeAsync"></a> |
|
267 <h4>MicroPythonDeviceInterface.executeAsync</h4> |
|
268 <b>executeAsync</b>(<i>commandsList</i>) |
|
269 |
|
270 <p> |
|
271 Public method to execute a series of commands over a period of time |
|
272 without returning any result (asynchronous execution). |
|
273 </p> |
|
274 <dl> |
|
275 |
|
276 <dt><i>commandsList</i> (list of bytes)</dt> |
|
277 <dd> |
|
278 list of commands to be execute on the device |
|
279 </dd> |
|
280 </dl> |
|
281 <a NAME="MicroPythonDeviceInterface.handlePreferencesChanged" ID="MicroPythonDeviceInterface.handlePreferencesChanged"></a> |
|
282 <h4>MicroPythonDeviceInterface.handlePreferencesChanged</h4> |
|
283 <b>handlePreferencesChanged</b>(<i></i>) |
|
284 |
|
285 <p> |
|
286 Public slot to handle a change of the preferences. |
|
287 </p> |
|
288 <a NAME="MicroPythonDeviceInterface.isConnected" ID="MicroPythonDeviceInterface.isConnected"></a> |
|
289 <h4>MicroPythonDeviceInterface.isConnected</h4> |
|
290 <b>isConnected</b>(<i></i>) |
|
291 |
|
292 <p> |
|
293 Public method to get the connection status. |
|
294 </p> |
|
295 <dl> |
|
296 <dt>Return:</dt> |
|
297 <dd> |
|
298 flag indicating the connection status |
|
299 </dd> |
|
300 </dl> |
|
301 <dl> |
|
302 <dt>Return Type:</dt> |
|
303 <dd> |
|
304 bool |
|
305 </dd> |
|
306 </dl> |
|
307 <a NAME="MicroPythonDeviceInterface.probeDevice" ID="MicroPythonDeviceInterface.probeDevice"></a> |
|
308 <h4>MicroPythonDeviceInterface.probeDevice</h4> |
|
309 <b>probeDevice</b>(<i></i>) |
|
310 |
|
311 <p> |
|
312 Public method to check the device is responding. |
|
313 </p> |
|
314 <p> |
|
315 If the device has not been flashed with a MicroPython formware, the |
|
316 probe will fail. |
|
317 </p> |
|
318 <dl> |
|
319 <dt>Return:</dt> |
|
320 <dd> |
|
321 flag indicating a communicating MicroPython device |
|
322 </dd> |
|
323 </dl> |
|
324 <dl> |
|
325 <dt>Return Type:</dt> |
|
326 <dd> |
|
327 bool |
|
328 </dd> |
|
329 </dl> |
|
330 <a NAME="MicroPythonDeviceInterface.write" ID="MicroPythonDeviceInterface.write"></a> |
|
331 <h4>MicroPythonDeviceInterface.write</h4> |
|
332 <b>write</b>(<i>data</i>) |
|
333 |
|
334 <p> |
|
335 Public method to write data to the connected device. |
|
336 </p> |
|
337 <dl> |
|
338 |
|
339 <dt><i>data</i> (bytes or bytearray)</dt> |
|
340 <dd> |
|
341 data to be written |
|
342 </dd> |
|
343 </dl> |
|
344 <div align="right"><a href="#top">Up</a></div> |
|
345 <hr /> |
|
346 </body></html> |