ModelSpace
Documentation for ModelSpace models and classes.
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
cfspp::OS Class Reference

Holds all os-specific interfaces. More...

#include <OS.h>

Public Member Functions

 OS ()
 
virtual ~OS ()
 
virtual int16 startup ()
 Initialize the os. More...
 
virtual clockwerk::Time systemTime ()
 Retrieves the system base time. More...
 
virtual clockwerk::Time navigationTime ()
 Retrieves the system navigation time. More...
 
virtual int16 delay (const clockwerk::Time &delay_time)
 Retrieves a handle to the system base time. More...
 
virtual int16 sysLog (double sys_time, const char *app, const char *message, uint16 msg_size)
 Write a system log (or terminal output, or file) More...
 
virtual int32 openFile (const char *filename)
 Opens a file with the specified filename. More...
 
virtual int16 closeFile (int32 fd)
 Close the file at the file descriptor. More...
 
virtual int16 writeFile (int32 fd, const char *buffer, uint32 size)
 Writes data to an open file. More...
 
virtual uint32 readFile (int32 fd, char *buffer, int32 size)
 Reads data from an open file. More...
 
virtual int32 openBroadcastSocket ()
 Opens a broadcast socket for sending data. More...
 
virtual int16 sendBroadcastSocket (int32 sock_fd, const char *address, uint32 port, const char *buffer, uint32 len)
 Sends data over a broadcast socket. More...
 
virtual int32 openListenerSocket (const char *address, uint32 port)
 Opens a listener socket to receive data. More...
 
virtual uint32 readListenerSocket (int32 sock_fd, char *buffer, uint32 max_len)
 Reads data from a listener socket. More...
 

Detailed Description

Holds all os-specific interfaces.

The OS class is the cFS++ method for applying the OSAL, or Operating System Abstraction Layer. OS defines all basic interfaces which are typical of an os, such as file I/O, thread scheduling, etc.

The OS class by itself does not do anything. Users seeking to implement OS should create a child class with OS as its base and implement the functions documented herein.

Constructor & Destructor Documentation

◆ OS()

cfspp::OS::OS ( )
inline

◆ ~OS()

virtual cfspp::OS::~OS ( )
inlinevirtual

Member Function Documentation

◆ closeFile()

virtual int16 cfspp::OS::closeFile ( int32  fd)
inlinevirtual

Close the file at the file descriptor.

Parameters
fdThe file to close
Returns
NO_ERROR on success, error on failure

◆ delay()

virtual int16 cfspp::OS::delay ( const clockwerk::Time delay_time)
inlinevirtual

Retrieves a handle to the system base time.

Returns a pointer to the current system time in the form provided by the clockwerk::Time class.

Returns
Pointer to a clockwerk::Time object representing the system time.

◆ navigationTime()

virtual clockwerk::Time cfspp::OS::navigationTime ( )
inlinevirtual

Retrieves the system navigation time.

Returns
A clockwerk::Time object representing the navigation time

The navigation time is a universally achored form of time which is synchronized between the flight vehicle and some ground reference. Often used timesets include GPS time and UTC time. Though the specific implementation varies system-to-system, these are generally stable forms of time, whereas system time may drift over long periods.

◆ openBroadcastSocket()

virtual int32 cfspp::OS::openBroadcastSocket ( )
inlinevirtual

Opens a broadcast socket for sending data.

This function creates and opens a socket that can be used to send broadcast messages over the network.

Returns
Socket file descriptor (int32) on success, or an error code if not implemented.

◆ openFile()

virtual int32 cfspp::OS::openFile ( const char *  filename)
inlinevirtual

Opens a file with the specified filename.

Parameters
filenameThe name of the file to open.
Returns
File descriptor (int32) on success, or an error code if not implemented.

◆ openListenerSocket()

virtual int32 cfspp::OS::openListenerSocket ( const char *  address,
uint32  port 
)
inlinevirtual

Opens a listener socket to receive data.

Creates and binds a socket to the specified address and port for listening to incoming data.

Parameters
addressThe address to bind the listener socket to.
portThe port number to bind the listener socket to.
Returns
Socket file descriptor (int32) on success, or an error code if not implemented.

◆ readFile()

virtual uint32 cfspp::OS::readFile ( int32  fd,
char *  buffer,
int32  size 
)
inlinevirtual

Reads data from an open file.

Parameters
fdThe file descriptor of the open file.
bufferPointer to the buffer where read data will be stored.
sizeThe number of bytes to read into the buffer.
Returns
Number of bytes read

◆ readListenerSocket()

virtual uint32 cfspp::OS::readListenerSocket ( int32  sock_fd,
char *  buffer,
uint32  max_len 
)
inlinevirtual

Reads data from a listener socket.

Reads up to max_len bytes from the specified listener socket into the provided buffer.

Parameters
sock_fdThe file descriptor of the listener socket.
bufferPointer to the buffer where the received data will be stored.
max_lenThe maximum number of bytes to read into the buffer.
Returns
Number of bytes read (uint32), or an error code if not implemented.

◆ sendBroadcastSocket()

virtual int16 cfspp::OS::sendBroadcastSocket ( int32  sock_fd,
const char *  address,
uint32  port,
const char *  buffer,
uint32  len 
)
inlinevirtual

Sends data over a broadcast socket.

Sends the specified buffer to the given address and port using the provided broadcast socket.

Parameters
sock_fdThe file descriptor of the broadcast socket.
addressThe destination address to send the broadcast to.
portThe destination port number.
bufferPointer to the data buffer to send.
lenThe number of bytes to send from the buffer.
Returns
Number of bytes sent (int16), or an error code if not implemented.

◆ startup()

virtual int16 cfspp::OS::startup ( )
inlinevirtual

Initialize the os.

Returns
Error code corresponding to success/failure

◆ sysLog()

virtual int16 cfspp::OS::sysLog ( double  sys_time,
const char *  app,
const char *  message,
uint16  msg_size 
)
inlinevirtual

Write a system log (or terminal output, or file)

Parameters
sys_timeThe time for the log
appThe name of the app to log
messageThe message to write
msg_sizeThe size of the message to write
Returns
Error code corresponding to success/failure

◆ systemTime()

virtual clockwerk::Time cfspp::OS::systemTime ( )
inlinevirtual

Retrieves the system base time.

Returns
A clockwerk::Time object representing the system time.

System base time is a specialized form of time which typically runs on the system oscillator (although the exact details are implementation-specific). System time should be used for low-level utilities, which may range from the scheduler step rate to timing. For utilties which require a universally anchored time, navigationTime() should be used instead.

◆ writeFile()

virtual int16 cfspp::OS::writeFile ( int32  fd,
const char *  buffer,
uint32  size 
)
inlinevirtual

Writes data to an open file.

Parameters
fdThe file descriptor of the open file.
bufferPointer to the data buffer to write.
sizeThe number of bytes to write from the buffer.
Returns
Number of bytes written (int16), or an error code if not implemented.

The documentation for this class was generated from the following file: