class::sys::Sys

class sys::Sys
  : public fs::File

This class allows access to system attributes and functions.

Summary

Sys()

int get_board_config(

sos_board_config_t & config
)

int get_id(

sys_id_t & id
)

int get_info(

sys_info_t & attr
)

int open()

static void assign_zero_sum32(

void * data,
int size
)

static int free_ram(

const char * path,
arg::LinkDriver driver
)

static SysInfo get_info()

static var::String get_kernel_version()

static SerialNumber get_serial_number()

static int get_version(

var::String & version
)

static var::String get_version()

static int hibernate(

const chrono::Milliseconds & milliseconds
)

static var::String install(

const var::ConstString & path,
int options,
int ram_size
)

static var::String install(

const var::ConstString & path,
int options,
int ram_size,
const sys::ProgressCallback * progress_callback
)

static int launch(

const var::ConstString & path,
const var::ConstString & args,
int options,
int ram_size
)

static int launch(

const var::ConstString & path,
const var::ConstString & args,
var::String & exec_destination,
int options,
int ram_size,
const sys::ProgressCallback * progress_callback,
const var::ConstString & envp
)

static void powerdown(

const chrono::Milliseconds & milliseconds
)

static int reclaim_ram(

const char * path,
arg::LinkDriver driver
)

static void redirect_stderr(

const arg::FileDescriptor fd
)

static void redirect_stdin(

const arg::FileDescriptor fd
)

static void redirect_stdout(

const arg::FileDescriptor fd
)

static int request(

const arg::KernelRequest req,
arg::DestinationBuffer arg
)

template<>
static const T * request_api(

int request
)

static void reset()

static int verify_zero_sum32(

void * data,
int size
)

static const char * version()

enum @22

Members

Sys()

int get_board_config(

sos_board_config_t & config
)

Loads the board configuration provided as part of the board support package.

Parameters

  • config A reference to the destination object

Returns

Zero on success

The object must be opened before calling this method.

See also: open()


int get_id(

sys_id_t & id
)

Loads the cloud kernel ID.

Parameters

  • id A reference to the destination data

Returns

Less than zero if the operation failed

The object must be opened before calling this method.


int get_info(

sys_info_t & attr
)

Loads the current system info.

Parameters

  • attr A reference to where the data should be stored

Returns

Zero on success

The object must be opened before calling this method.

See also: open()


int open()

Opens /dev/sys.

Returns

Less than zero for an error


static void assign_zero_sum32(

void * data,
int size
)


static int free_ram(

const char * path,
arg::LinkDriver driver
)

Frees the RAM associated with the app without deleting the code from flash (should not be called when the app is currently running).

Parameters

  • path The path to the app (use exec_dest from launch())

  • driver Used with link protocol only

Returns

Zero on success

This method can causes problems if not used correctly. The RAM associated with the app will be free and available for other applications. Any applications that are using the RAM must quit before the RAM can be reclaimed using reclaim_ram().

See also: reclaim_ram()


static SysInfo get_info()

Loads the current system info.


static var::String get_kernel_version()

Gets the version (kernel version).

Parameters

  • version The destination string for the version

Returns

Zero on success


static SerialNumber get_serial_number()

static int get_version(

var::String & version
)

Gets the version (system/board version).

Parameters

  • version The destination string for the version

Returns

Zero on success


static var::String get_version()

static int hibernate(

const chrono::Milliseconds & milliseconds
)

Puts the kernel in hibernate mode.

Parameters

  • timeout_msec The number of milliseconds before the device will wake up from hibernation. If this isn’t supported, the device will stay in hibernation until woken up externally

static var::String install(

const var::ConstString & path,
int options,
int ram_size
)

Installs an application from the data filesystem to the application filesystem.

Parameters

  • path The path to the source application to install

  • options The installation flag options

  • ram_size The number of bytes to allow for the application’s data section

Returns

Zero on success or less than zero with errno set.


static var::String install(

const var::ConstString & path,
int options,
int ram_size,
const sys::ProgressCallback * progress_callback
)

Installs an application from the data filesystem to the application filesystem.

Parameters

  • path The path to the source file.

  • options The installation options.

  • ram_size The number of bytes to allow for the application’s data section.

  • progress_callback A pointer to a callback to indicate the installation progress.

Returns


static int launch(

const var::ConstString & path,
const var::ConstString & args,
int options,
int ram_size
)

Launches a new application.

Parameters

  • path The path to the application

  • args The arguments to pass to the applications

  • options For example: LAUNCH_OPTIONS_FLASH | LAUNCH_OPTIONS_STARTUP

  • ram_size The amount of RAM that will be used by the app

Returns

The process ID of the new app if successful

This method must be called locally in an app. It can’t be executed over the link protocol.


static int launch(

const var::ConstString & path,
const var::ConstString & args,
var::String & exec_destination,
int options,
int ram_size,
const sys::ProgressCallback * progress_callback,
const var::ConstString & envp
)

Launches a new application.

Parameters

  • path The path to the application

  • exec_dest A pointer to a buffer where the execution path will be written (null if not needed)

  • args The arguments to pass to the applications

  • options For example: LAUNCH_OPTIONS_FLASH | LAUNCH_OPTIONS_STARTUP

  • ram_size The amount of RAM that will be used by the app (0 assumes default value)

  • update_progress A callback to show the progress if the app needs to be installed (copied to flash/RAM)

  • envp Not used (leave as default empty string)

Returns

The process ID of the new app if successful


static void powerdown(

const chrono::Milliseconds & milliseconds
)

Puts the kernel in powerdown mode.

Parameters

  • timeout_msec The number of milliseconds before the device will power on (reset). If this isn’t supported, the device will power off until reset by an external signal

static int reclaim_ram(

const char * path,
arg::LinkDriver driver
)

Reclaims RAM that was freed using free_ram().

Parameters

  • path The path to the app

  • driver Used with link protocol only

Returns

Zero on success

See also: free_ram()


static void redirect_stderr(

const arg::FileDescriptor fd
)

Redirects the standard error from the specified file descriptor.

Parameters

  • fd The open and writable file descriptor to use for standard input

See Sys::redirect_stdout() for an example.


static void redirect_stdin(

const arg::FileDescriptor fd
)

Redirects the standard input from the specified file descriptor.

Parameters

  • fd The open and readable file descriptor to use for standard input

See Sys::redirect_stdout() for an example.


static void redirect_stdout(

const arg::FileDescriptor fd
)

Redirects the standard output to the file specified.

Parameters

  • fd The file descriptor where the standard output should be directed.

The file desriptor should be open and ready for writing. For example, to redirect the standard output to the UART:

#include <sapi/sys.hpp>
#include <sapi/hal.hpp>

Uart uart(0);
uart.init(); //initializes uart using default settings (if available)
Sys::redirect_stdout( uart.fileno() );
printf("This will be written to UART0\n");

static int request(

const arg::KernelRequest req,
arg::DestinationBuffer arg
)

Executes a kernel request.

Parameters

  • req The request number

  • arg Argument pointer

Returns

The result of the execution of the request. (-1 if request is not available)

The kernel request must be defined and implemented by the board support package.


template<>

static const T * request_api(

int request
)

Request a kernel install library’s API.

Parameters

  • request The API request value (ie SAPI_API_REQUEST_ARM_DSP)

Returns

A pointer to the api_t.

This method will request a library API from the kernel. If the library is install in the kernel. This method will return a pointer to the api. Otherwise, zero will be retured. It is possible for the application to link directly to the library if the library is not provided by the kernel.


static void reset()

Forces a reset of the device.


static int verify_zero_sum32(

void * data,
int size
)


static const char * version()

Returns a c style string pointer to the API version.

This version is 2.4.0


enum @22
  • LAUNCH_OPTIONS_FLASH Install in flash memory
  • LAUNCH_OPTIONS_RAM Install in ram memory (default behavior)
  • LAUNCH_OPTIONS_STARTUP Run at startup (must be in flash)
  • LAUNCH_OPTIONS_ROOT Run as root (if applicable)
  • LAUNCH_OPTIONS_REPLACE Delete if application exists and install in the same location
  • LAUNCH_OPTIONS_ORPHAN If this option is not set, the calling process MUST call wait() or waitpid() to finalize the process.
  • LAUNCH_OPTIONS_UNIQUE_NAMES Create a unique name on install
  • LAUNCH_RAM_SIZE_DEFAULT

Options for launching applications.


X

Thanks for Coming!

Subscribe to news and updates