def __init__(self, fw, channel = 16, serial_port = None, snr = None): ''' Ininitialises the OTA Flasher class which handles flashing the devboard with the needed OTA Server firmware and the update file for the OTA Client. The said devboard shall become the OTA Server which shall propagate the image on the Zigbee network. Keyword arguments: fw -- path to the update file for the OTA Client channel -- a 802.15.4 channel number, on which the OTA Server shall operate (default 16) serial_port -- a serial port of the connected devboard which shall be flashed with OTA Server snr -- a JLink serial number of the connected devboard which shall be flashed with OTA Server Note: only one parameter out of (serial_port, snr) must be provided, since the superclass constructor shall handle resolving the rest. ''' # Call the superclass constructor Flasher.__init__(self, serial_port, snr) # Create a Intel Hex out of the Zigbee Update file ih = IntelHex() update = open(fw, 'rb').read() ih.puts(OTAFlasher.OTA_UPDATE_OFFSET, update) self.update_firmware_hex = fw + '.hex' ih.write_hex_file(self.update_firmware_hex) # Open the serial channel to the devboard and save the 802.15.4 channel self.ser = Serial(self.serial_port, 115200) self.channel = channel
def __init__(self, serial_port = None, snr = None): Flasher.__init__(self, serial_port, snr)