WarpTwin
Documentation for WarpTwin models and classes.
Loading...
Searching...
No Matches
warpos::OS Class Reference

Holds all os-specific interfaces. More...

#include <OS.h>

Public Member Functions

 OS ()
virtual ~OS ()
virtual int16 startup ()
 Initialize the os.
virtual clockwerk::Time systemTime ()
 Retrieves the system base time.
virtual clockwerk::Time navigationTime ()
 Retrieves the system navigation time.
virtual int16 delay (const clockwerk::Time &delay_time)
 Delay the current task or thread.
virtual int16 yield ()
 Yield the current task or thread.
virtual int16 delayUntil (const clockwerk::Time &wake_time)
 Delay the current task or thread until the specified time.
virtual void startTimer ()
 Start a timer in the system.
virtual uint64 stopTimer ()
 Stop the system timer and return the result.
virtual int16 sysLog (floating_point sys_time, const char *app, const char *message, uint16 msg_size)
 Write a system log (or terminal output, or file).
virtual int32 openFile (const char *filename, uint8 desc=file_descriptors_e::WRITE|file_descriptors_e::READ|file_descriptors_e::OPEN_ALWAYS)
 Opens a file with the specified filename.
virtual uint32 fileSize (int32 fd)
 Opens a file with the specified filename, used for reading.
virtual int16 closeFile (int32 fd)
 Close the file at the file descriptor.
virtual int16 writeFile (int32 fd, const char *buffer, uint32 size)
 Writes data to an open file.
virtual uint32 readFile (int32 fd, char *buffer, int32 size)
 Reads data from an open file.
virtual int16 flushFile (int32 fd)
 Flushes any buffered data to the file associated with the given file descriptor.
virtual int32 getSysLogFD ()
 Gets the file descriptor for the system log.
virtual int32 openBroadcastSocket ()
 Opens a broadcast socket for sending data.
virtual int16 sendBroadcastSocket (int32 sock_fd, const char *address, uint32 port, const char *buffer, uint32 len)
 Sends data over a broadcast socket.
virtual int32 openListenerSocket (const char *address, uint32 port)
 Opens a listener socket to receive data.
virtual uint32 readListenerSocket (int32 sock_fd, char *buffer, uint32 max_len)
 Reads data from a listener socket.

Detailed Description

Holds all os-specific interfaces.

The OS class is the warpOS 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()

warpos::OS::OS ( )
inline

◆ ~OS()

virtual warpos::OS::~OS ( )
inlinevirtual

Member Function Documentation

◆ closeFile()

virtual int16 warpos::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 warpos::OS::delay ( const clockwerk::Time & delay_time)
inlinevirtual

Delay the current task or thread.

Parameters
delay_timeThe amount of time to delay for
Returns
Pointer to a clockwerk::Time object representing the system time.

◆ delayUntil()

virtual int16 warpos::OS::delayUntil ( const clockwerk::Time & wake_time)
inlinevirtual

Delay the current task or thread until the specified time.

Parameters
wake_timeThe time to wake the task or thread
Returns
Error code corresponding to success/failure

◆ fileSize()

virtual uint32 warpos::OS::fileSize ( int32 fd)
inlinevirtual

Opens a file with the specified filename, used for reading.

Parameters
fdFile descriptor to check
Returns
File size

◆ flushFile()

virtual int16 warpos::OS::flushFile ( int32 fd)
inlinevirtual

Flushes any buffered data to the file associated with the given file descriptor.

Parameters
fdThe file descriptor of the open file to flush.
Returns
NO_ERROR on success, or an error code on failure.

◆ getSysLogFD()

virtual int32 warpos::OS::getSysLogFD ( )
inlinevirtual

Gets the file descriptor for the system log.

Returns
file descriptor for the system log

◆ navigationTime()

virtual clockwerk::Time warpos::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 warpos::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 warpos::OS::openFile ( const char * filename,
uint8 desc = file_descriptors_e::WRITE | file_descriptors_e::READ | file_descriptors_e::OPEN_ALWAYS )
inlinevirtual

Opens a file with the specified filename.

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

◆ openListenerSocket()

virtual int32 warpos::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 warpos::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 warpos::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 warpos::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.

◆ startTimer()

virtual void warpos::OS::startTimer ( )
inlinevirtual

Start a timer in the system.

◆ startup()

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

Initialize the os.

Returns
Error code corresponding to success/failure

◆ stopTimer()

virtual uint64 warpos::OS::stopTimer ( )
inlinevirtual

Stop the system timer and return the result.

Returns
The time since startTimer, in microseconds

◆ sysLog()

virtual int16 warpos::OS::sysLog ( floating_point 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 warpos::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 warpos::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.

◆ yield()

virtual int16 warpos::OS::yield ( )
inlinevirtual

Yield the current task or thread.

Returns
Error code corresponding to success/failure

The documentation for this class was generated from the following file:
  • /Users/mickey/Documents/Projects/warptwin/warpos/src/flight/OS.h