예제 #1
0
def get_biicode_env_folder_path():
    """ this folder is used to store automatically downloaed ArduinoSDK and RPI cross compilers
    """
    if OSInfo.is_win():
        return os.path.normpath("C:/biicode_env")
    else:
        return os.path.expanduser("~/.biicode_env")
예제 #2
0
def get_biicode_env_folder_path():
    """ this folder is used to store automatically downloaed ArduinoSDK and RPI cross compilers
    """
    if OSInfo.is_win():
        return os.path.normpath("C:/biicode_env")
    else:
        return os.path.expanduser("~/.biicode_env")
예제 #3
0
def _get_standard_path():
    if OSInfo.is_win():
        return 'C:/Program Files (x86)/Arduino'
    elif OSInfo.is_linux():
        return '/usr/share/arduino'
    elif OSInfo.is_mac():
        return '/Applications/Arduino.app/Contents/Resources/Java'
예제 #4
0
def _get_standard_path():
    if OSInfo.is_win():
        return 'C:/Program Files (x86)/Arduino'
    elif OSInfo.is_linux():
        return '/usr/share/arduino'
    elif OSInfo.is_mac():
        return '/Applications/Arduino.app/Contents/Resources/Java'
예제 #5
0
파일: cmake.py 프로젝트: MordodeMaru/client
def _install_cmake(user_io, bii_paths):
    user_io.out.writeln('Downloading and installing CMake %s' % _CMAKE_VERSION, front=Color.GREEN)
    if OSInfo.is_win():
        return _install_cmake_win(user_io, bii_paths)
    elif OSInfo.is_mac():
        return _install_cmake_mac(user_io)
    elif OSInfo.is_linux():
        return _install_cmake_linux(user_io, bii_paths)
예제 #6
0
def _install_cmake(user_io, bii_paths):
    user_io.out.writeln('Downloading and installing CMake %s' % _CMAKE_VERSION,
                        front=Color.GREEN)
    if OSInfo.is_win():
        return _install_cmake_win(user_io, bii_paths)
    elif OSInfo.is_mac():
        return _install_cmake_mac(user_io)
    elif OSInfo.is_linux():
        return _install_cmake_linux(user_io, bii_paths)
예제 #7
0
 def ssh_upload(self, possible_firmwares, ip):
     '''Uploading the firmware to Arduino'''
     firmware = _firmware_to_upload(self.bii, possible_firmwares)
     self.bii.user_io.out.writeln('Uploading...')
     if not OSInfo.is_win():
         scp_command = "scp %s.hex root@%s:/tmp/" % (firmware, ip)
         ssh_command = "ssh root@%s /usr/bin/run-avrdude /tmp/%s.hex -q -q" % (ip, firmware)
         bii_paths = self.bii.bii_paths
         self._execute_command(scp_command, bii_paths.bin)
         self._execute_command(ssh_command)
예제 #8
0
def get_arduino_download_url(version):
    if OSInfo.is_win():
        url = S3_URL + "arduino-%s-windows.zip" % version
    elif OSInfo.is_mac():
        url = S3_URL + "arduino-%s-macosx.zip" % version
    elif OSInfo.is_linux():
        if OSInfo.architecture() == "64bit":
            url = S3_URL + "arduino-%s-linux64.tgz" % version
        elif OSInfo.architecture() == "32bit":
            url = S3_URL + "arduino-%s-linux32.tgz" % version
    return url
예제 #9
0
def get_arduino_download_url(version):
    if OSInfo.is_win():
        url = S3_URL + "arduino-%s-windows.zip" % version
    elif OSInfo.is_mac():
        url = S3_URL + "arduino-%s-macosx.zip" % version
    elif OSInfo.is_linux():
        if OSInfo.architecture() == "64bit":
            url = S3_URL + "arduino-%s-linux64.tgz" % version
        elif OSInfo.architecture() == "32bit":
            url = S3_URL + "arduino-%s-linux32.tgz" % version
    return url
예제 #10
0
 def ssh_upload(self, possible_firmwares, ip):
     '''Uploading the firmware to Arduino'''
     firmware = _firmware_to_upload(self.bii, possible_firmwares)
     self.bii.user_io.out.writeln('Uploading...')
     if not OSInfo.is_win():
         scp_command = "scp %s.hex root@%s:/tmp/" % (firmware, ip)
         ssh_command = "ssh root@%s /usr/bin/run-avrdude /tmp/%s.hex -q -q" % (
             ip, firmware)
         bii_paths = self.bii.bii_paths
         self._execute_command(scp_command, bii_paths.bin)
         self._execute_command(ssh_command)
예제 #11
0
def _get_cmake_download_url():
    if OSInfo.is_win():
        url = S3_URL + "cmake-%s-win32-x86.zip" % _CMAKE_VERSION
    elif OSInfo.is_mac():
        url = S3_URL + 'cmake-%s-Darwin64-universal.dmg' % _CMAKE_VERSION
    elif OSInfo.is_linux():
        import platform
        if OSInfo.architecture() == "64bit":
            url = S3_URL + "cmake-%s-Linux-64.tar.gz" % _CMAKE_VERSION
        elif OSInfo.architecture() == "32bit":
            url = S3_URL + "cmake-%s-Linux-i386.tar.gz" % _CMAKE_VERSION
        if platform.machine() == "armv6l" or platform.machine() == "armv7l":
            url = S3_URL + "cmake-%s-Linux-armv6.tar.gz" % _CMAKE_VERSION
    return url
예제 #12
0
파일: cmake.py 프로젝트: MordodeMaru/client
def _get_cmake_download_url():
    if OSInfo.is_win():
        url = S3_URL + "cmake-%s-win32-x86.zip" % _CMAKE_VERSION
    elif OSInfo.is_mac():
        url = S3_URL + 'cmake-%s-Darwin64-universal.dmg' % _CMAKE_VERSION
    elif OSInfo.is_linux():
        import platform
        if OSInfo.architecture() == "64bit":
            url = S3_URL + "cmake-%s-Linux-64.tar.gz" % _CMAKE_VERSION
        elif OSInfo.architecture() == "32bit":
            url = S3_URL + "cmake-%s-Linux-i386.tar.gz" % _CMAKE_VERSION
        if platform.machine() == "armv6l" or platform.machine() == "armv7l":
            url = S3_URL + "cmake-%s-Linux-armv6.tar.gz" % _CMAKE_VERSION
    return url
예제 #13
0
 def _setup_cpp(self, interactive):
     restart_console = False
     try:
         paths = self.bii.bii_paths
         install_cmake(self.bii.user_io, paths, interactive)
         gnu_optional = OSInfo.is_win()
         # GNU in windows is optional, you could use Visual
         restart_console2 = install_gnu(self.bii.user_io, gnu_optional)
         restart_console = restart_console or restart_console2
     except BiiException as e:
         self.bii.user_io.out.error(str(e))
         raise BiiException("The cpp setup has failed. Please fix problems and launch bii "
                             "setup:cpp again")
     finally:
         if restart_console:
             self.bii.user_io.out.warn('The PATH has changed, it is necessary '
                                       'to CLOSE this window')
             self.bii.user_io.out.warn('Please close this window')
예제 #14
0
 def _setup_cpp(self, interactive):
     restart_console = False
     try:
         paths = self.bii.bii_paths
         install_cmake(self.bii.user_io, paths, interactive)
         gnu_optional = OSInfo.is_win()
         # GNU in windows is optional, you could use Visual
         restart_console2 = install_gnu(self.bii.user_io, gnu_optional)
         restart_console = restart_console or restart_console2
     except BiiException as e:
         self.bii.user_io.out.error(str(e))
         raise BiiException(
             "The cpp setup has failed. Please fix problems and launch bii "
             "setup:cpp again")
     finally:
         if restart_console:
             self.bii.user_io.out.warn(
                 'The PATH has changed, it is necessary '
                 'to CLOSE this window')
             self.bii.user_io.out.warn('Please close this window')
예제 #15
0
 def _handle_generator(self, generator):
     """ update current settings with the arg passed generator, or define a
     default generator. If settings for the toolchain do not exist, they
     might be created, as defaults or requested to user by wizard (e.g. arduino board)
     param generator: possible None. Text string with the Cmake generator
     """
     hive_disk_image = self.hive_disk_image
     settings = hive_disk_image.settings
     if generator:
         if generator != settings.cmake.generator:
             if settings.cmake.generator:
                 self.bii.user_io.out.warn("Changed CMake generator, regenerating project")
                 hive_disk_image.delete_build_folder()
             settings.cmake.generator = generator
             hive_disk_image.settings = settings
     else:
         if not settings.cmake.generator:
             if OSInfo.is_win():
                 settings.cmake.generator = "MinGW Makefiles"
             else:
                 settings.cmake.generator = "Unix Makefiles"
             hive_disk_image.settings = settings
예제 #16
0
 def _handle_generator(self, generator):
     """ update current settings with the arg passed generator, or define a
     default generator. If settings for the toolchain do not exist, they
     might be created, as defaults or requested to user by wizard (e.g. arduino board)
     param generator: possible None. Text string with the Cmake generator
     """
     hive_disk_image = self.hive_disk_image
     settings = hive_disk_image.settings
     if generator:
         if generator != settings.cmake.generator:
             if settings.cmake.generator:
                 self.bii.user_io.out.warn(
                     "Changed CMake generator, regenerating project")
                 hive_disk_image.delete_build_folder()
             settings.cmake.generator = generator
             hive_disk_image.settings = settings
     else:
         if not settings.cmake.generator:
             if OSInfo.is_win():
                 settings.cmake.generator = "MinGW Makefiles"
             else:
                 settings.cmake.generator = "Unix Makefiles"
             hive_disk_image.settings = settings
예제 #17
0
def _reset_serial(out, serial_port, wait_for_upload_port=False):
    ''' Code original from https://github.com/Robot-Will/Stino/tree/master/app
        adapted to biicode to reset Arduino ports

        Reset any serial port.
            parameters:
                out: bii.user_io.out
                serial_port: current serial port detected
                wait_for_upload_port: True if board == 'leonardo'
            return:
                selected port
    '''
    caterina_serial_port = ''
    before_serial_list = _detect_arduino_port()
    if serial_port in before_serial_list:
        non_serial_list = before_serial_list[:]
        non_serial_list.remove(serial_port)

        out.success('Forcing reset using 1200bps open/close on port %s' % serial_port)
        _touch_serial_port(serial_port, 1200)

        if not wait_for_upload_port:
            time.sleep(0.4)
            return serial_port

        # Scanning for available ports seems to open the port or
        # otherwise assert DTR, which would cancel the WDT reset if
        # it happened within 250 ms. So we wait until the reset should
        # have already occurred before we start scanning.
        time.sleep(3 if OSInfo.is_win() else 0.3)

        # Wait for a port to appear on the list
        elapsed = 0
        while (elapsed < 10000):
            now_serial_list = _detect_arduino_port()
            diff_serial_list = [v for v in now_serial_list if v not in non_serial_list]

            out.success('Ports {%s}/{%s} => {%s}'
                                % (before_serial_list, now_serial_list, diff_serial_list))
            if len(diff_serial_list) > 0:
                caterina_serial_port = diff_serial_list[0]
                out.success('Found new upload port: %s' % caterina_serial_port)
                break

            # Keep track of port that disappears
            # before_serial_list = now_serial_list
            time.sleep(0.25)
            elapsed += 250

            # On Windows, it can take a long time for the port to disappear and
            # come back, so use a longer time out before assuming that the selected
            # port is the bootloader (not the sketch).
            if (((not OSInfo.is_win() and elapsed >= 500)
                or elapsed >= 5000) and (serial_port in now_serial_list)):
                out.success('Uploading using selected port: %s' % serial_port)
                caterina_serial_port = serial_port
                break

        if not caterina_serial_port:
            out.error("Couldn't find a Leonardo on the selected port. "
                      "Check that you have the correct port selected. "
                      "If it is correct, try pressing the board's reset"
                      " button after initiating the upload.")
    return caterina_serial_port or 'None'