forked from OpenRoberta/robertalab-ev3dev
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathopenrobertalab
More file actions
41 lines (29 loc) · 799 Bytes
/
openrobertalab
File metadata and controls
41 lines (29 loc) · 799 Bytes
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
#!/usr/bin/env python3
import atexit
import logging
from gi.repository import GObject
from dbus.mainloop.glib import DBusGMainLoop
from roberta.lab import Service
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger('roberta')
GObject.threads_init()
service = None
def cleanup():
global service
if service:
service.hal.clearDisplay()
service.hal.stopAllMotors()
service.switchToTxtMode()
logger.info('--- done ---')
logging.shutdown()
def main():
global service
logger.info('--- starting ---')
atexit.register(cleanup)
DBusGMainLoop(set_as_default=True)
loop = GObject.MainLoop()
service = Service('/org/openroberta/Lab1')
logger.debug('loop running')
loop.run()
if __name__ == "__main__":
main()