2 ##############################################################################
4 # @file example_readlog.py
5 # @author The LibrePilot Project, http://www.librepilot.org Copyright (C) 2017.
6 # The OpenPilot Team, http://www.openpilot.org Copyright (C) 2011.
7 # @brief Base classes for python UAVObject
9 # @see The GNU Public License (GPL) Version 3
11 #############################################################################/
13 # This program is free software; you can redistribute it and/or modify
14 # it under the terms of the GNU General Public License as published by
15 # the Free Software Foundation; either version 3 of the License, or
16 # (at your option) any later version.
18 # This program is distributed in the hope that it will be useful, but
19 # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
20 # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
23 # You should have received a copy of the GNU General Public License along
24 # with this program; if not, write to the Free Software Foundation, Inc.,
25 # 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
35 from librepilot
.uavtalk
.uavobject
import *
36 from librepilot
.uavtalk
.uavtalk
import *
37 from librepilot
.uavtalk
.objectManager
import *
38 from librepilot
.uavtalk
.connectionManager
import *
39 from example
import UavtalkDemo
45 class UavtalkLogDemo(UavtalkDemo
):
49 self
.lastRateCalc
= time
.time()
54 def setup(self
, filename
):
55 print "Opening File \"%s\"" % filename
56 file = open(filename
,"rb")
58 raise IOError("Failed to open file")
60 print "Creating UavTalk"
61 self
.uavTalk
= UavTalk(None, filename
)
63 print "Starting ObjectManager"
64 self
.objMan
= ObjManager(self
.uavTalk
)
65 self
.objMan
.importDefinitions()
67 print "Starting UavTalk"
71 appName
= os
.path
.basename(sys
.argv
[0])
74 print " %s filename " % appName
76 print " for example: %s /tmp/OP-2015-04-28_23-16-33.opl" % appName
79 if __name__
== '__main__':
82 print "ERROR: Incorrect number of arguments"
87 script
, filename
= sys
.argv
88 if not os
.path
.exists(sys
.argv
[1]):
89 sys
.exit('ERROR: Database %s was not found!' % sys
.argv
[1])
91 # Log everything, and send it to stderr.
92 logging
.basicConfig(level
=logging
.INFO
)
95 demo
= UavtalkLogDemo()
99 demo
.objMan
.AttitudeState
.waitUpdate()
100 demo
._onAttitudeUpdate
(demo
.objMan
.AttitudeState
)
102 except KeyboardInterrupt:
106 print "An error occured: ", e
108 traceback
.print_exc()