# CPF Configuration Guide

## Getting Started

There are two options for configuring the CPF. You can change single parameters through the factory mode that you can enter when the firmware starts, or you can edit the configuration file manually while the float in is USB mass storage mode.

## Using the Factory Mode

Factory mode is entered via a bluetooth serial connection to the CPF. In order to access this interface, we will assume you have a bluetooth RS232 module hooked up to your PC. Open the serial port using baudrate 115200 kbps 8N1 with no flow control. After powering the float you should see a message:

    Press $$$<CR> to enter factory mode. You have 5 seconds...

Enter the `$$$` followed by the enter key on your keyboard. You can do this multiple times to be sure, the CPF will wait 5 seconds irregardless. Upon success, you will be welcomed with the factory mode prompt:

    CPF>

Here you can interact with the configuration using the [`config`](#the-config-command-tool) command.

More detail on other uses of [Factory Mode can be found on its detailed page](../factory_mode). 

## The Config Command Tool

If you've [entered factory mode](#using-the-factory-mode), you can issue a `config` command on the prompt to get the usage information for the commennd.

    CPF> config
    usages:
        config -a                  - Print all configuration keys & values
        config <parameter>         - Print the value of the given parameter key
        config <parameter> <value> - Set a configuration parameter
        config -s                  - Commit changes to the config.xml file on SD card.

Values you enter here will be checked against acceptable ranges, so if you enter a value that is out of range or should be an integer or decimal, an error will print out that tells you what you did wrong.

**All changes are temporary until you issue a `config -s` to commit the changes and write a new xml file. You will need to `reboot` the CPF to see if these values were saved.**

## XML Configuration Values

### `name`

- **Description:** Unique CPF Name Identifier
- **Values:** ascii string, no spaces with name of the unit, i.e. `CP001`, `CPF002`
- **Notes:** This gets used mostly in file naming and log message construction.

### `engrlogverb`

- **Description:** Engineering Log Verbosity Level
- **Values:** unsigned integer, range 0-1
- **Notes:**  This is the verbosity of engineering log messages that end up 
    - Verbosity = 0: no bluetooth output at all
    - Verbosity = 1: Basic messages are always sent, minimum verbosity
    - Verbosity = 5: Maximum verbosity

### `debuglogverb`

- **Description:** Verbosity level when printing messages to the debugger
- **Values:** integer, range 0-5 
- **Notes:** This value only has impact when a software debugger has been attached to the CPF.

### `sysdatasampperiod`

- **Description:** Period of seconds between acquisition of core health data for the vehicle.
- **Values:** integer, 1-1200 seconds
- **Notes:**

### `premissdelayperiod`

- **Description:** Period of seconds between acquisition of core health data for the vehicle.
- **Values:** integer, 0-1200 seconds
- **Notes:**

### `stringpotinverseslope`

- **Description:** Calibration inverted slope for the conversion of voltage to % full for internal bellows.
- **Values:** float, no range limit

### `stringpotint`

- **Description:** Calibration intercept for the conversion of voltage to % full.
- **Values:** float, no range liimit

### `bellowslower`

- **Description:** Lower limit of the bellows (in percent full)
- **Values:** float, 0.00-100.00 inner bellows %full

### `bellowsupper`

- **Description:** Upper limit of the bellows (in percent full)
- **Values:** float, 0.00-100.00 inner bellows %full

### `sobellowspos`

- **Description:** Bellows position in percent full to set when in surface ops mode.
- **Values:** float, 0.00-100.00 inner bellows %full

### `sobellowsjv`

- **Description:** Pump speed for adjustments to the bellows position in surface ops mode.
- **Values:** integer, -200000 to 20000 (common JV limits)

### `rmbellowspos`

- **Description:** Bellows position in percent full to set when in recovery mode.
- **Values:** Bellows position in percent full to set when in recovery mode.

### `abretfastjv`

- **Description:** Pump speed for bellows control during retract fast modes.
- **Values:** integer, -200000 to 20000 (common JV limits)

### `abretslowjv`

- **Description:** Pump speed for bellows control during retract slow modes.
- **Values:** integer, -200000 to 20000 (common JV limits)

### `abpressthres`

- **Description:** Minimum pressure in decibars to transition from ABretract Mode
            to Descend mode.
- **Values:**

### `deanchorjv`

- **Description:** Pump velocity during deanchoring.
- **Values:** integer, -200000 to 20000 (common JV limits)

### `deanchorvellim`

- **Description:** Sets the detection limit for determining when the system is deanchored.
            This is a pressure velocity (decibars/sec).
- **Values:** float, -1 to 1.0 (common velocity limits)

### `deanchorpressmin`

- **Description:** Minimum pressure in decibars away from anchored pressure to determine
            deanchoring is complete.
- **Values:** float, 0.1 to 10.0 decibar

### `deanchorcount`

- **Description:** Number of consecutive valid samples in the "deanchored" state to
            exit the deanchoring state.
- **Values:** integer, 1 to 200 counts (common count limit)

### `anchorcount`

- **Description:** Sets the number of consecutive samples of pressures below target
            to determine the system has been anchored.
- **Values:** integer, 1 to 200 counts (common count limit)

### `anchorpressmin`

- **Description:** The minimum pressure in decibars where anchoring can be tested against.
- **Values:**

### `anchorvellim`

- **Description:** Maximum vertical velocity in decibars per second when
            determining if the system has reached bottom.
- **Values:** float, -1 to 1.0 (common velocity limits)

### `exitanchorpressthres`

- **Description:** Pressure difference in decibar we are willing to accept between pressure sensor
            updates to make sure we are properly anchored.
- **Values:** float, 1 to 10.0

### `approachvel`

- **Description:** Target pressure velocity (decibars/sec) when approaching a target depth.
- **Values:** float, -1 to 1.0 (common velocity limits)

### `cppresscutoff`

- **Description:** SBE41 CP mode stops below this pressure in deciBars
- **Values:** float, 1.0 to 20.0 decibar

### `cprunpumptime`

- **Description:** run the pump for this many seconds before starting CP mode
- **Values:** integer 0 to 1200 seconds milliseconds

### `cpmode`

- **Description:** Puts SBE41 in CP mode during ascend states only.
- **Values:** integer, 0 (disables) or 1 (enables)

### `sbecomsampperiod`

- **Description:** Sample period for the SBE when in Sample mode in milliseconds.
- **Values:** integer, 2600 to 60000 milliseconds

### `sbecpsampperiod`

- **Description:** Sample Period for the SBE CTD when in CP mode in milliseconds
- **Values:** integer, 1000 to 3000

### `parkdepth`

- **Description:** Mission parking depth in decibar TODO add more detail.
- **Values:** float, 0 to 125 decibar

### `parksampmin`

- **Description:** Time between instrument sampling during park states in minutes.
- **Values:** integer, 0 to 1000 minutes (common with parktime min)

### `parktimehrs`

- **Description:** Time to spend in park states, hours component.
- **Values:** integer, 0 to 100 hours
- **Notes:** Please use in conjunction with [`parktimemin'](#parktimemin)

### `parktimemin`

- **Description:** Time to spend in park states, minutes component.
- **Values:** integer, 0 to 1000 minutes (common with parktime min)
- **Notes:** Please use in conjunction with [`parktimehrs'](#parktimehrs)
