Rishka
RISC-V virtual runtime in C/C++ made for ESP32-WROVER
Sys Class Referencefinal

Class for handling system utilities in Rishka applications. More...

#include <sys.h>

Static Public Member Functions

static void delay (u64 ms)
 Delay execution for a specified duration. More...
 
static u64 micros ()
 Get the current system time in microseconds. More...
 
static u64 millis ()
 Get the current system time in milliseconds. More...
 
static i64 shellexec (string cmdline)
 Execute a shell command. More...
 
static void exit (i32 code)
 Terminate the application with an exit code. More...
 
static string info_str (sysinfos_t key)
 Get system information as a string. More...
 
static i64 info_num (sysinfon_t key)
 Get system information as a numeric value. More...
 
static i64 random ()
 Generate a random integer value. More...
 
static bool change_dir (char *directory)
 Changes the current working directory. More...
 
static string working_dir ()
 Retrieves the current working directory. More...
 

Detailed Description

Class for handling system utilities in Rishka applications.

The Sys class provides static methods for delaying execution, accessing system time, executing shell commands, retrieving system information, and exiting the application.

Member Function Documentation

◆ change_dir()

bool Sys::change_dir ( char *  directory)
static

Changes the current working directory.

This static method changes the current working directory to the specified directory.

Parameters
directoryThe directory to change to.
Returns
True if the directory change was successful, false otherwise.

◆ delay()

void Sys::delay ( u64  ms)
static

Delay execution for a specified duration.

This method suspends program execution for the specified number of milliseconds.

Parameters
msThe duration to delay in milliseconds.

◆ exit()

void Sys::exit ( i32  code)
static

Terminate the application with an exit code.

This method terminates the application with the specified exit code.

Parameters
codeThe exit code for the application.

◆ info_num()

i64 Sys::info_num ( sysinfon_t  key)
static

Get system information as a numeric value.

This method retrieves system information specified by the key as a numeric value.

Parameters
keyThe key for the system information.
Returns
The system information as a numeric value.

◆ info_str()

string Sys::info_str ( sysinfos_t  key)
static

Get system information as a string.

This method retrieves system information specified by the key as a string representation.

Parameters
keyThe key for the system information.
Returns
The system information as a string.

◆ micros()

u64 Sys::micros ( )
static

Get the current system time in microseconds.

This method returns the current system time in microseconds since boot.

Returns
The current system time in microseconds.

◆ millis()

u64 Sys::millis ( )
static

Get the current system time in milliseconds.

This method returns the current system time in milliseconds since boot.

Returns
The current system time in milliseconds.

◆ random()

i64 Sys::random ( )
static

Generate a random integer value.

The random() function generates a random integer value within the range supported by the underlying hardware's random number generator. The generated random value is suitable for various applications such as cryptographic operations, simulation, and randomization tasks.

Returns
A random integer value within the supported range.

◆ shellexec()

i64 Sys::shellexec ( string  cmdline)
static

Execute a shell command.

This method executes a shell command with the specified binary program file name, argument count, and argument array.

Parameters
programThe file name of the binary program to execute.
argcThe number of arguments in the argument array.
argvThe array of arguments for the shell command.
Returns
The exit status of the shell command.

◆ working_dir()

string Sys::working_dir ( )
static

Retrieves the current working directory.

This static method returns the current working directory as a string.

Returns
A string representing the current working directory.

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