Nut/OS  5.0.5
API Reference
System Configuration

Nut/OS configuration structure. More...

Collaboration diagram for System Configuration:

Data Structures

struct  _CONFOS
 Operating system configuration structure. More...

Defines

#define CONFOS_EE_OFFSET   0
 Non-volatile memory location.
#define CONFOS_EE_MAGIC   "OS"
#define MAX_HOSTNAME_LEN   15
 Maximum number of characters allowed for hostname.
#define CONFOS_VIRGIN_HOSTNAME   "ethernut"
 Default hostname.

Typedefs

typedef struct _CONFOS CONFOS
 Operating system configuration type.

Functions

int NutLoadConfig (void)
 Load Nut/OS configuration from non-volatile memory.
int NutSaveConfig (void)
 Save Nut/OS configuration in non-volatile memory.

Variables

CONFOS confos
 Global system configuration structure.
CONFOS confos
 Global system configuration structure.

Detailed Description

Nut/OS configuration structure.


Define Documentation

#define CONFOS_EE_OFFSET   0

Non-volatile memory location.

Offset into non-volatile memory, where Nut/OS stores the system configuration. The default may be overridden by the Configurator.

Referenced by NutLoadConfig(), and NutSaveConfig().

#define CONFOS_EE_MAGIC   "OS"

Referenced by NutLoadConfig(), and NutSaveConfig().

#define MAX_HOSTNAME_LEN   15

Maximum number of characters allowed for hostname.

Intentionally not MAXHOSTNAMELEN to avoid conflicts with existing C libraries.

Referenced by NutSaveConfig().

#define CONFOS_VIRGIN_HOSTNAME   "ethernut"

Default hostname.

Used on virgin systems without any valid configuration.

Referenced by NutLoadConfig().


Typedef Documentation

typedef struct _CONFOS CONFOS

Operating system configuration type.


Function Documentation

int NutLoadConfig ( void  )

Load Nut/OS configuration from non-volatile memory.

This routine is automatically called during system initialization. It tries to read the OS configuration structure CONFOS from non-volatile memory, starting at /ref CONFOS_EE_OFFSET.

The routine may fail, if

  • non-volatile memory is not supported,
  • non-volatile memory contains invalid data,
  • the configuration structure has changed.
Returns:
0 if OK, -1 on failures, in which case the hostname will be set to CONFOS_VIRGIN_HOSTNAME.

References CONFOS_EE_MAGIC, CONFOS_EE_OFFSET, CONFOS_VIRGIN_HOSTNAME, _CONFOS::hostname, _CONFOS::magic, memcmp(), NUTASSERT, NutNvMemLoad(), _CONFOS::size, strcpy(), and strlen().

Referenced by main(), and NutIdle().

Here is the call graph for this function:

int NutSaveConfig ( void  )

Save Nut/OS configuration in non-volatile memory.

Since Nut/OS version 4.7.5, this routine is no longer called automatically during system initialization. Thus, if NutLoadConfig() fails, then the non-volatile memory remains invalid and NutLoadConfig() will again fail during the next system start.

Returns:
0 if OK, -1 on failures.

References CONFOS_EE_MAGIC, CONFOS_EE_OFFSET, _CONFOS::hostname, _CONFOS::magic, MAX_HOSTNAME_LEN, memcpy(), NUTASSERT, NutNvMemSave(), _CONFOS::size, and strlen().

Referenced by NutDiscoveryAppConf().

Here is the call graph for this function:


Variable Documentation

Global system configuration structure.

Contains the current system configuration. Nut/OS will load this structure from non-volatile memory during initialization.

Referenced by MibRegisterSysVars(), NutDiscoveryAnnTele(), NutDiscoveryAppConf(), and syslog_header().

Global system configuration structure.

Contains the current system configuration. Nut/OS will load this structure from non-volatile memory during initialization.

Referenced by MibRegisterSysVars(), NutDiscoveryAnnTele(), NutDiscoveryAppConf(), and syslog_header().