-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FWXV-221 Added telemetry project (#213)
* FWXV-221 Added telemetry project * FWXV-221 Deleting unnecessary file * Not sure why these extra files are being generated, getting rid of them
- Loading branch information
1 parent
266fafb
commit bab1374
Showing
5 changed files
with
96 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,4 +27,4 @@ | |
- new_can | ||
- can_communication | ||
- can_debug | ||
|
||
- telemetry |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--- | ||
Messages: | ||
test_msg: | ||
id: 0 | ||
target: | ||
telemetry: | ||
watchdog: 0 | ||
critical: true | ||
signals: | ||
test: | ||
length: 8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<!-- | ||
General guidelines | ||
These are just guidelines, not strict rules - document however seems best. | ||
A README for a firmware-only project (e.g. Babydriver, MPXE, bootloader, CAN explorer) should answer the following questions: | ||
- What is it? | ||
- What problem does it solve? | ||
- How do I use it? (with usage examples / example commands, etc) | ||
- How does it work? (architectural overview) | ||
A README for a board project (powering a hardware board, e.g. power distribution, centre console, charger, BMS carrier) should answer the following questions: | ||
- What is the purpose of the board? | ||
- What are all the things that the firmware needs to do? | ||
- How does it fit into the overall system? | ||
- How does it work? (architectural overview, e.g. what each module's purpose is or how data flows through the firmware) | ||
--> | ||
# telemetry | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"libs": [ | ||
"FreeRTOS", | ||
"ms-common" | ||
], | ||
"can": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
#include "can.h" | ||
#include "can_board_ids.h" | ||
#include "log.h" | ||
#include "tasks.h" | ||
|
||
#define TARGET_HEX_MASK 0xF0 | ||
#define TARGET_BIT_SHIFT 4 | ||
#define SIZE_OF_UINT32 4 | ||
|
||
// Add telemetry CAN message IDs here | ||
static const CanMessageId telemetry_ids[] = { | ||
SYSTEM_CAN_MESSAGE_TELEMETRY_TEST_MSG, | ||
}; | ||
|
||
static CanStorage s_can_storage = { 0 }; | ||
const CanSettings can_settings = { | ||
.device_id = 0x1, | ||
.bitrate = CAN_HW_BITRATE_500KBPS, | ||
.tx = { GPIO_PORT_A, 12 }, | ||
.rx = { GPIO_PORT_A, 11 }, | ||
.loopback = true, | ||
.mode = CAN_ONE_SHOT_MODE, | ||
}; | ||
|
||
// Function to pop CAN messages off the queue if they are addressed to telemetry | ||
StatusCode telemetry_queue_pop(CanMessage *msg) { | ||
if (can_receive(msg) == STATUS_CODE_OK) { | ||
for (uint8_t i = 0; i < sizeof(telemetry_ids) / SIZE_OF_UINT32; i++) { | ||
if (telemetry_ids[i] == msg->id.raw) { | ||
return STATUS_CODE_OK; | ||
} | ||
} | ||
} | ||
memset(msg, 0, sizeof(*msg)); | ||
return STATUS_CODE_EMPTY; | ||
} | ||
|
||
// Sample task using telemetry_queue_pop to receive telemetry messages | ||
TASK(master_task, TASK_MIN_STACK_SIZE) { | ||
CanMessage msg = { 0 }; | ||
while (true) { | ||
if (telemetry_queue_pop(&msg) == STATUS_CODE_OK) { | ||
LOG_DEBUG("Received a message!\n"); | ||
} | ||
} | ||
} | ||
|
||
int main() { | ||
tasks_init(); | ||
log_init(); | ||
|
||
LOG_DEBUG("Welcome to Telemetry!\n"); | ||
can_init(&s_can_storage, &can_settings); | ||
|
||
tasks_init_task(master_task, TASK_PRIORITY(2), NULL); | ||
|
||
tasks_start(); | ||
|
||
LOG_DEBUG("exiting main?\n"); | ||
return 0; | ||
} |