Skip to content
Snippets Groups Projects
Commit de1b8027 authored by 488_MP-4's avatar 488_MP-4
Browse files

debugging sending return packet

parent f8311cc5
No related branches found
No related tags found
5 merge requests!106Adding Pycrocart 2.1,!104adding cflib to this branch,!103Updating develop to current state of master branch,!98Pycrocart 2.1 will,!94Merge cflib adapter into main
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
......@@ -177,7 +177,16 @@ class CrazyflieConnection:
try:
if self.scf.is_link_open():
toc = list(self.scf.cf.param.values.values())
print(self.scf.cf.param.values)
lst = list(self.scf.cf.param.values.values())
print(lst)
toc = []
for val in lst:
sublst = list(val.values())
for item in sublst:
toc.append(item)
#lst2 = list(self.scf.cf.param.values)
#print(lst2)
#val = toc.flatten()
#print(val)
print(toc)
......@@ -190,10 +199,18 @@ class CrazyflieConnection:
pass
data = bytearray(group)
data.append(name)
data.append(val)
data = bytearray()
data += command['data'][0:2]
data += command['data'][2:4]
if "." in actual:
actual = float(actual)
flBytes = struct.pack('f', actual)
else:
actual = int(actual)
flBytes = struct.pack('i', actual)
data += flBytes
print(data)
print(len(data))
responsedata = {
"msg_type": (MessageTypeID.RESPPARAM_ID),
"msg_id": command['msg_id'],
......
......@@ -3,6 +3,7 @@ import socket
import os
import collections
from enum import IntEnum, Enum
import struct
# Set the path for the Unix socket
socket_path = './cflib_groundstation.socket'
......@@ -92,14 +93,23 @@ class GroundstationSocket():
def EncodePacket(self, messagedata):
print("encoding packet")
bytedata = bytearray(Message.BEGIN_CHAR.value)
bytedata.append(messagedata["msg_type"] & 0xFF)
bytedata.append((messagedata["msg_type"] >> 8) & 0xFF)
bytedata = bytearray()
bytedata += b'\xbe'
bytedata.append((messagedata["msg_type"].value & 0xFF))
print(bytedata)
bytedata.append((messagedata["msg_type"].value >> 8) & 0xFF)
print(bytedata)
bytedata.append(messagedata["msg_id"])
print(bytedata)
bytedata.append(messagedata["data_len"] & 0xFF)
print(bytedata)
bytedata.append((messagedata["data_len"] >> 8) & 0xFF)
print(bytedata)
bytedata += messagedata["data"]
bytedata.append(self.packetChecksum(messagedata["data"], PacketHeader.HDR_SIZE.value + messagedata["data_len"] + ChecksumFormat.CSUM_SIZE.value))
print(bytedata)
bytedata.append(self.packetChecksum(bytedata, PacketHeader.HDR_SIZE.value + messagedata["data_len"] + ChecksumFormat.CSUM_SIZE.value))
print(bytedata)
return bytedata
def WriteToBackend(self, message):
......@@ -136,10 +146,7 @@ class DataType(IntEnum):
intType = 0
stringType = 2
"""
Message type IDs used to know what kind of message we are dealing with
Enumeration used to index the MessageTypes array in commands.c
DO NOT change items in the middle of this enum or you will break backwards compatibility.
Message type IDs used to know what kind omessagedata enum or you will break backwards compatibility.
Add new message types in the slot between MAX_TYPE_ID and the one before it
DO NOT change this enum without also updating the "MessageTypes" array
in commands.c to match.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment