Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def initiateColdBoot(self, linkURI):
self.connectingSignal.emit()
self.link = cflib.crtp.get_link_driver("radio://0/110")
self.loader = Cloader(self.link, "radio://0/110")
#self.link = CRTP.get_link_driver("debug://0/110")
#self.loader = Cloader(self.link, "debug://0/110")
if self.loader.coldboot():
logger.info("Connected in coldboot mode ok")
self.updateCpuIdSignal.emit(self.loader.cpuid)
self.readConfigAction()
self.connectedSignal.emit()
else:
self.connectionFailedSignal.emit()
logger.info("Connected in coldboot mode failed")
self.link.close()
def main():
# Initialise the CRTP link driver
link = None
try:
cflib.crtp.init_drivers()
link = cflib.crtp.get_link_driver("radio://")
except Exception as e:
print("Error: {}".format(str(e)))
if link:
link.close()
sys.exit(-1)
# Set the default parameters
clink = None
action = "info"
boot = "cold"
if len(sys.argv) < 2:
print()
print("==============================")
print(" CrazyLoader Flash Utility")
print("==============================")
def open_link(self, link_uri):
"""
Open the communication link to a copter at the given URI and setup the
connection (download log/parameter TOC).
"""
self.connection_requested.call(link_uri)
self.state = State.INITIALIZED
self.link_uri = link_uri
try:
self.link = cflib.crtp.get_link_driver(
link_uri, self._link_quality_cb, self._link_error_cb)
if not self.link:
message = "No driver found or malformed URI: {}" \
.format(link_uri)
logger.warning(message)
self.connection_failed.call(link_uri, message)
else:
# Add a callback so we can check that any data is coming
# back from the copter
self.packet_received.add_callback(
self._check_for_initial_packet_cb)
self._start_connection_setup()
except Exception as ex: # pylint: disable=W0703
# We want to catch every possible exception here and show
def scan_for_bootloader(self):
link = cflib.crtp.get_link_driver("radio://0")
ts = time.time()
res = ()
while len(res) == 0 and (time.time() - ts) < 10:
res = link.scan_selected(self._available_boot_uri)
link.close()
if len(res) > 0:
return res[0]
return None
# MA 02110-1301, USA.
#Crazy Loader bootloader utility
#Can reset bootload and reset back the bootloader
import sys
import cflib.crtp
from cflib.bootloader.cloader import Cloader
#Initialise the CRTP link driver
link = None
cload = None
try:
cflib.crtp.init_drivers()
link = cflib.crtp.get_link_driver("radio://0")
except(Exception):
print "=============================="
print " CrazyLoader Flash Utility"
print "=============================="
print
print " Usage:", sys.argv[0], "[CRTP options] [parameters]"
print
print "The CRTP options are described above"
print
print "Crazyload option:"
print " info : Print the info of the bootloader and quit."
print " Will let the target in bootloader mode"
print " reset : Reset the device in firmware mode"
print " flash <img> : flash the <img> binary file from the first"
print " possible page in flash and reset to firmware"
print " mode."
# Wait to ack the reset ...
pk = None
while True:
pk = self.link.receive_packet(2)
if not pk:
return False
if pk.port == 0xFF and tuple(pk.data) == (0xFF, 0xFE) + cpu_id:
pk.data = (0xFF, 0xF0) + cpu_id
self.link.send_packet(pk)
break
time.sleep(0.1)
self.link.close()
self.link = cflib.crtp.get_link_driver(self.clink_address)
# time.sleep(0.1)
return self._update_info()
retry_counter -= 1
if pk:
new_address = (0xb1,) + struct.unpack("