- C2A (Command Centric Architecture) is an architecture for spacecraft flight software developed by ISSL.
- S2E can execute C2A as flight software for onboard algorithm development and debugging.
- This document describes how to integrate the C2A within S2E.
- Notes
- C2A is written in C language, but S2E builds C2A as C++.
- The supported version of this document
- Please confirm that the version of the documents and s2e-core are compatible.
- Directory Construction
- Make
FlightSW
directory at same directory withs2e-core
ands2e-user
. - Make a
c2a-user
directory inFlightSW
and set the C2A source code you want to use.├─ FlightSW │ └─ c2a-user │ └─ src_user │ └─ src_core └─ s2e-user-example ├─ s2e-core └─ ExtLibraries
- Edit
s2e-user/CMakeLists.txt
as follows.set(C2A_NAME "c2a_oss")
- Edit the directory name
c2a_oss
according to your situation. - In the case of the above directory structure, you need to edit as
c2a-user
- Edit the directory name
option(USE_C2A "Use C2A" OFF)
- Turn on the
USE_C2A
flag asoption(USE_C2A "Use C2A" ON)
- Turn on the
- Make
- Notes
- In the default setting of S2E, C2A is built but isn't executed. To execute the C2A, users need to add an onboard computer, which can execute the C2A.
- The
s2e-core
has the ObcWithC2a class as a component, and users can use it to execute the C2A. - Users can use the
ObcWithC2a
class in theUserComponents
class, the same as other components.
- Build the
s2e_user
- Note: When you add new source files in the C2A, you need to modify the
c2a-user/CMakeLists.txt
to compile them in the S2E. - Users can choose the construction of CMake as users need. For example, the sample codes have several
CMakeLists.txt
files in each directory to set the compile targets, so users need to modify them to add the target source codes.
- Note: When you add new source files in the C2A, you need to modify the
-
Sample codes
- A sample of s2e-user: s2e-user-example/sample/how-to-integrate-c2a
- A sample of c2a-user: C2A minimum user in
c2a-core
.
-
Preparing development environment
-
Clone the
s2e-user-example
and switch the branch tosample/how-to-integrate-c2a
. -
Make
FlightSW
directory at same directory withs2e-core
. -
Clone
c2a-core v3.8.0
in theFlightSW
directory. -
Execute setup script
- Mac or Linux Users:
c2a-core/setup.sh
- Windows Users:
c2a-core/setup.bat
- Mac or Linux Users:
-
Open
s2e-user-for-c2a-core/CMakeLists.txt
and editset(C2A_NAME "c2a_sample")
toset(C2A_NAME "c2a-core/Examples/minimum_user")
-
For users who don't use Windows
- open
c2a-core/Examples/minimum_user/CMakeLists.txt
and editoption(USE_SCI_COM_WINGS "Use SCI_COM_WINGS" ON)
tooption(USE_SCI_COM_WINGS "Use SCI_COM_WINGS" OFF)
- This setting turns off the feature to communicate with WINGS ground station. Currently, this feature is available only for Windows users.
- open
-
Please check the following directory construction
├─ FlightSW │ └─ c2a-core │ └─ Examples │ └─ minimum_user └─ s2e-user-example ├─ s2e-core └─ ExtLibraries
-
Build and execute the
s2e-user-example
. -
Users can see the following output in a terminal. The
CYCLE: TOTAL
value is incremented.
-
- Generally, communication between flight software and S2E is executed via
OnBoardComputer
class. - The
OnBoardComputer
class has communication ports and communication functions. Other components and flight software can use the communication functions to communicate each other. - For C2A, the
ObcWithC2a
has the following functions for C2A flight software. The driver functions in the flight software can use these functions. It is essential to use the sameport_id
with the component setting in S2E. The details are described in specification documents for each feature.- Serial communication functions
int OBC_C2A_SendFromObc(int port_id, unsigned char* buffer, int offset, int count); int OBC_C2A_ReceivedByObc(int port_id, unsigned char* buffer, int offset, int count);
- I2C communication functions
int OBC_C2A_I2cWriteCommand(int port_id, const unsigned char i2c_addr, const unsigned char* data, const unsigned char len); int OBC_C2A_I2cWriteRegister(int port_id, const unsigned char i2c_addr, const unsigned char* data, const unsigned char len); int OBC_C2A_I2cReadRegister(int port_id, const unsigned char i2c_addr, unsigned char* data, const unsigned char len);
- GPIO
int OBC_C2A_GpioWrite(int port_id, const bool is_high); bool OBC_C2A_GpioRead(int port_id);
- Serial communication functions
- Currently, the C2A uses the wrapper functions in IfWrapper/Sils. The functions automatically overload the normal IfWrapper functions when C2A is executed on the S2E.
- Other interfaces like SPI, etc., will be implemented.
-
This section shows an example of communication between a component in S2E and an application in C2A.
-
The sample codes
-
Preparation
- See
Ch. 3 How to build C2A in S2E with the sample codes
.
- See
-
Modification of the S2E side
- Users can use the ExampleSerialCommunicationWithObc class in
s2e-core
as a test component to communicate with C2A. - Please refer the sample codes in s2e-user-example/sample/how-to-integrate-c2a.
- Add
ExampleSerialCommunicationWithObc
as a component inuser_components.cpp and .hpp
.- In this example, the
ObcWithC2a
is executed as 1kHz, and theExampleSerialCommunicationWithObc
is executed as 1Hz.
- In this example, the
- Users can use the ExampleSerialCommunicationWithObc class in
-
Modification of the C2A side
- Please refer the sample codes in
Tutorials/SampleCodes/c2a_integration/c2a_src_user
.- The directory structure of
c2a_src_user
is the same with that ofc2a-core/Examples/minimum_user/src/src_user
.
- The directory structure of
- We need to add a new driver instance application to communicate with the
ExampleSerialCommunicationWithObc
component.- Copy
Application/DriverInstances/di_s2e_uart_test.c and .h
- Edit
CMakeLists.txt
in the Application directory to adddi_s2e_uart_test.c
as a compile target.
- Copy
- Edit
app_registry.c, h
andapp_headers.h
in theApplication
directory to register the applications ofdi_s2e_uart_test
.- We have two applications
AR_DI_S2E_UART_TEST
andAR_DI_DBG_S2E_UART_TEST
.
- We have two applications
- Edit
Setting/Modes/TaskLists/Elements/tl_elem_drivers_update.c
to add theAR_DI_S2E_UART_TEST
to execute the application in the tasklist. - Edit
Setting/Modes/TaskLists/Elements/tl_elem_debug_display.c
to add theAR_DI_DBG_S2E_UART_TEST
to execute the application in the tasklist.
- Please refer the sample codes in
-
Execution and Result
-
The C2A's
AR_DI_S2E_UART_TEST
application sends characters to the S2E'sExampleSerialCommunicationWithObc
component likeSETA, SETB, SETC, ..., SETZ, SETA
-
The
ExampleSerialCommunicationWithObc
component receives the characters and stores the set characters likeA, B, C, ..., Z, A
-
The
ExampleSerialCommunicationWithObc
component sends the stored characters as telemetry likeA, BA, CBA, ..., ZYX
-
The
AR_DI_S2E_UART_TEST
application receives the telemetry, and theAR_DI_DBG_S2E_UART_TEST
application prints the first three characters in the debug output console like the following figure.
-