# module – modulhantering

> Laddar, laddar ur, klonar och inspekterar hårdvarumoduler och deras inställningar.

_Källa: E-Sharp (esharp.se) · Accordion Shell (CLI)_


## Description

The `module` command manages hardware modules in the Accordion system. It allows you to load, unload, configure, and inspect modules and their settings.

## Syntax

```bash
module [options]
```

## Optional Options

| Option | Short | Description |
| --- | --- | --- |
| `--module` | `-m` | The module name to activate/deactivate |
| `--file` | `-f` | Path to the file containing module definitions |
| `--rename` | `-r` | Clone and rename the module before loading |
| `--key` | `-k` | Key for initial data to change (must be paired with value) |
| `--value` | `-v` | Value for initial data to change (must be paired with key) |
| `--deactivate` | `-d` | Flag to deactivate (unload) the module |

## Examples

```bash
module
module --module "PMBus_Engine"
module --module "PMBus_Engine" --file "C:\configs\modules.xml"
module --module "I2C_Device" --rename "I2C_Device_Clone"
module --module "ADC_Module" --key "SampleRate" --value "1000"
module --module "PMBus_Engine" --deactivate
```

## Output Format

### Available Modules Section

```
Available Modules:
PMBus_Engine
    AssemblyPath         : additional/PmbusEngine/PMBusEngine.dll
    ClassName            : Pmbus
    Namespace            : PmbusEngine
    ImageName            : pmbus.png
    InitialData          :
        I2CAddress       : 0x50
        DeviceType       : LTC3880
```

### Loaded Modules & Affected Channels

```
Loaded Modules:
PMBus_Engine
GPIO_Controller

Affected channels:
PMBus_Engine.VOUT_COMMAND
PMBus_Engine.IOUT_MEASURED
```

## Loading Behavior

When loading a module: if no file specified, uses existing module definitions; if file specified, reads from file; if rename specified, creates a clone with new name; if key/value specified, overrides InitialData; enables the module, loads it into the hardware manager, refreshes the channel list, and displays affected channels.

## Cloning Modules

Cloning allows multiple instances of the same module:

```bash
module -m "I2C_Device" -r "I2C_Dev_0x50" -k "Address" -v "0x50"
module -m "I2C_Device" -r "I2C_Dev_0x51" -k "Address" -v "0x51"
```

## Notes

- Requires an active connection (use `init` first)
- Key and value must be provided together
- Loading modules refreshes the channel list
- Changes persist until reset or manual unload

## Error Handling

- **Module not found**: Module doesn't exist in available modules list
- **Key without value**: Key and value must be provided together
- **Module already loaded**: Cannot load duplicate module (use rename)
- **Unload failed**: Module may be in use or dependencies exist
