Skip to content

Create initial state machine firmware #4

@Iyury1

Description

@Iyury1

Summary

The state machine will be a C program similar to the MessageTransfer_RPI program from last year.
https://github.com/albertaloop/T_SWE_2022_2023/tree/master/Firmware/MessageTransfer_RPi/src

The program will be divided up into modular tasks and data structures to maximize portability between microcontrollers.

diagram of the proposed software architecture

state_machine drawio

State Machine Task

This should have its own file with a thread function containing a switch statement. Each case of the switch statement should implement the logic for the current state using a series of function calls. By keeping a small amount of control statements and moving all logic to the individual functions, the state machine should be much more readable.

Before the switch statement is called, we may want to perform common operations such as reading incoming CAN messages and UDP commands. Don't worry too much about implementing every detail yet, just create the state machine switch statement and state variables.

UDP Comms Task

Make a new source file based on udp.c from MessageTransfer_RPI. All UNIX dependencies should exist in this file only. This task will not be portable between operating systems. If we make the state machine using an RTOS, then we likely will not be able to use sockets.

Dont worry about communicating with the state machine task yet. Just make a test program and can send commands and receive telemetry. Just have the server and test client both print the messages they receive.

Main.c

Launch state machine and udp threads using pthreads. This file will also not be portable between operating systems.

Acceptance Criteria

  • State Machine task source file with switch statement and state variables defined.
  • UDP task source file.
  • Run both tasks in separate threads using pthreads
  • UDP test client.
  • Both server and client print out received messages.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions