Rev 702 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 702 | Rev 705 | ||
---|---|---|---|
Line 182... | Line 182... | ||
182 | def setSetting(self, settingIndex, value): |
182 | def setSetting(self, settingIndex, value): |
183 | self.msg.data[settingIndex] = value |
183 | self.msg.data[settingIndex] = value |
Line 184... | Line 184... | ||
184 | 184 | ||
- | 185 | ||
- | 186 | class DebugDataMsg: |
|
185 | 187 | IDX_ANALOG_ANGLENICK= 2+2*0 |
|
186 | class DebugDataMsg: |
188 | IDX_ANALOG_ANGLEROLL= 2+2*1 |
187 | IDX_ANALOG_ACCNICK = 2+2*2 |
189 | IDX_ANALOG_ACCNICK = 2+2*2 |
188 | IDX_ANALOG_ACCROLL = 2+2*3 |
190 | IDX_ANALOG_ACCROLL = 2+2*3 |
Line 189... | Line 191... | ||
189 | IDX_ANALOG_COMPASS = 2+2*3 |
191 | IDX_ANALOG_COMPASS = 2+2*3 |
190 | IDX_ANALOG_VOLTAGE = 2+2*9 |
192 | IDX_ANALOG_VOLTAGE = 2+2*9 |
191 | 193 | ||
192 | def __init__(self, msg): |
194 | def __init__(self, msg): |
Line -... | Line 195... | ||
- | 195 | if (msg.cmd != 'D'): |
|
- | 196 | raise InvalidMsgType |
|
- | 197 | self.msg = msg |
|
- | 198 | ||
- | 199 | def getAngleNick(self): |
|
- | 200 | return self.msg.data2SignedInt(DebugDataMsg.IDX_ANALOG_ANGLENICK) |
|
193 | if (msg.cmd != 'D'): |
201 | |
194 | raise InvalidMsgType |
202 | def getAngleRoll(self): |
Line 195... | Line 203... | ||
195 | self.msg = msg |
203 | return self.msg.data2SignedInt(DebugDataMsg.IDX_ANALOG_ANGLEROLL) |
196 | 204 | ||
Line 334... | Line 342... | ||
334 | 342 | ||
335 | # FIXE: should be fixed in the FC code |
343 | # FIXE: should be fixed in the FC code |
336 | data[0]=data[1] |
344 | data[0]=data[1] |
Line -... | Line 345... | ||
- | 345 | return data |
|
- | 346 | ||
- | 347 | def recordDbgMsg(self, samplePeriod, nbSamples): |
|
- | 348 | result = [] |
|
- | 349 | self.serPort.flushInput() |
|
- | 350 | msg = MkMsg(address=0, cmd='d', data=[int(samplePeriod*100)]) |
|
- | 351 | self.sendMsg(msg) |
|
- | 352 | for i in range(nbSamples): |
|
- | 353 | print i |
|
- | 354 | msg = self.waitForMsg('D', timeout=samplePeriod+1) |
|
- | 355 | msg = DebugDataMsg(msg) |
|
Line 337... | Line 356... | ||
337 | return data |
356 | result.append(msg) |
338 | 357 | return result |
|
Line 346... | Line 365... | ||
346 | comm.open(comPort="COM5") |
365 | comm.open(comPort="COM5") |
Line 347... | Line 366... | ||
347 | 366 | ||
348 | msg = comm.getVersionMsg() |
367 | msg = comm.getVersionMsg() |
Line 349... | Line 368... | ||
349 | print "Version: %d.%d" % msg.getVersion() |
368 | print "Version: %d.%d" % msg.getVersion() |
350 | 369 | ||
351 | msg = comm.getSettingsMsg() |
370 | # msg = comm.getSettingsMsg() |
352 | print "Index=",msg.getIndex() |
371 | # print "Index=",msg.getIndex() |
353 | print "Name=",msg.getName() |
372 | # print "Name=",msg.getName() |
- | 373 | # print "StickP=",msg.getSetting(SettingsMsg.IDX_STICK_P) |
|
- | 374 | # print "StickD=",msg.getSetting(SettingsMsg.IDX_STICK_D) |
|
- | 375 | # |
|
- | 376 | # msg.setSetting(SettingsMsg.IDX_STICK_P, msg.getSetting(SettingsMsg.IDX_STICK_P)+1) |
|
- | 377 | # comm.sendSettings(msg.getSettings()) |
|
- | 378 | ||
- | 379 | messages = comm.recordDbgMsg(0.05, 20) |
|
Line 354... | Line -... | ||
354 | print "StickP=",msg.getSetting(SettingsMsg.IDX_STICK_P) |
- | |
355 | print "StickD=",msg.getSetting(SettingsMsg.IDX_STICK_D) |
- | |
Line 356... | Line -... | ||
356 | - | ||
357 | msg.setSetting(SettingsMsg.IDX_STICK_P, msg.getSetting(SettingsMsg.IDX_STICK_P)+1) |
- | |
Line 358... | Line 380... | ||
358 | comm.sendSettings(msg.getSettings()) |
380 | for msg in messages: |
359 | 381 | print msg.getAngleRoll() |
|
360 | comm.doVibrationTest(100,5) |
382 | |
361 | 383 |