-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathcdh.py
More file actions
58 lines (45 loc) · 1.44 KB
/
cdh.py
File metadata and controls
58 lines (45 loc) · 1.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import time
commands = {
b'\x8eb': 'no-op',
b'\xd4\x9f': 'hreset',
b'\x12\x06': 'shutdown',
b'8\x93': 'query',
b'\x96\xa2': 'exec_cmd',
}
########### commands without arguments ###########
def noop(self):
self.debug('no-op')
pass
def hreset(self):
self.debug('Resetting')
try:
self.cubesat.radio1.send(data=b'resetting')
self.cubesat.micro.on_next_reset(self.cubesat.micro.RunMode.NORMAL)
self.cubesat.micro.reset()
except:
pass
########### commands with arguments ###########
def shutdown(self,args):
# make shutdown require yet another pass-code
if args == b'\x0b\xfdI\xec':
self.debug('valid shutdown command received')
# set shutdown NVM bit flag
self.cubesat.f_shtdwn=True
# stop all tasks
for t in self.cubesat.scheduled_tasks:
self.cubesat.scheduled_tasks[t].stop()
self.cubesat.powermode('minimum')
"""
Exercise for the user:
Implement a means of waking up from shutdown
See beep-sat guide for more details
https://pycubed.org/resources
"""
while True:
time.sleep(100000)
def query(self,args):
self.debug(f'query: {args}')
self.cubesat.radio1.send(data=str(eval(args)), keep_listening=True)
def exec_cmd(self,args):
self.debug(f'exec: {args}')
exec(args)