# Fieldbus Access runtime

## Service management

Fieldbus Access runs as a service and the management is different depending on
the system it runs on.

### CC Linux 2.0/3.0

The runtime starts as a service and can be controlled by `systemctl`. Use either
`enable` or `disable` to control if Fieldbus Access should autostart or not:

``` console
sudo systemctl enable fieldbusaccess
sudo systemctl disable fieldbusaccess
```

The service may also be started or stopped while the system is running:

``` console
sudo systemctl start fieldbusaccess
sudo systemctl stop fieldbusaccess
```

Output from the service can be checked with `journalctl`:

``` console
sudo journalctl -fu fieldbusaccess
```

### i.MX 5 and i.MX 6

Another type of service management is used on systems which are not running CC
Linux 2.0. The startup script is located under `/opt/etc/init.d`. Set the
execute permission to control if the service should autostart or not:

``` console
sudo chmod +x /opt/etc/init.d/StartupFieldbusAccess
sudo chmod -x /opt/etc/init.d/StartupFieldbusAccess
```

They service may also be started or stopped while the system is running:

``` console
sudo /opt/etc/init.d/StartupFieldbusAccess start
sudo /opt/etc/init.d/StartupFieldbusAccess stop
```

Symbolic links are created from `/opt/etc/init.d/rc3.d` and
`/opt/etc/init.d/rc6.d` and decides the startup and shutdown order of various
services (including Fieldbus Access).

## Startup arguments

```console
$/opt/bin/fieldbusaccess --help
Usage: ./fieldbusaccess [options] config
Transfer configured signals between CAN-bus and Application through Data Engine

Options:
  -h, --help          Displays help on commandline options.
  -v, --version       Displays version information.
  --name <Name>       Instance name of FA to use [Default: FieldbusAccess]
  -d, --debug <level> Additional debug output. Select level: 1=Debug,
                      2=Warning, 3=Critical, 4=Fatal.
  -ip <ip-address>    IP Address to DE [Default: 127.0.0.1]

Arguments:
  config              Path and name of configuration file to use.
```

### -h, --help

Display the help information.

### -v, --version

Display version information about Fieldbus Access.

### --name \<Name>

Instance name of Fieldbus Access. Default if none is selected, 'fieldbusAccess'

### -d, --debug \<level>

Activate additional printouts during execution. Number selects level to print to
file. Logfiles are found on the device at
`/opt/FieldbusAccess/logs/debug_log.txt`. Argument level and higher will be
added to the log. If you add `-d 2 (Warning)` as argument, Warnings, Critical
and Fatal errors will be added to the logfile.

Level | Error    | Description
------|----------|-------------------------------------------------------------------------------------------------
1     | Debug    | Information that is diagnostically helpful
2     | Warning  | Anything that can potentially cause runtime oddities but are automatically recovering
3     | Critical | Any error which is critical to the operation. These errors will usually force user  intervention
4     | Fatal    | Any error that is forcing a shutdown of the runtime

### -ip \<ip-address>

IP Address to connect to Data Engine. Default is 'localhost' 127.0.0.1.

### config

Nonoptional argument. Configuration file (.json) created by LinX Manager
Fieldbus Access

## Example

```console
fieldbusaccess [options] configuration
$/opt/bin/fieldbusaccess --debug 2 FieldbusAccess_ConfigFile.json
Will add `Warning, Critical and Fatal` messages in /opt/FieldbusAccess/logs/debug_log.txt
