formatting

This commit is contained in:
Jaime van Kessel 2015-03-31 10:40:21 +02:00
parent 9d889cf2db
commit 3fa02d3710
6 changed files with 289 additions and 286 deletions

View file

@ -29,7 +29,8 @@ class PrinterConnection():
def _connect(self): def _connect(self):
self._is_connecting = True self._is_connecting = True
programmer.connect(serial_port) #Connect with the serial, if this succeeds, it's an arduino based usb device. programmer = stk500v2.Stk500v2()
programmer.connect(self._serial_port) #Connect with the serial, if this succeeds, it's an arduino based usb device.
try: try:
self._serial = programmer.leaveISP() self._serial = programmer.leaveISP()
# Create new printer connection # Create new printer connection

View file

@ -17,7 +17,7 @@ class USBPrinterManager(SignalEmitter,PluginObject):
self._check_ports_thread = threading.Thread(target=self._updateConnectionList) self._check_ports_thread = threading.Thread(target=self._updateConnectionList)
self._check_ports_thread.daemon = True self._check_ports_thread.daemon = True
self._check_ports_thread.start() self._check_ports_thread.start()
time.sleep(6) time.sleep(2)
self.connectAllConnections() self.connectAllConnections()
## Check all serial ports and create a PrinterConnection object for them. ## Check all serial ports and create a PrinterConnection object for them.

View file

@ -1,8 +1,8 @@
""" """
Database of AVR chips for avr_isp programming. Contains signatures and flash sizes from the AVR datasheets. Database of AVR chips for avr_isp programming. Contains signatures and flash sizes from the AVR datasheets.
To support more chips add the relevant data to the avrChipDB list. To support more chips add the relevant data to the avrChipDB list.
This is a python 3 conversion of the code created by David Braam for the Cura project.
""" """
__copyright__ = "Copyright (C) 2013 David Braam - Released under terms of the AGPLv3 License"
avrChipDB = { avrChipDB = {
'ATMega1280': { 'ATMega1280': {

View file

@ -2,8 +2,8 @@
Module to read intel hex files into binary data blobs. Module to read intel hex files into binary data blobs.
IntelHex files are commonly used to distribute firmware IntelHex files are commonly used to distribute firmware
See: http://en.wikipedia.org/wiki/Intel_HEX See: http://en.wikipedia.org/wiki/Intel_HEX
This is a python 3 conversion of the code created by David Braam for the Cura project.
""" """
__copyright__ = "Copyright (C) 2013 David Braam - Released under terms of the AGPLv3 License"
import io import io
def readHex(filename): def readHex(filename):
@ -25,7 +25,7 @@ def readHex(filename):
if len(line) != recLen * 2 + 11: if len(line) != recLen * 2 + 11:
raise Exception("Error in hex file: " + line) raise Exception("Error in hex file: " + line)
checkSum = 0 checkSum = 0
for i in xrange(0, recLen + 5): for i in range(0, recLen + 5):
checkSum += int(line[i*2+1:i*2+3], 16) checkSum += int(line[i*2+1:i*2+3], 16)
checkSum &= 0xFF checkSum &= 0xFF
if checkSum != 0: if checkSum != 0:

View file

@ -4,8 +4,8 @@ The ISP AVR programmer can load firmware into AVR chips. Which are commonly used
Needs to be subclassed to support different programmers. Needs to be subclassed to support different programmers.
Currently only the stk500v2 subclass exists. Currently only the stk500v2 subclass exists.
This is a python 3 conversion of the code created by David Braam for the Cura project.
""" """
__copyright__ = "Copyright (C) 2013 David Braam - Released under terms of the AGPLv3 License"
from . import chipDB from . import chipDB

View file

@ -1,8 +1,8 @@
""" """
STK500v2 protocol implementation for programming AVR chips. STK500v2 protocol implementation for programming AVR chips.
The STK500v2 protocol is used by the ArduinoMega2560 and a few other Arduino platforms to load firmware. The STK500v2 protocol is used by the ArduinoMega2560 and a few other Arduino platforms to load firmware.
This is a python 3 conversion of the code created by David Braam for the Cura project.
""" """
__copyright__ = "Copyright (C) 2013 David Braam - Released under terms of the AGPLv3 License"
import os, struct, sys, time import os, struct, sys, time
from serial import Serial from serial import Serial
@ -30,7 +30,7 @@ class Stk500v2(ispBase.IspBase):
self.seq = 1 self.seq = 1
#Reset the controller #Reset the controller
for n in xrange(0, 2): for n in range(0, 2):
self.serial.setDTR(True) self.serial.setDTR(True)
time.sleep(0.1) time.sleep(0.1)
self.serial.setDTR(False) self.serial.setDTR(False)
@ -127,7 +127,9 @@ class Stk500v2(ispBase.IspBase):
for c in data: for c in data:
message += struct.pack(">B", c) message += struct.pack(">B", c)
checksum = 0 checksum = 0
print("messsage " , message)
for c in message: for c in message:
print(c)
checksum ^= ord(c) checksum ^= ord(c)
message += struct.pack(">B", checksum) message += struct.pack(">B", checksum)
try: try: