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

Update function calls for comDriver headers #213

Merged
merged 1 commit into from
Jul 31, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ int main(int argc, char* argv[]) {

// Setup, cycle, and teardown topology
{{cookiecutter.deployment_name}}::setupTopology(inputs);
{{cookiecutter.deployment_name}}::startSimulatedCycle(1000); // Program loop cycling rate groups at 1Hz
{{cookiecutter.deployment_name}}::startSimulatedCycle(Fw::Time(1,0)); // Program loop cycling rate groups at 1Hz
{{cookiecutter.deployment_name}}::teardownTopology(inputs);
(void)printf("Exiting...\n");
return 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,15 +159,15 @@ void setupTopology(const TopologyState& state) {
Os::TaskString name("ReceiveTask");
// Uplink is configured for receive so a socket task is started
comDriver.configure(state.hostname, state.port);
comDriver.startSocketTask(name, true, COMM_PRIORITY, Default::STACK_SIZE);
comDriver.start(name, true, COMM_PRIORITY, Default::STACK_SIZE);
}
{%- elif cookiecutter.com_driver_type == "UART" %}
if (state.uartDevice != nullptr) {
Os::TaskString name("ReceiveTask");
// Uplink is configured for receive so a socket task is started
if (comDriver.open(state.uartDevice, static_cast<Drv::LinuxUartDriver::UartBaudRate>(state.baudRate),
Drv::LinuxUartDriver::NO_FLOW, Drv::LinuxUartDriver::PARITY_NONE, Svc::DeframerCfg::RING_BUFFER_SIZE)) {
comDriver.startReadThread(COMM_PRIORITY, Default::STACK_SIZE);
comDriver.start(COMM_PRIORITY, Default::STACK_SIZE);
} else {
printf("Failed to open UART device %s at baud rate %" PRIu32 "\n", state.uartDevice, state.baudRate);
}
Expand All @@ -179,15 +179,15 @@ void setupTopology(const TopologyState& state) {
Os::Mutex cycleLock;
volatile bool cycleFlag = true;

void startSimulatedCycle(U32 milliseconds) {
void startSimulatedCycle(Fw::Time interval) {
cycleLock.lock();
bool cycling = cycleFlag;
cycleLock.unLock();

// Main loop
while (cycling) {
{{cookiecutter.deployment_name}}::blockDrv.callIsr();
Os::Task::delay(milliseconds);
Os::Task::delay(interval);

cycleLock.lock();
cycling = cycleFlag;
Expand All @@ -209,10 +209,10 @@ void teardownTopology(const TopologyState& state) {
// Other task clean-up.
{%- if cookiecutter.com_driver_type == "UART" %}
comDriver.quitReadThread();
(void)comDriver.join(nullptr);
(void)comDriver.join();
{%- else %}
comDriver.stopSocketTask();
(void)comDriver.joinSocketTask(nullptr);
comDriver.stop();
(void)comDriver.join();
{%- endif %}

// Resource deallocation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ void teardownTopology(const TopologyState& state);
*
* \param milliseconds: milliseconds to delay for each cycle. Default: 1000 or 1Hz.
*/
void startSimulatedCycle(U32 milliseconds = 1000);
void startSimulatedCycle(Fw::Time interval = Fw::Time(1,0));

/**
* \brief stop the simulated cycle started by startSimulatedCycle
Expand Down
Loading