コード例 #1
0
ファイル: brewpi.py プロジェクト: mrmichalis/brewpi-script
				time.sleep(1)  # sleep shortly, or something could be added to the string
			except json.JSONDecodeError:
				print >> sys.stderr, (time.strftime("%b %d %Y %H:%M:%S   ") +
					"Error: invalid json string received: " + value)
			raise socket.timeout
		elif messageType == "programArduino":
			ser.close  # close serial port before programming
			del ser  # Arduino won't reset when serial port is not completely removed
			programParameters = json.loads(value)
			hexFile = '/var/www/uploads/brewpi_avr.hex'
			boardType = 'leonardo'
			port = '/dev/ttyACM0'
			eraseEEPROM = True
			print >> sys.stderr, (time.strftime("%b %d %Y %H:%M:%S   ") +
						"New program uploaded to Arduino, script will restart")
			result = programmer.programArduino(boardType, hexFile, port, eraseEEPROM)

			# avrdudeResult = programmer.programArduino(	programParameters['boardType'],
			#							'/var/www/uploads/' + programParameters['fileName'],
			#							config['port'],
			#							programParameters['eraseEEPROM'])
			conn.send(result)
			# restart the script when done. This replaces this process with the new one
			time.sleep(5)  # give the Arduino time to reboot
			python = sys.executable
			os.execl(python, python, * sys.argv)
		else:
			print >> sys.stderr, (time.strftime("%b %d %Y %H:%M:%S   ") +
								"Error: Received invalid message on socket: " + message)

		if (time.time() - prevTimeOut) < config['serialCheckInterval']:
# Copyright 2012 Elco Jacobs.
# This file is part of ShiftPWM.

# ShiftPWM is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.

# ShiftPWM is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with ShiftPWM.  If not, see <http://www.gnu.org/licenses/>.

import programArduino as programmer

hexFile = "ShiftPWM_Non_Blocking/Debug/ShiftPWM_Non_Blocking.hex"
arduinoPath = "D:/arduino-1.0.1/"
# check https://github.com/arduino/Arduino/blob/master/hardware/arduino/boards.txt for the correct name
boardType = "nano328"
port = "COM7"
eraseEEPROM = True

programmer.programArduino(boardType, hexFile, port, eraseEEPROM, arduinoPath)
コード例 #3
0
# Copyright 2012 BrewPi/Elco Jacobs.
# This file is part of BrewPi.

# BrewPi is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.

# BrewPi is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with BrewPi.  If not, see <http://www.gnu.org/licenses/>.

import programArduino as programmer

hexFile = '/var/www/uploads/brewpi_avr.hex'
boardType = 'leonardo'
port = '/dev/ttyACM0'
eraseEEPROM = True

result = programmer.programArduino(boardType, hexFile, port, eraseEEPROM)

print result
コード例 #4
0
ファイル: updater.py プロジェクト: ajt2/brewpi-tools
        return

    import programArduino
    boardType = binary.split("-")[1]
    hexFile = scriptPath+'/utils/'+binary
    chooseSettings = raw_input("Would you like to keep your current Arduino settings? [Y/n]: ")
    chooseDevices = raw_input("Would you like to keep your current Arduino Device list? [Y/n]: ")
    if chooseSettings is "Y" or "y" or "Yes" or "yes" or "":
        restoreSettings = True
    else:
        restoreSettings = False
    if chooseDevices is "Y" or "y" or "Yes" or "yes" or "":
        restoreDevices = True
    else:
        restoreDevices = False
    programArduino.programArduino(config, boardType, hexFile, {'settings': restoreSettings, 'devices': restoreDevices})


print "######################################################"
print "####                                              ####"
print "####        Welcome to the BrewPi Updater!        ####"
print "####                                              ####"
print "######################################################"
print ""
checkForUpdates()
print ""

print "Most users will want to select the 'master' choice at each of the following menus."
branch = raw_input("Press enter to continue... ")

changed = False
コード例 #5
0
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with BrewPi.  If not, see <http://www.gnu.org/licenses/>.

import os
import sys
from configobj import ConfigObj

import programArduino as programmer
import BrewPiUtil as util

# Read in command line arguments
if len(sys.argv) < 2:
	sys.exit('Usage: %s <config file full path>' % sys.argv[0])
if not os.path.exists(sys.argv[1]):
	sys.exit('ERROR: Config file "%s" was not found!' % sys.argv[1])

configFile = sys.argv[1]
config = ConfigObj(configFile)

# global variables, will be initialized by startBeer()
util.readCfgWithDefaults(configFile)

hexFile = config['wwwPath'] + 'uploads/brewpi-uno-revC.hex'
boardType = config['boardType']

result = programmer.programArduino(config, boardType, hexFile, {'settings': True, 'devices': True})

print result
コード例 #6
0
    boardType = binary.split("-")[1]
    hexFile = scriptPath + '/utils/' + binary
    chooseSettings = raw_input(
        "Would you like to keep your current Arduino settings? [Y/n]: ")
    chooseDevices = raw_input(
        "Would you like to keep your current Arduino Device list? [Y/n]: ")
    if chooseSettings is "Y" or "y" or "Yes" or "yes" or "":
        restoreSettings = True
    else:
        restoreSettings = False
    if chooseDevices is "Y" or "y" or "Yes" or "yes" or "":
        restoreDevices = True
    else:
        restoreDevices = False
    programArduino.programArduino(config, boardType, hexFile, {
        'settings': restoreSettings,
        'devices': restoreDevices
    })


print "######################################################"
print "####                                              ####"
print "####        Welcome to the BrewPi Updater!        ####"
print "####                                              ####"
print "######################################################"
print ""
checkForUpdates()
print ""

print "Most users will want to select the 'master' choice at each of the following menus."
branch = raw_input("Press enter to continue... ")
コード例 #7
0
ファイル: brewpi.py プロジェクト: nogorilla/brewpi-script
            urllib.urlretrieve(profileUrl, profileFileName)
            if os.path.isfile(profileFileName):
                conn.send("Profile successfuly updated")
            else:
                conn.send("Failed to update profile")
        elif messageType == "programArduino":
            ser.close()  # close serial port before programming
            del ser  # Arduino won't reset when serial port is not completely removed
            try:
                programParameters = json.loads(value)
                hexFile = programParameters["fileName"]
                boardType = programParameters["boardType"]
                restoreSettings = programParameters["restoreSettings"]
                restoreDevices = programParameters["restoreDevices"]
                programmer.programArduino(
                    config, boardType, hexFile, {"settings": restoreSettings, "devices": restoreDevices}
                )
                logMessage("New program uploaded to Arduino, script will restart")
            except json.JSONDecodeError:
                logMessage("Error: cannot decode programming parameters: " + value)
                logMessage("Restarting script without programming.")

                # restart the script when done. This replaces this process with the new one
            time.sleep(5)  # give the Arduino time to reboot
            python = sys.executable
            os.execl(python, python, *sys.argv)
        elif messageType == "refreshDeviceList":
            deviceList["listState"] = ""  # invalidate local copy
            if value.find("readValues") != -1:
                ser.write("d{r:1}")  # request installed devices
                serialRestoreTimeOut = ser.getTimeout()
# Copyright 2012 Elco Jacobs.
# This file is part of ShiftPWM.

# ShiftPWM is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.

# ShiftPWM is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with ShiftPWM.  If not, see <http://www.gnu.org/licenses/>.

import programArduino as programmer

hexFile = 'ShiftPWM_Non_Blocking/Debug/ShiftPWM_Non_Blocking.hex'
arduinoPath = 'D:/arduino-1.0.1/'
# check https://github.com/arduino/Arduino/blob/master/hardware/arduino/boards.txt for the correct name
boardType = 'nano328'
port = 'COM7'
eraseEEPROM = True

programmer.programArduino(boardType, hexFile, port, eraseEEPROM, arduinoPath)