+++
title = "Serial Interface"
weight = 4
categories = "Serial"
+++

# Serial Interface

All components provide minimal introspection capabilities : info, debug and custom registered methods. Each method can be called via Serial, eg : ```<<1;2;64;print:100:0>>``` to call 'print' for component `1` (main application).

**Command construction** :

Command Syntax : `` <<COMPONENT ID ; VERB ; FLAGS ; PAYLOAD>> `` whereby `PAYLOAD` consists out of `METHOD:ARG-1:ARG-2`

**ID** : Component Id

**VERB** : Command Type | Default=EC_METHOD (Class Method)

```c++
enum ECALLS
{
    // global function
    EC_COMMAND = 1,
    // addon method
    EC_METHOD = 2,
    // external function
    EC_FUNC = 3,
    // user space
    EC_USER = 10

};
```

**FLAGS** : Flags being used for the call. Default = 64
```c++
    enum MessageFlags
    {
        NEW = 1 << 1,           // set on target when inbound
        // set on target
        PROCESSING = 1 << 2,
        // set on target when inbound
        PROCESSED = 1 << 3,
        // set on host, turn on debugging through the entire processing chain
        DEBUG = 1 << 4,
        RECEIPT = 1 << 5        // set on host, this will return the new state
    };
```

**PAYLOAD**: String, this string depends on the verb, Default = Class::Method(short,short)

## Examples

List all registered component methods

```<<1;2;64;print:100:0>>``` (whereby the leading '1' designates the root component 'MixerApp')

Output

```log
V: 	Registered Method:  601::Stepper::debug
V: 	Registered Method:  601::Stepper::speed
V: 	Registered Method:  601::Stepper::dir
V: 	Registered Method:  400::POT::toggleFlag
V: 	Registered Method:  400::POT::clearFlag
V: 	Registered Method:  400::POT::info
V: 	Registered Method:  400::POT::test
V: 	Registered Method:  401::POT::toggleFlag
V: 	Registered Method:  401::POT::clearFlag
V: 	Registered Method:  401::POT::info
V: 	Registered Method:  401::POT::test
V: 	Registered Method:  402::POT::toggleFlag
V: 	Registered Method:  402::POT::clearFlag
V: 	Registered Method:  402::POT::info
V: 	Registered Method:  402::POT::test
V: 	Registered Method:  1::APP::print
V: 	Registered Method:  1::APP::list
V: 	Registered Method:  1::APP::reset
V: 	Registered Method:  1::APP::setDebugParams
```

<hr/>

List all components

```<<1;2;64;list:100:0>>```

Output

```log
V: MixerApp::list - 0 | SerialMessage | Debug=1
V: MixerApp::list - 0 | Bridge | Debug=0
V: MixerApp::list - 601 | Stepper | Debug=0
V: MixerApp::list - 400 | POT | Debug=0
V: MixerApp::list - 401 | POT | Debug=0
V: MixerApp::list - 402 | POT | Debug=0
```

<hr/>

Set debugging interval to 100ms

```<<1;2;64;setDebugParams:100:0>>```

Enable debugging for stepper control (2nd argument = 1)

```<<1;2;64;setDebugParams:100:1>>```

<hr/>

Turn on debugging for component 'POT - 0' (Component Id = 400)

```<<400;2;64;toggleFlag:1:1>>```

Output (Arduino Plotter compatible)

```log
V: Frac_400:100,Avg_400:4095,Damped_400:5733,Val_400:4095
```

'Arduino Plotter'

![](plotter.png)

Remarks : There are currently 3 POTs supported

## Modbus

-> [See more here](../modbus)
