Skip to content

Commit

Permalink
fixed frame default constructed booleans initialization and checking
Browse files Browse the repository at this point in the history
  • Loading branch information
Bambofy committed Oct 16, 2020
1 parent 225f05e commit d82c309
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ void setup()

void loop()
{
while (Serial.available()) {
char v = Serial.read();
SerialB.print("RX");
}
/* Press S to send messages from the arduino to the control panel.
*
// listen to the main com port 6 and echo to the serialb.
Expand Down Expand Up @@ -57,6 +61,7 @@ void loop()
sprintf(&(hexStr[0]), "%02x", (uint8_t)c);
Serial.print(hexStr);
}*/
/*
while (SerialB.available() > 0)
{
char c = SerialB.read();
Expand All @@ -65,5 +70,5 @@ void loop()
//char hexStr[2];
//sprintf(&(hexStr[0]), "%02x\r\n", (uint8_t)c);
Serial.print(c);
}
}*/
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Datagram GroundStation::DatagramEncoder::Encode(OperationID operationId, std::ve
Datagram GroundStation::DatagramEncoder::Handshake()
{
std::vector<uint8_t> msgData;
msgData.push_back(FCPI_DIR_FROM_GROUND_STATION);
msgData.push_back(FCPI_DIR_TO_GROUND_STATION);
msgData.push_back(OperationID::HANDSHAKE);

return Datagram(SatVersion::V_NA, "NA", msgData, false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@

#include "Frame.h"

Frame::Frame() {

Frame::Frame()
: hasFunctionId(false), hasOptionalData(false), encrypted(false) {
}

Frame::~Frame() {
Expand Down Expand Up @@ -85,26 +85,37 @@ uint8_t Frame::GetByteAt(uint32_t index)
std::vector<uint8_t> Frame::Serialize()
{
std::vector<uint8_t> data;
data.insert(data.end(), this->optionalData.begin(), this->optionalData.end());
if (this->hasOptionalData)
{
data.insert(data.end(), this->optionalData.begin(), this->optionalData.end());
}
return data;
}

std::string Frame::ToHexString()
{
std::string frameStr;

char hexChar[5];
hexChar[4] = '\0';
sprintf(&(hexChar[0]), "%02x, ", this->functionId);
frameStr.append(hexChar);

for (uint8_t value : this->optionalData) {
if (this->hasFunctionId)
{
char hexChar[5];
hexChar[4] = '\0';
sprintf(&(hexChar[0]), "%02x, ", value);
sprintf(&(hexChar[0]), "%02x, ", this->functionId);
frameStr.append(hexChar);
}

if (this->hasOptionalData)
{
for (uint8_t value : this->optionalData)
{
char hexChar[5];
hexChar[4] = '\0';
sprintf(&(hexChar[0]), "%02x, ", value);
frameStr.append(hexChar);
}
}


return frameStr;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ class Frame {
SatVersion satVersion;
int16_t functionId;
std::vector<uint8_t> optionalData;

bool hasOptionalData;
bool hasFunctionId;
};


Expand Down
34 changes: 17 additions & 17 deletions Desktop/FOSSA-GroundStationControlPanel/FOSSAGSCP/mainwindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
<enum>QTabWidget::Triangular</enum>
</property>
<property name="currentIndex">
<number>0</number>
<number>2</number>
</property>
<property name="elideMode">
<enum>Qt::ElideRight</enum>
Expand Down Expand Up @@ -3838,28 +3838,28 @@ Sleep Interval (mV):</string>
<resources/>
<connections/>
<buttongroups>
<buttongroup name="buttonGroup_5"/>
<buttongroup name="buttonGroup_8"/>
<buttongroup name="buttonGroup_3"/>
<buttongroup name="retransmissionCodingRateButtonGroup"/>
<buttongroup name="buttonGroup_15"/>
<buttongroup name="lowPowerModeButtonGroup"/>
<buttongroup name="buttonGroup_6"/>
<buttongroup name="dopplerShiftEnableDisableRadioButtonGroup"/>
<buttongroup name="buttonGroup_5"/>
<buttongroup name="buttonGroup"/>
<buttongroup name="buttonGroup_4"/>
<buttongroup name="sendFullPictureButtonGroup"/>
<buttongroup name="retransmitBandwidthButtonGroup"/>
<buttongroup name="buttonGroup_11"/>
<buttongroup name="buttonGroup_9"/>
<buttongroup name="buttonGroup_12"/>
<buttongroup name="buttonGroup_8"/>
<buttongroup name="retransmitCRCEnabledButtonGroup"/>
<buttongroup name="buttonGroup_10"/>
<buttongroup name="buttonGroup_13"/>
<buttongroup name="buttonGroup"/>
<buttongroup name="lowPowerModeButtonGroup"/>
<buttongroup name="buttonGroup_2"/>
<buttongroup name="dopplerShiftEnableDisableRadioButtonGroup"/>
<buttongroup name="buttonGroup_3"/>
<buttongroup name="buttonGroup_13"/>
<buttongroup name="retransmitSpreadingFactorButtonGroup"/>
<buttongroup name="gpsLogOldestOrNewestFirstButtonGroup"/>
<buttongroup name="buttonGroup_11"/>
<buttongroup name="buttonGroup_9"/>
<buttongroup name="retransmitBandwidthButtonGroup"/>
<buttongroup name="buttonGroup_6"/>
<buttongroup name="buttonGroup_14"/>
<buttongroup name="buttonGroup_4"/>
<buttongroup name="buttonGroup_12"/>
<buttongroup name="buttonGroup_7"/>
<buttongroup name="retransmitCRCEnabledButtonGroup"/>
<buttongroup name="gpsLogOldestOrNewestFirstButtonGroup"/>
<buttongroup name="retransmissionCodingRateButtonGroup"/>
</buttongroups>
</ui>

0 comments on commit d82c309

Please sign in to comment.