|
@@ -56,18 +56,28 @@ def main(): |
|
|
|
|
|
|
|
|
print "Flashing device: {0} - {2} baud\r\nFirmware: {1}".format(device, firmware, baudrate) |
|
|
print "Flashing device: {0} - {2} baud\r\nFirmware: {1}".format(device, firmware, baudrate) |
|
|
|
|
|
|
|
|
if ':' in device: |
|
|
|
|
|
hostname, port = device.split(':') |
|
|
|
|
|
dev = alarmdecoder.devices.SocketDevice(interface=(hostname, int(port))) |
|
|
|
|
|
dev.open(no_reader_thread=True) |
|
|
|
|
|
else: |
|
|
|
|
|
dev = alarmdecoder.devices.SerialDevice(interface=device) |
|
|
|
|
|
dev.open(baudrate=baudrate, no_reader_thread=True) |
|
|
|
|
|
|
|
|
dev = None |
|
|
|
|
|
try: |
|
|
|
|
|
if ':' in device: |
|
|
|
|
|
hostname, port = device.split(':') |
|
|
|
|
|
dev = alarmdecoder.devices.SocketDevice(interface=(hostname, int(port))) |
|
|
|
|
|
dev.open(no_reader_thread=True) |
|
|
|
|
|
else: |
|
|
|
|
|
dev = alarmdecoder.devices.SerialDevice(interface=device) |
|
|
|
|
|
dev.open(baudrate=baudrate, no_reader_thread=True) |
|
|
|
|
|
|
|
|
time.sleep(3) |
|
|
|
|
|
alarmdecoder.util.Firmware.upload(dev, firmware, handle_firmware, debug=debug) |
|
|
|
|
|
|
|
|
time.sleep(3) |
|
|
|
|
|
alarmdecoder.util.Firmware.upload(dev, firmware, handle_firmware, debug=debug) |
|
|
|
|
|
|
|
|
dev.close() |
|
|
|
|
|
|
|
|
except alarmdecoder.util.NoDeviceError, ex: |
|
|
|
|
|
print "Error: Could not find device: {0}".format(ex) |
|
|
|
|
|
except alarmdecoder.util.UploadError, ex: |
|
|
|
|
|
print "Error: Error uploading firmware: {0}".format(ex) |
|
|
|
|
|
except Exception, ex: |
|
|
|
|
|
print "Error: {0}".format(ex) |
|
|
|
|
|
finally: |
|
|
|
|
|
if dev is not None: |
|
|
|
|
|
dev.close() |
|
|
|
|
|
|
|
|
if __name__ == "__main__": |
|
|
if __name__ == "__main__": |
|
|
main() |
|
|
main() |