# Features

Here are a few of the key features of Fieldbus Access.

## Fieldbus Access runtime

The Fieldbus Access binary with its integrated J1939 and CANopen stack handles signal communication between Data Engine and the CAN bus protocol. Signals, PGN's and/or PDO's are configured via LinX Manager Fieldbus Access and an automatic integration to your GUI application is created for easy access of signal values and statuses.


## Configuration file

Fieldbus Access runtime takes a configuration file as one of it's arguments. The
file is of type json and is generated by the LinX Manager configuration tool in
UX designer. A closer look of the various possible settings is found in the
LinX-Manager Fieldbus Access documentations. Most settings described below is added to the
configuration file.

A default configuration file `FieldbusAccess_ConfigFile.json` is added during
installation in your devices /appfs/bin folder. A configuration file is taken by 
the RT as an argument during startup and is mandatory. More info in the 
[Runtime](runtime.md) section under "Startup arguments"

## Environment variables

`FIELDBUSACCESS_SKIP_OS_BOOTED` is an OS environment variable that could be set
prior to start of the Fieldbus Access runtime in order to skip boot check. If
this flag is set to true =1 the runtime will skip any internal checks. CCAux API
used for validation of completed system boot. If you don't have any issues with
automatic boot of the Fieldbus Access runtime there is no need for this variable
to be set.

## J1939

### CAN driver

It's possible to connect up to four (4) CAN interfaces simultaneously. The
integrated J1939 stack communicates via socketcan driver and TCP protocol.

### Name claiming

A name claiming procedure is done during initialization of the Fieldbus Access
runtime. From the LinX Manager plugin preferred arbitrary addresses list is set
following J1939 SAE standard.

### Receive filter

Receive filters configured from the LinX Manager configuration tool are used to
ensure only relevant messages are received/accepted.

### Transmission mode

The Fieldbus Access runtime accepts two different transmission modes for signals
between Data Engine and CAN bus, **[On change]** and **[Cyclic]**

#### On change

A PGN configured in this mode will be transmitted each time any of the included
SPN values are updated. Reception occurs as soon as a configured PGN value is
received on the bus.

#### Cyclic

Reception of PGN configured in this mode will be checked for reception. If the
messages is not received within the configured cyclic time (cyclic interval x 3)
it will generate a warning messages and relayed via one of the error signals
available for Data Engine `fieldbusAccess_J1939Error_CAN0`. Transfer time is
configured by the configuration tool, either from standard library or by custom
assigned value. Transmission of signals in this mode simply sends the set value
every cyclic interval.

### Scaling

Fieldbus Access automatically scales received and transmitted SPNs. The raw
value is scaled using configured gain and offset for each SPN.

### Dynamic length

FA supports transmission and reception of PGNs with variable length. From 1 byte
up to a total of 1785 bytes are supported (based on the used data type). The
total length of included SPNs in a PGN determines the number of bytes that is
transmitted with each CAN frame.

Data Type                    | Bytes
-----------------------------|----------
bool                         | 1
signed char, unsigned char   | 1
signed short, unsigned short | 2
signed int, unsigned int     | 4
blob                         | 8 to 1785
string                       | 8 to 1785

### Diagnostic messages

Fieldbus Access supports DM1 and DM2 diagnostic messages. Other DMs are also
supported but require manually setup. The message size is dependent on number of
DTCs received and thus dynamic in size. Data Engine type BLOB is used to handle
these messages. The first byte received is the source address from the sending
node. Following bytes is the SAE J1939-73 diagnostic message.

```mermaid::

  flowchart LR
    A[SRC] --- B[LAMP] 
    subgraph SAE J1939-73
    B[LAMP] --- C[RES]
    C[RESERVED] --- D[DTC]
    end
```

## CANopen

Fieldbus Access performs mapping between OD index, subindex and Data Engine signals. This makes
it possible for the CANopen master to reconfigure the PDOs and the mappings will
still be valid. It also makes it possible for the CANopen master to read and
write signals with SDOs if necessary.

An ECU using Fieldbus Access in CANopen slave mode will act like a full CANopen
slave on the network. Fieldbus Access executes a CANopen slave stack to be
CANopen compliant.

### Node management

Listens to node management (NMT) messages from the master and act according to
them.

### Signal communication

Convert PDOs to Data Engine signals and vice versa.

### Scaling

Manage Scaling between PDOs and Data Engine signals.

### Heart beats

Able to generate heart-beats on request from the CANopen master.

### Transmission type

PDOs will be sent and received according to their transmission type (event,
sync, remote transmission request etc.).

### Configuration

Identify itself to the master according to data in the configuration file
(vendor name, vendor number, product name, product number, revision number).
Configuration of the node is primarily made by the master sending configuration
SDOs to the unit. It will not be possible to set up for instance PDO types or
heartbeat rate in the configuration file. It will not be possible to store a
configuration sent by SDOs to the unit on persistent memory.

### EDS file

From the UX designer tool, it will be possible to generate an EDS file for the
slave that can be imported into a CANopen master.

### Object dictionary

Object dictionary will be dynamically set up according to the configuration
file. All signal values will be available in the object dictionary so it will be
possible to alter the values with SDO writes although the recommended usage is
to use PDOs.
