Inheritance diagram for sys::Sys:

Documentation

This class allows access to system attributes and functions.

Public Member Functions

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 ()
 
- Public Member Functions inherited from sys::File
virtual int close ()
 
int create (const char *path, bool overwrite=true, int perms=0666)
 
int fileno () const
 
int flags () const
 
char * gets (var::String &s, char term= '\n') const
 
virtual int ioctl (int req, void *arg) const
 
int ioctl (int req, const void *arg) const
 
int ioctl (int req) const
 
int ioctl (int req, int arg) const
 
int loc () const
 
virtual int open (const char *name, int flags=RDWR)
 
int open (const char *name, int access, int perms)
 
int open_append (const char *path)
 
int open_readonly (const char *path)
 
int open_readwrite (const char *path)
 
virtual int read (void *buf, int nbyte) const
 
int read (int loc, void *buf, int nbyte) const
 
int readline (char *buf, int nbyte, int timeout_msec, char terminator= '\n') const
 
virtual int seek (int loc, int whence=LINK_SEEK_SET) const
 
void set_fileno (int fd)
 
u32 size () const
 
virtual int write (const void *buf, int nbyte) const
 
int write (int loc, const void *buf, int nbyte) const
 
int write (const var::String &str) const
 
- Public Member Functions inherited from api::WorkObject
void clear_error_number () const
 
int error_number () const
 

Static Public Member Functions

static int free_ram (const char *path, link_transport_mdriver_t *driver=0)
 
static int get_kernel_version (var::String &version)
 
static int get_version (var::String &version)
 
static int hibernate (int timeout_msec=0)
 
static int launch (const char *path, char *exec_dest=0, const char *args=0, int options=0, int ram_size=LAUNCH_RAM_SIZE_DEFAULT, int(*update_progress)(int, int)=0, char *const envp[]=0)
 
static void powerdown (int timeout_msec=0)
 
static int reclaim_ram (const char *path, link_transport_mdriver_t *driver=0)
 
static void redirect_stderr (int fd)
 
static void redirect_stdin (int fd)
 
static void redirect_stdout (int fd)
 
static int request (int req, void *arg=0)
 
static void reset ()
 
static const char * version ()
 
- Static Public Member Functions inherited from sys::File
static int access (const char *path, int o_access)
 
static int copy (var::String &source_path, var::String &dest_path)
 
static bool exists (const char *path)
 
static const char * name (const char *path)
 
static int remove (const char *path)
 
static int rename (var::String &old_path, var::String &new_path)
 
static u32 size (const char *path)
 
static int stat (const char *path, struct stat *st)
 
static const char * suffix (const char *path)
 
- Static Public Member Functions inherited from api::ApiObject
static const char * api_version ()
 

Additional Inherited Members

- Public Types inherited from sys::File

Member Enumeration Documentation

anonymous enum
Enumerator
LAUNCH_OPTIONS_FLASH 

Install in flash memory

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

LAUNCH_OPTIONS_ORPHAN 

Allow app to become an orphan

LAUNCH_OPTIONS_UNIQUE_NAMES 

Create a unique name on install

Member Function Documentation

static int sys::Sys::free_ram ( const char *  path,
link_transport_mdriver_t *  driver = 0 
)
static

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

Parameters
pathThe path to the app (use exec_dest from launch())
driverUsed 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()
int sys::Sys::get_board_config ( sos_board_config_t config)

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

Parameters
configA reference to the destination object
Returns
Zero on success

The object must be opened before calling this method.

See also
open()
int sys::Sys::get_id ( sys_id_t &  id)

Loads the cloud kernel ID.

Parameters
idA reference to the destination data
Returns
Less than zero if the operation failed

The object must be opened before calling this method.

int sys::Sys::get_info ( sys_info_t &  attr)

Loads the current system info.

Parameters
attrA reference to where the data should be stored
Returns
Zero on success

The object must be opened before calling this method.

See also
open()
static int sys::Sys::get_kernel_version ( var::String version)
static

Gets the version (kernel version).

Parameters
versionThe destination string for the version
Returns
Zero on success
static int sys::Sys::get_version ( var::String version)
static

Gets the version (system/board version).

Parameters
versionThe destination string for the version
Returns
Zero on success
static int sys::Sys::hibernate ( int  timeout_msec = 0)
static

Puts the kernel in hibernate mode.

Parameters
timeout_msecThe 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 int sys::Sys::launch ( const char *  path,
char *  exec_dest = 0,
const char *  args = 0,
int  options = 0,
int  ram_size = LAUNCH_RAM_SIZE_DEFAULT,
int(*)(int, int)  update_progress = 0,
char *const  envp[] = 0 
)
static

Launches a new application.

Parameters
pathThe path to the application
exec_destA pointer to a buffer where the execution path will be written (null if not needed)
argsThe arguments to pass to the applications
optionsFor example: LAUNCH_OPTIONS_FLASH | LAUNCH_OPTIONS_STARTUP
ram_sizeThe amount of RAM that will be used by the app
update_progressA callback to show the progress if the app needs to be installed (copied to flash/RAM)
envpNot used (set to zero)
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.

int sys::Sys::open ( )
inline

Opens /dev/sys.

Returns
Less than zero for an error
static void sys::Sys::powerdown ( int  timeout_msec = 0)
static

Puts the kernel in powerdown mode.

Parameters
timeout_msecThe 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 sys::Sys::reclaim_ram ( const char *  path,
link_transport_mdriver_t *  driver = 0 
)
static

Reclaims RAM that was freed using free_ram().

Parameters
pathThe path to the app
driverUsed with link protocol only
Returns
Zero on success
See also
free_ram()
static void sys::Sys::redirect_stderr ( int  fd)
inlinestatic

Redirects the standard error from the specified file descriptor.

Parameters
fdThe open and writable file descriptor to use for standard input

See Sys::redirect_stdout() for an example.

static void sys::Sys::redirect_stdin ( int  fd)
inlinestatic

Redirects the standard input from the specified file descriptor.

Parameters
fdThe open and readable file descriptor to use for standard input

See Sys::redirect_stdout() for an example.

static void sys::Sys::redirect_stdout ( int  fd)
inlinestatic

Redirects the standard output to the file specified.

Parameters
fdThe 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 sys::Sys::request ( int  req,
void *  arg = 0 
)
static

Executes a kernel request.

Parameters
reqThe request number
argArgument 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.

static void sys::Sys::reset ( )
static

Forces a reset of the device.

static const char* sys::Sys::version ( )
inlinestatic

Returns a c style string pointer to the API version.

This version is 2.4.0