Subversion Repositories Projects

Rev

Rev 618 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 618 Rev 653
Line 188... Line 188...
188
 
188
 
189
    def getVersion(self):
189
    def getVersion(self):
Line 190... Line 190...
190
        return (self.msg.data[0], self.msg.data[1])
190
        return (self.msg.data[0], self.msg.data[1])
-
 
191
 
191
 
192
class MkComm:
-
 
193
    ADDRESS_ALL    = 0
-
 
194
    ADDRESS_FC     = 1
192
class MkComm:
195
    ADDRESS_NC     = 2
193
    FCADDRESS = 1
196
    ADDRESS_MK3MAG = 3
194
 
197
   
Line 195... Line 198...
195
    def __init__(self, printDebugMsg=False):
198
    def __init__(self, printDebugMsg=False):
196
        #self.logfile = open('mklog.txt', "rbU")
199
        #self.logfile = open('mklog.txt', "rbU")
Line 202... Line 205...
202
        self.getVersionMsgLn = msg.generateMsg()
205
        self.getVersionMsgLn = msg.generateMsg()
203
        msg = MkMsg(address=0, cmd='d', data=[500])
206
        msg = MkMsg(address=0, cmd='d', data=[500])
204
        self.getDebugMsgLn = msg.generateMsg()
207
        self.getDebugMsgLn = msg.generateMsg()
Line 205... Line -...
205
       
-
 
206
 
208
       
207
 
209
 
208
    def open(self, comPort):
210
    def open(self, comPort):
209
        self.serPort = serial.Serial(comPort, 57600, timeout=0.5)
211
        self.serPort = serial.Serial(comPort, 57600, timeout=0.5)
Line 237... Line 239...
237
                if self.printDebugMsg:
239
                if self.printDebugMsg:
238
                  print "DebugMsg: \"%s\"" % line[:-1]
240
                  print "DebugMsg: \"%s\"" % line[:-1]
239
                pass
241
                pass
240
        return msg
242
        return msg
Line -... Line 243...
-
 
243
 
-
 
244
    def sendNCRedirectUartFromFC(self):
-
 
245
        self.serPort.flushInput()
-
 
246
        msg = MkMsg(address=MkComm.ADDRESS_NC, cmd='u', data=[0])
-
 
247
        self.sendLn(msg.generateMsg())
-
 
248
        time.sleep(.5)
-
 
249
        # No reply expected...        
241
 
250
 
242
    def getDebugMsg(self):
251
    def getDebugMsg(self):
243
        self.serPort.flushInput()
252
        self.serPort.flushInput()
244
        self.sendLn(self.getDebugMsgLn)
253
        self.sendLn(self.getDebugMsgLn)
245
        msg = self.waitForMsg('D')
254
        msg = self.waitForMsg('D')
Line 251... Line 260...
251
        msg = self.waitForMsg('V')
260
        msg = self.waitForMsg('V')
252
        msg = VersionMsg(msg)
261
        msg = VersionMsg(msg)
253
        return msg
262
        return msg
Line 254... Line 263...
254
 
263
 
255
    def setMotorTest(self, motorSpeeds):
264
    def setMotorTest(self, motorSpeeds):
256
        msg = MkMsg(address=MkComm.FCADDRESS, cmd='t', data=motorSpeeds)
265
        msg = MkMsg(address=MkComm.ADDRESS_FC, cmd='t', data=motorSpeeds)
Line 257... Line 266...
257
        self.sendLn(msg.generateMsg())
266
        self.sendLn(msg.generateMsg())
258
       
267
       
259
    def doVibrationTest(self, nbSamples, channel):
268
    def doVibrationTest(self, nbSamples, channel):
260
        data = []
269
        data = []
261
        for i in range(0,(min(nbSamples,1000)/50)):
270
        for i in range(0,(min(nbSamples,1000)/50)):
262
          msg = MkMsg(address=MkComm.FCADDRESS, cmd='f', data=[channel, i])
271
          msg = MkMsg(address=MkComm.ADDRESS_FC, cmd='f', data=[channel, i])
263
          self.sendLn(msg.generateMsg())
272
          self.sendLn(msg.generateMsg())
264
          msg = self.waitForMsg('F')
273
          msg = self.waitForMsg('F')