-
Notifications
You must be signed in to change notification settings - Fork 5
initial variable buffer software #83
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -159,9 +159,26 @@ void Telemetry::transmit() { | |
| digitalWrite(LED_BLUE, blue_state); | ||
| blue_state = !blue_state; | ||
|
|
||
| TelemetryPacket packet = makePacket(dataLogger.read()); | ||
| Packets packet; | ||
|
|
||
| auto rocket_state = dataLogger.read().rocketState_data.rocketStates[0]; | ||
| if (rocket_state == FSM_State::STATE_INIT || rocket_state == FSM_State::STATE_IDLE) { | ||
| packet.compact_packet = makeCompactPacket(dataLogger.read()); | ||
| packet.type = Packets::COMPACT; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would appreciate if this section were commented |
||
| } else { | ||
| packet.default_packet = makePacket(dataLogger.read()); | ||
| packet.type = Packets::DEFAULT; | ||
| } | ||
|
|
||
| #ifndef ENABLE_SILSIM_MODE | ||
| rf95.send((uint8_t *)&packet, sizeof(packet)); | ||
| switch (packet.type) { | ||
| case (Packets::DEFAULT): | ||
| rf95.send((uint8_t *)&packet, sizeof(packet.default_packet)); | ||
| break; | ||
| case (Packets::COMPACT): | ||
| rf95.send((uint8_t *)&packet, sizeof(packet.compact_packet)); | ||
| break; | ||
| } | ||
|
|
||
| chThdSleepMilliseconds(170); | ||
|
|
||
|
|
@@ -392,6 +409,18 @@ TelemetryPacket Telemetry::makePacket(const sensorDataStruct_t &data_struct) { | |
| return packet; | ||
| } | ||
|
|
||
| CompactTelemetryPacket Telemetry::makeCompactPacket(const sensorDataStruct_t &data_struct) { | ||
| CompactTelemetryPacket packet{}; | ||
| packet.gps_lat = data_struct.gps_data.latitude; | ||
| packet.gps_long = data_struct.gps_data.longitude; | ||
| packet.gps_alt = data_struct.gps_data.altitude; | ||
|
|
||
| packet.voltage_battery = inv_convert_range<uint8_t>(data_struct.voltage_data.v_battery, 16); | ||
| packet.barometer_temp = inv_convert_range<int16_t>(data_struct.barometer_data.temperature, 256); | ||
|
|
||
| return packet; | ||
| } | ||
|
|
||
| void Telemetry::bufferData() { | ||
| #ifdef ENABLE_TELEMETRY | ||
| #ifndef TLM_DEBUG | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -37,6 +37,7 @@ struct TelemetryDataLite { | |
| }; | ||
|
|
||
| struct TelemetryPacket { | ||
| unsigned short idx = 0; | ||
| TelemetryDataLite datapoints[4]; | ||
| float gps_lat; | ||
| float gps_long; | ||
|
|
@@ -68,6 +69,25 @@ struct TelemetryPacket { | |
| int16_t barometer_temp; //[-128, 128] | ||
| }; | ||
|
|
||
| struct CompactTelemetryPacket { | ||
| unsigned short idx = 1; | ||
| float gps_lat; | ||
| float gps_long; | ||
| float gps_alt; | ||
| uint8_t voltage_battery; //[0, 16] | ||
| int16_t barometer_temp; //[-128, 128] | ||
| }; | ||
|
|
||
| struct Packets { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Clarify the reasoning for having both possible messages defined in this singular struct in a comment. Another possibility would just be to separate the structs completely, but this does seem nice so a comment describing the design would help. |
||
| enum { | ||
| COMPACT, | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: Since in the future we may define more packet types, let's make the names a bit more descriptive. For example, COMPACT could be named PAD_LANDED and DEFAULT could be named MAIN_FLIGHT etc. |
||
| DEFAULT, | ||
| } type; | ||
|
|
||
| TelemetryPacket default_packet; | ||
| CompactTelemetryPacket compact_packet; | ||
| }; | ||
|
|
||
| // Commands transmitted from ground station to rocket | ||
| enum CommandType { SET_FREQ, SET_CALLSIGN, ABORT, TEST_FLAPS, EMPTY }; | ||
|
|
||
|
|
@@ -117,4 +137,6 @@ class Telemetry { | |
| command_handler_struct freq_status = {}; | ||
|
|
||
| TelemetryPacket makePacket(const sensorDataStruct_t& data_struct); | ||
|
|
||
| CompactTelemetryPacket makeCompactPacket(const sensorDataStruct_t& data_struct); | ||
| }; | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's avoid using auto lol
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also I might be wrong, but I think you can also use the
getActiveFSM()function to get the state, it would make this line a little more clear. See how it's obtained inController::ActiveControl_ON()inActiveControl.cpp