# Types, constants, and status codes

This page summarizes the public definitions in `include/mscb.h`. The checked-out
header remains authoritative for compilation.

## `MSCB_INFO`

General node metadata returned by `mscb_info()`:

```c
typedef struct {
    unsigned char  protocol_version;
    unsigned char  n_variables;
    unsigned short node_address;
    unsigned short group_address;
    unsigned short revision;
    char            node_name[16];
    unsigned char   rtc[6];
    unsigned short  buf_size;
    /* SCS3000 diagnostic extension follows */
} MSCB_INFO;
```

The structure includes SCS3000 reset
counters, boot-bank/silicon fields, system load, board temperature, supply
voltages/current, and battery voltage. Zero-initialize the structure before a
query and compile client and library against compatible headers.

## `MSCB_INFO_VAR`

```c
typedef struct {
    unsigned char width;
    unsigned char unit;
    unsigned char prefix;
    unsigned char status;
    unsigned char flags;
    char          name[16];
} MSCB_INFO_VAR;
```

Flags defined by the current header:

| Constant | Bit | Meaning |
|---|---:|---|
| `MSCBF_FLOAT` | 0 | IEEE floating-point representation |
| `MSCBF_SIGNED` | 1 | Signed integer |
| `MSCBF_DATALESS` | 2 | Control/action without stored data |
| `MSCBF_HIDDEN` | 3 | Internal configuration variable |
| `MSCBF_REMIN` | 4 | Input from a remote node on a sub-bus |
| `MSCBF_REMOUT` | 5 | Output to a remote node on a sub-bus |

## Successful/status results

| Constant | Value | Meaning |
|---|---:|---|
| `MSCB_SUCCESS` | 1 | Operation succeeded |
| `MSCB_CRC_ERROR` | 2 | Response CRC mismatch |
| `MSCB_TIMEOUT` | 3 | Host/submaster response timeout |
| `MSCB_TIMEOUT_BUS` | 4 | Remote RS-485 bus timeout |
| `MSCB_INVAL_PARAM` | 5 | Invalid parameter |
| `MSCB_MUTEX` | 6 | Connection lock failure/busy |
| `MSCB_FORMAT_ERROR` | 7 | Invalid firmware/file format |
| `MSCB_NO_MEM` | 8 | Allocation failure |
| `MSCB_SUBM_ERROR` | 9 | Submaster error |
| `MSCB_ADDR_EXISTS` | 10 | Requested node address already exists |
| `MSCB_WRONG_PASS` | 11 | Authentication rejected |
| `MSCB_SUBADDR` | 12 | Invalid subaddress/slot |
| `MSCB_NOTREADY` | 13 | Target is not ready |
| `MSCB_NO_VAR` | 14 | Variable does not exist |
| `MSCB_INVALID_INDEX` | 15 | Variable index invalid |
| `MSCB_NOT_FOUND` | 16 | Requested object not found |

## Initialization/transport errors

| Constant | Value | Meaning |
|---|---:|---|
| `EMSCB_UNDEFINED` | −1 | Unclassified error |
| `EMSCB_NO_MEM` | −2 | Allocation failure |
| `EMSCB_RPC_ERROR` | −3 | Submaster connection error (legacy constant name) |
| `EMSCB_NO_ACCESS` | −4 | Access denied |
| `EMSCB_LOCKED` | −5 | Device is locked by another process |
| `EMSCB_NO_SUBM` | −6 | No submaster available |
| `EMSCB_INVAL_PARAM` | −7 | Invalid argument |
| `EMSCB_WRONG_PASSWORD` | −8 | Wrong submaster password |
| `EMSCB_COMM_ERROR` | −9 | Transport communication failed |
| `EMSCB_NOT_FOUND` | −10 | Device not found |
| `EMSCB_NO_WRITE_ACCESS` | −11 | Device is not writable |
| `EMSCB_PROTOCOL_VERSION` | −12 | Host/submaster protocol mismatch |

## Other public constants

- `MSCB_UPLOAD_DEBUG` (`0x01`) enables upload diagnostics.
- `MSCB_UPLOAD_SUBADDR` (`0x02`) marks subaddress-aware upload behavior.
- `MSCB_BASE_RAM`, `MSCB_BASE_NVRAM`, `MSCB_BASE_FLASH`, and
  `MSCB_BASE_CODE` select memory regions.
- `BD_2400` through `BD_345600` are listed in the
  [command reference](../protocol/commands.md#baud-codes).
- Prefix and unit codes are listed with
  [variable responses](../protocol/responses.md#metric-prefixes).

`MSCB_FD` and the global `mscb_fd` table are implementation details.
Applications should treat them as private and use the descriptor
and accessor functions instead.
