MCPcopy Create free account
hub / github.com/bitcraze/crazyflie-lib-python / Flasher

Class Flasher

examples/flash-memory.py:35–107  ·  view source on GitHub ↗

A class that can flash the DS28E05 EEPROM via CRTP.

Source from the content-addressed store, hash-verified

33
34
35class Flasher(object):
36 """
37 A class that can flash the DS28E05 EEPROM via CRTP.
38 """
39
40 def __init__(self, link_uri):
41 self._cf = Crazyflie()
42 self._link_uri = link_uri
43
44 # Add some callbacks from the Crazyflie API
45 self._cf.connected.add_callback(self._connected)
46 self._cf.disconnected.add_callback(self._disconnected)
47 self._cf.connection_failed.add_callback(self._connection_failed)
48 self._cf.connection_lost.add_callback(self._connection_lost)
49
50 # Initialize variables
51 self.connected = False
52
53 # Public methods
54
55 def connect(self):
56 """
57 Connect to the crazyflie.
58 """
59 print('Connecting to %s' % self._link_uri)
60 self._cf.open_link(self._link_uri)
61
62 def disconnect(self):
63 print('Disconnecting from %s' % self._link_uri)
64 self._cf.close_link()
65
66 def wait_for_connection(self, timeout=10):
67 """
68 Busy loop until connection is established.
69
70 Will abort after timeout (seconds). Return value is a boolean, whether
71 connection could be established.
72
73 """
74 start_time = datetime.datetime.now()
75 while True:
76 if self.connected:
77 return True
78 now = datetime.datetime.now()
79 if (now - start_time).total_seconds() > timeout:
80 return False
81 time.sleep(0.5)
82
83 def search_memories(self):
84 """
85 Search and return list of 1-wire memories.
86 """
87 if not self.connected:
88 raise NotConnected()
89 return self._cf.mem.get_mems(MemoryElement.TYPE_1W)
90
91 # Callbacks
92

Callers 1

flash-memory.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected