524 @pyqtSlot() |
524 @pyqtSlot() |
525 def __resetDevice(self): |
525 def __resetDevice(self): |
526 """ |
526 """ |
527 Private slot to reset the connected device. |
527 Private slot to reset the connected device. |
528 """ |
528 """ |
529 if self.getDeviceType() == "bbc_microbit": |
529 if self.microPython.isConnected(): |
530 # BBC micro:bit |
530 if self.getDeviceType() == "bbc_microbit": |
531 self.microPython.deviceInterface().execute( |
531 # BBC micro:bit |
532 "import microbit\nmicrobit.reset()\n", mode=self._submitMode |
532 self.executeCommands( |
533 ) |
533 "import microbit\nmicrobit.reset()\n", mode=self._submitMode |
534 else: |
534 ) |
535 # Calliope mini |
535 else: |
536 self.microPython.deviceInterface().execute( |
536 # Calliope mini |
537 "import calliope_mini\ncalliope_mini.reset()\n", mode=self._submitMode |
537 self.executeCommands( |
538 ) |
538 "import calliope_mini\ncalliope_mini.reset()\n", |
|
539 mode=self._submitMode, |
|
540 ) |
539 |
541 |
540 def getDocumentationUrl(self): |
542 def getDocumentationUrl(self): |
541 """ |
543 """ |
542 Public method to get the device documentation URL. |
544 Public method to get the device documentation URL. |
543 |
545 |
624 command = """ |
626 command = """ |
625 import os as __os_ |
627 import os as __os_ |
626 print(__os_.listdir()) |
628 print(__os_.listdir()) |
627 del __os_ |
629 del __os_ |
628 """ |
630 """ |
629 out, err = self._interface.execute(command, mode=self._submitMode) |
631 out, err = self.executeCommands(command, mode=self._submitMode) |
630 if err: |
632 if err: |
631 raise OSError(self._shortError(err)) |
633 raise OSError(self._shortError(err)) |
632 return ast.literal_eval(out.decode("utf-8")) |
634 return ast.literal_eval(out.decode("utf-8")) |
633 |
635 |
634 def lls(self, dirname="", fullstat=False, showHidden=False): |
636 def lls(self, dirname="", fullstat=False, showHidden=False): |
672 print(listdir_stat({0})) |
674 print(listdir_stat({0})) |
673 del __os_, stat, listdir_stat, is_visible |
675 del __os_, stat, listdir_stat, is_visible |
674 """.format( |
676 """.format( |
675 showHidden |
677 showHidden |
676 ) |
678 ) |
677 out, err = self._interface.execute(command, mode=self._submitMode) |
679 out, err = self.executeCommands(command, mode=self._submitMode) |
678 if err: |
680 if err: |
679 raise OSError(self._shortError(err)) |
681 raise OSError(self._shortError(err)) |
680 fileslist = ast.literal_eval(out.decode("utf-8")) |
682 fileslist = ast.literal_eval(out.decode("utf-8")) |
681 if fileslist is None: |
683 if fileslist is None: |
682 return None |
684 return None |
763 return False |
765 return False |
764 |
766 |
765 print(has_bt()) |
767 print(has_bt()) |
766 del has_bt |
768 del has_bt |
767 """ |
769 """ |
768 out, err = self._interface.execute( |
770 out, err = self.executeCommands(command, mode=self._submitMode, timeout=10000) |
769 command, mode=self._submitMode, timeout=10000 |
|
770 ) |
|
771 if err: |
771 if err: |
772 raise OSError(self._shortError(err)) |
772 raise OSError(self._shortError(err)) |
773 return out.strip() == b"True" |
773 return out.strip() == b"True" |
774 |
774 |
775 def getBluetoothStatus(self): |
775 def getBluetoothStatus(self): |