Module atomvm
AtomVM-specific APIs.
Description
This module contains functions that are specific to the AtomVM platform.
Data Types
avm_path()
avm_path() = string() | binary()
platform_name()
platform_name() = generic_unix | emscripten | esp32 | pico | stm32
Function Index
add_avm_pack_binary/2 | Add code from an AVM binary to your application. |
add_avm_pack_file/2 | Add code from an AVM binary to your application. |
close_avm_pack/2 | Close previously opened AVM binary from your application. |
platform/0 | Return the platform moniker. |
rand_bytes/1 | Returns a binary containing random sequence of bytes of length Len. |
random/0 | Returns a random 32-bit integer value. |
read_priv/2 | This function allows to fetch priv/ resources content. |
Function Details
add_avm_pack_binary/2
add_avm_pack_binary(AVMData::binary(), Options::[{name, Name::atom()}]) -> ok
AVMData
: AVM data.Options
: Options, as a property list.
returns: ok
Add code from an AVM binary to your application.
This function will add the data in the AVMData
parameter to
your application. The data is assumed to be valid AVM data (e.g, as
generated by packbeam tooling).
Failure to properly load AVM data is result in a runtime error
add_avm_pack_file/2
add_avm_pack_file(AVMPath::avm_path(), Options::[]) -> ok
AVMPath
: Path to AVM data.Options
: Options, as a property list.
returns: ok
Add code from an AVM binary to your application.
This function will add the data located in the AVMPath
parameter to
your application. The data is assumed to be valid AVM data (e.g, as
generated by packbeam tooling).
On generic_unix
platforms, the AVMPath
may be a valid file system
path to an AVM file.
On esp32
platforms, the AVMPath
should be the name of an ESP32
flash partition, prefixed with the string
/dev/partition/by-name/
. Thus, for example, if you specify
/dev/partition/by-name/main2.app
as the AVMPath
, the ESP32
flash should contain a data partition with the
name main2.app
Failure to properly load AVM path is result in a runtime error
close_avm_pack/2
close_avm_pack(Name::atom(), Options::[]) -> ok | error
Options
: Options, as a property list.
returns: ok | error
Close previously opened AVM binary from your application.
This function will close the data referenced by the Name
parameter from
your application. The Name
parameter must reference previously
opened AVM data.
Failure to close AVM data is result in a runtime error
platform/0
platform() -> platform_name()
returns: The platform name.
Return the platform moniker. You may use this function to uniquely identify the platform type on which your application is running.
rand_bytes/1
rand_bytes(Len::non_neg_integer()) -> binary()
Len
: non-negative integer
returns: Binary containing random sequence of bytes of length Len.
Returns a binary containing random sequence of bytes of length Len. Supplying a negative value will result in a badarg error. This function will use a cryptographically strong RNG if available. Otherwise, the random value is generated using a PRNG.
random/0
random() -> integer()
returns: random 32-bit integer.
Returns a random 32-bit integer value. This function will use a cryptographically strong RNG if available. Otherwise, the random value is generated using a PRNG.
read_priv/2
read_priv(App::atom(), Path::list()) -> binary()
App
: application name.Path
: path to the resource.
returns: Binary containing the resource content.
This function allows to fetch priv/ resources content.