示例#1
0
    def __init__(self, protocol="arduino", microcontroller="atmega328p", baudRate="19200", confPath=None, port=None):
        self.protocol = protocol
        self.microcontroller = microcontroller
        self.baudRate = baudRate

        if os.name == 'nt':
        	self.avrdude = path(resources.getPathForToolsWindows("avrdude.exe")).abspath()
        else:
            self.avrdude = 'avrdude'
        
        if self.avrdude is None:
            raise FirmwareError('avrdude not installed')

        if confPath is None:
            if os.name == 'nt':
                self.avrconf = path(resources.getPathForToolsWindows("avrdude.conf")).abspath()
            else:
                self.avrconf = path(resources.getPathForToolsLinux("avrdude-linux.conf")).abspath()
        else:
            self.avrconf = path(confPath).abspath()
        
        if port:
            self.port = port
            #print 'avrdude set to connect on port: %s' % self.port
        else:
            self.port = self.get_port(baudRate)
示例#2
0
    def __init__(self,
                 protocol="arduino",
                 microcontroller="atmega328p",
                 baudRate="19200",
                 confPath=None,
                 port=None):
        self.protocol = protocol
        self.microcontroller = microcontroller
        self.baudRate = baudRate

        if sys.isWindows():
            self.avrdude = path(
                resources.getPathForTools("avrdude.exe")).abspath()
        elif sys.isDarwin():
            self.avrdude = path(resources.getPathForTools("avrdude")).abspath()
        else:
            self.avrdude = 'avrdude'

        if self.avrdude is None:
            raise FirmwareError('avrdude not installed')

        if confPath is None:
            self.avrconf = path(
                resources.getPathForTools("avrdude.conf")).abspath()
        else:
            self.avrconf = path(confPath).abspath()

        if port:
            self.port = port
        else:
            self.port = self.get_port(baudRate)
示例#3
0
def get_serial_ports():
    if os.name == "nt":
        ports = _get_serial_ports_windows()
    else:
        ports = itertools.chain(path("/dev").walk("ttyUSB*"), path("/dev").walk("ttyACM*"))
    # sort list alphabetically
    ports_ = [port for port in ports]
    ports_.sort()
    for port in ports_:
        yield port
示例#4
0
def get_serial_ports():
    if os.name == 'nt':
        ports = _get_serial_ports_windows()
    else:
        ports = itertools.chain(path('/dev').walk('ttyUSB*'),
                                path('/dev').walk('ttyACM*'))
    # sort list alphabetically
    ports_ = [port for port in ports]
    ports_.sort()
    for port in ports_:
        yield port
示例#5
0
 def flash(self, hexPath=resources.getPathForFirmware("horus-fw.hex"), extraFlags=None):
     hexPath = path(hexPath)
     flags = ['-c', self.protocol, '-b', str(self.baudRate), '-p',
              self.microcontroller, '-P', '%s' % self.port, '-U',
              'flash:w:%s:i' % hexPath.name, '-C', '%(avrconf)s']
     if extraFlags is not None:
         flags.extend(extraFlags)
     try:
         cwd = os.getcwd()
         os.chdir(hexPath.parent)
         p = self._runCommand(flags)
     finally:
         os.chdir(cwd)
     return p
示例#6
0
    def __init__(self,
                 protocol="arduino",
                 microcontroller="atmega328p",
                 baudRate="19200",
                 confPath=None,
                 port=None):
        self.protocol = protocol
        self.microcontroller = microcontroller
        self.baudRate = baudRate

        if os.name == 'nt':
            self.avrdude = path(
                resources.getPathForToolsWindows("avrdude.exe")).abspath()
        else:
            self.avrdude = 'avrdude'

        if self.avrdude is None:
            raise FirmwareError('avrdude not installed')

        if confPath is None:
            if os.name == 'nt':
                self.avrconf = path(
                    resources.getPathForToolsWindows(
                        "avrdude.conf")).abspath()
            else:
                self.avrconf = path(
                    resources.getPathForToolsLinux(
                        "avrdude-linux.conf")).abspath()
        else:
            self.avrconf = path(confPath).abspath()

        if port:
            self.port = port
            #print 'avrdude set to connect on port: %s' % self.port
        else:
            self.port = self.get_port(baudRate)
示例#7
0
    def __init__(self, protocol="arduino", microcontroller="atmega328p", baudRate="19200", confPath=None, port=None):
        self.protocol = protocol
        self.microcontroller = microcontroller
        self.baudRate = baudRate

        if sys.isWindows():
        	self.avrdude = path(resources.getPathForTools("avrdude.exe")).abspath()
        elif sys.isDarwin():
            self.avrdude = path(resources.getPathForTools("avrdude")).abspath()
        else:
            self.avrdude = 'avrdude'
        
        if self.avrdude is None:
            raise FirmwareError('avrdude not installed')

        if confPath is None:
            self.avrconf = path(resources.getPathForTools("avrdude.conf")).abspath()
        else:
            self.avrconf = path(confPath).abspath()
        
        if port:
            self.port = port
        else:
            self.port = self.get_port(baudRate)
示例#8
0
 def flash(self,
           hexPath=resources.getPathForFirmware("horus-fw.hex"),
           extraFlags=None):
     hexPath = path(hexPath)
     flags = [
         '-c', self.protocol, '-b',
         str(self.baudRate), '-p', self.microcontroller, '-P',
         '%s' % self.port, '-U',
         'flash:w:%s:i' % hexPath.name, '-C', '%(avrconf)s'
     ]
     if extraFlags is not None:
         flags.extend(extraFlags)
     try:
         cwd = os.getcwd()
         os.chdir(hexPath.parent)
         p = self._runCommand(flags)
     finally:
         os.chdir(cwd)
     return p