====== PIDflight Lap Protocol ======
The PIDflight Lap protocol uses a slightly modified version of the [[http://www.multiwii.com/wiki/index.php?title=Multiwii_Serial_Protocol|Multiwii Serial Protocol]].
===== Notes =====
* By default all lap timers are activated on power up. (i.e. do not require **MSP_ACTIVATE** to be sent)
===== Getting started =====
* Open serial connection to lap timing device(s).
* **Baud rate**: 115200
* Application issues **MSP_SET_DEVICE_ID** to __all__ devices.
// Initialise all connected devices identifiers starting with 1
MSP.sendMessage(MSP.WILDCARD_DEVICE_ID, MSP.MSP_SET_DEVICE_ID, 1);
* Each device found and initialised will return a response to **MSP_SET_DEVICE_ID** with the **ID** it has been initialised with.
* Poll **MSP_CURRENT_LAP** to detect when a new lap has been recorded on the lap timer.
* Poll **MSP_STATUS** to retrieve current status of the lap timer.
===== MSP message format =====
{{:pidflightlap:msp_message_format.png?nolink&800|}}
===== MSP codes =====
^Name^Code^Description^
|MSP_API_VERSION|1|Firmware API version|
|MSP_STATUS|4|Device and lap timing status|
|MSP_RESET|5|Resets device and lap timing state|
|MSP_RSSI_CALIBRATE|6|Triggers RSSI calibration routine|
|MSP_START|7|Starts lap timing|
|MSP_ACTIVATE|8|Activates a lap timer device|
|MSP_DEACTIVATE|9|Deactivates a lap timer device|
|MSP_DEVICE_ID|10|Not used|
|MSP_SET_DEVICE_ID|11|Triggers lap timing devices to assign an ID|
|MSP_CHANNEL|20|Gets the channel frequency set on the lap timing device|
|MSP_SET_CHANNEL|21|Sets the channel frequency on the lap timing device|
|MSP_CURRENT_LAP|30| |
|MSP_LAP_MIN_TIME|34| |
|MSP_SET_LAP_MIN_TIME|35| |
|MSP_LAP_MAX|37| |
|MSP_SET_LAP_MAX|38| |
|MSP_RSSI|40| |
|MSP_RSSI_THRESHOLD|42| |
|MSP_SET_RSSI_THRESHOLD|43| |
|MSP_RSSI_FILTER|44|TBD|
|MSP_SET_RSSI_FILTER|45|TBD|
|MSP_EEPROM_WRITE|250|Persists settings to EEPROM for settings to survive a power cycle (if desired)|
==== MSP_API_VERSION ====
^Part^Type^Description^
|1|UINT 8|Major version|
|2|UINT 8|Minor version|
Version is constructed as [PART 1][DECIMAL][PART2][DECIMAL][ZERO] (e.g. 2.6.0)
==== MSP_STATUS ====
^Part^Type^Description^
|1|UINT 8|Device state|
|2|UINT 8|Timer state|
=== Device states ===
^Value^State^
|0|Idle|
|1|Timing|
|2|Calibrating|
|3|Inactive|
=== Timer states ===
^Value^State^
|0|Waiting|
|1|Start|
|2|Stop|