diff options
author | Christian Pointner <equinox@spreadspace.org> | 2013-07-07 22:15:09 +0000 |
---|---|---|
committer | Christian Pointner <equinox@spreadspace.org> | 2013-07-07 22:15:09 +0000 |
commit | 0b9dc7cf75c30d30557bd2efdbcc0f3ee859cc08 (patch) | |
tree | 4087de3b39d44b6a4aeb912d561f7c1d21a835d1 /downloader | |
parent | ignoring all data beyond of flash (diff) |
identify now checks if the downloader is connected to the right device
git-svn-id: https://svn.spreadspace.org/pic/trunk@54 a09c6847-51d9-44de-8ef2-e725cf50f3c7
Diffstat (limited to 'downloader')
-rwxr-xr-x | downloader/downloader.py | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/downloader/downloader.py b/downloader/downloader.py index 8c5f15c..48e6836 100755 --- a/downloader/downloader.py +++ b/downloader/downloader.py @@ -162,7 +162,7 @@ def exec_command(dev, cmd, param, answer): ### Commands -def identify(dev): +def identify(dev, name): data = exec_command(dev, 1, '', '<BB3sHHBHBH') id = { 'ver_min': data[0], 'ver_maj': data[1], 'name': data[2], 'devid': data[3], 'fs': data[4], 'fss': data[5], 'es': data[6], 'mess': data[7], 'supported': data[8] } @@ -170,8 +170,10 @@ def identify(dev): if id['ver_maj'] != VERSION_MAJ: print "incompatible protocol version, expected: %d, got: %d" % (VERSION_MAJ, id['ver_maj']) sys.exit(4) - if id['fss'] == 0: - print "FSS value is 0 " + if name and id['name'] != name: + print "ERROR: the bootloaders name '%s' differs from the one supplied via" % id['name'] + print " command line option '%s'. Are sure you are connected to the" % name + print " right device?" sys.exit(4) print "connected with Bootloader '%s' Version %d.%d, (ID=%04X, %d words Flash, FSS=%d, %d bytes EEPROM, MESS=%d)" % \ @@ -231,14 +233,16 @@ Options: -v, --version version info. --device=N the serial port to use (default: /dev/ttyUSB0). --baud=N baudrate to use (default: 57600). + --name=N the expected name of the bootloader. ''' device = "/dev/ttyUSB0" baudrate = 57600 + name = None try: opts, args = getopt.getopt(sys.argv[1:], "hv", - ["help", "version", "device=", "baud="]) + ["help", "version", "device=", "baud=", "name="]) for o, a in opts: if o in ("-h", "--help"): @@ -251,6 +255,8 @@ Options: device = a elif o in ("--baud"): baudrate = a + elif o in ("--name"): + name = a if not args: raise getopt.GetoptError('Input file is not specified') @@ -265,7 +271,7 @@ Options: dev = open_serial(device, baudrate) codedata = load_hex(args[0]) - id = identify(dev) + id = identify(dev, name) for segment in create_flash_segments(codedata, id['fs'], id['fss']): print "%05X: %s" % (segment[0], ''.join('%04X'%i for i in segment[1])) |