Skip to content

Latest commit

 

History

History
61 lines (44 loc) · 1.24 KB

DEVELOPER.md

File metadata and controls

61 lines (44 loc) · 1.24 KB

Some notes about the project

xml/

For fetching configuration files from the original project, do

cd xml; make fetch_from_original_nbfc

For translating them to JSON, do

cd xml; make transform_to_json

error.c

For chaining error messages, there is a Error error_stack[16];. Errors can be strings, integers or error codes belonging to an error system.

enum ErrorSystem {
  ErrorSystem_String,
  ErrorSystem_Integer,
  ErrorSystem_Stdlib,
  ErrorSystem_NxJson,
#ifdef HAVE_SENSORS
  ErrorSystem_Sensors,
#endif
};

typedef struct Error Error;
struct Error {
  enum ErrorSystem system;
  union {
    int code;
    const char* message;
  } value;
};

The return value of functions is either a pointer to error_stack or NULL (no error).

OOP

We use the my macro defined in macros.h as a shortcut for (*self).

static Error* Fan_ECWriteValue(Fan* self, int value) {
  return my.readWriteWords
    ? ec->WriteWord(my.fanConfig->WriteRegister, value)
    : ec->WriteByte(my.fanConfig->WriteRegister, value);
}

Code generation

The code for parsing JSON and validating the configuration values is generated by tools/config.py.

src/generated/model_config.generated.c
src/generated/model_config.generated.h