Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add MSP motor telemetry support #2

Merged
merged 1 commit into from Apr 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 10 additions & 0 deletions unavlib/__init__.py
Expand Up @@ -1531,6 +1531,16 @@ def process_MSP_BLACKBOX_CONFIG(self, data):
def process_MSP_SET_BLACKBOX_CONFIG(self, data):
logging.info("Blackbox config saved")

def process_MSP_MOTOR_TELEMETRY(self, data):
motorCount = self.readbytes(data, size=8, unsigned=True)
for i in range(motorCount):
self.MOTOR_TELEMETRY_DATA['rpm'][i] = self.readbytes(data, size=32, unsigned=True)
self.MOTOR_TELEMETRY_DATA['invalidPercent'][i] = self.readbytes(data, size=16, unsigned=True)
self.MOTOR_TELEMETRY_DATA['temperature'][i] = self.readbytes(data, size=8, unsigned=True)
self.MOTOR_TELEMETRY_DATA['voltage'][i] = self.readbytes(data, size=16, unsigned=True)
self.MOTOR_TELEMETRY_DATA['current'][i] = self.readbytes(data, size=16, unsigned=True)
self.MOTOR_TELEMETRY_DATA['consumption'][i] = self.readbytes(data, size=16, unsigned=True)

# TODO: This changed and it will need to check the BF version to decode things correctly
# def process_MSP_TRANSPONDER_CONFIG(self, data):
# bytesRemaining = len(data)
Expand Down
9 changes: 9 additions & 0 deletions unavlib/msp_vars.py
Expand Up @@ -47,6 +47,15 @@

MOTOR_DATA = [0]*8

MOTOR_TELEMETRY_DATA = {
'rpm': [0]*8,
'invalidPercent': [0]*8,
'temperature': [0]*8,
'voltage': [0]*8,
'current': [0]*8,
'consumption': [0]*8,
}

# defaults
# roll, pitch, yaw, throttle, aux 1, ... aux n
RC = {
Expand Down