# Serial Protocol

We have defined a set of serial communication protocols for robots:&#x20;

<figure><img src="/files/wmeoDPekAvhcMLdnhYfz" alt=""><figcaption></figcaption></figure>

All the tokens start with a single ASCII-encoded character to specify their parsing format. They are case-sensitive and usually in lowercase.&#x20;

{% hint style="info" %}
Some commands, like the **c** and **m** commands, can be combined.&#x20;

For example:

Successive "m8 40", "m8 -35", "m 0 50" can be written as "m8 40 8 -35 0 50".&#x20;

You can change the limit in the code, but there might be a systematic constraint for the serial buffer.
{% endhint %}

Try the following serial commands in [the serial monitor](https://docs.petoi.com/arduino-ide/serial-monitor):

* “**k**sit”
* “**m**0 30”
* “**m**0 -30”
* “**k**balance”
* “**k**wkF”
* “**k**trL”
* “**d**”

{% hint style="warning" %}
The quotation mark indicates that they are character strings. Don’t type quotation marks in the serial monitor.
{% endhint %}

You can refer to the macro definitions in OpenCat.h to utilize the most updated sets of tokens.&#x20;

{% @github-files/github-code-block url="<https://github.com/PetoiCamp/OpenCat/blob/3368dfd46d91cb453bb5fcca3ca4cf84712c922e/src/OpenCat.h#L204-L254>" %}

<figure><img src="/files/Zq1plzNCR0vyhrM5xxP3" alt=""><figcaption></figcaption></figure>

Some more available commands for skills:

<figure><img src="/files/WB4qKITGAxz6mcr6mScB" alt=""><figcaption></figcaption></figure>

The complete set of skills in effect is defined in [InstinctBittle.h](https://github.com/PetoiCamp/OpenCat/blob/main/src/InstinctBittle.h) or [InstinctNybble.h](https://github.com/PetoiCamp/OpenCat/blob/main/src/InstinctNybble.h):\
For example:

{% code overflow="wrap" %}

```cpp
const char* skillNameWithType[]={"bdFI","bkI","bkLI","crFI","crLI","hlwI","mhFI","mhLI","pcFI","phFI","phLI","trFI","trLI","vtFI","vtLI","wkFI","wkLI","balanceI","buttUpI","calibI","droppedI","liftedI","restI","sitI","strI","zeroN","bfI","ckI","climbCeilI","fdI","ffI","hiI","jyI","pdI","peeI","puI","pu1I","rcI","rlLI","rtI","stpI","tsI",};
```

{% endcode %}

All the skill names in the list can be called by adding a 'k' to the front and deleting the suffix. For example, there's "sitI" in the list. You can send "ksit" to call the sitting posture. If a skill has "F" or "L" as the second last character, it's a gait. It means walking forward or left. Walking right is a mirror of walking left. So you can send "kwkF", "kwkL", "kwkR" to make the robot walk. Similarly, there are other gaits like trot ("tr"), crawl ("cr"), and stepping ("vt").<br>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.petoi.com/apis/serial-protocol.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
