Timeout Codec
Collects incoming bytes and emits them as one message once the line has been quiet for the Timeout, or once the timeout has passed since the first byte while data keeps coming. Outgoing payloads are sent as they are.
It needs no knowledge of the protocol, which makes it the codec to start with on an unknown device. Pick a timeout longer than the gaps inside a frame and shorter than the gap between frames: at 9600 baud one byte takes about 1 ms, so the default 50 ms suits most request/response devices. If frames arrive merged, lower it; if they arrive split, raise it. When the frame format is known, Frame or Structured Frame decode it exactly.
Configuration reference
| Config ID | timeout_codec |
| Selected by | app_codec = "timeout_codec" |
| Platforms | Linux, Windows, Android |
| License | Free |
Decode based on timeout (treat buffered data as a frame after timeout)
If there is no new data after this time, the buffered data will be treated as a complete frame
| Setting | Key | Type | Default | Notes |
|---|---|---|---|---|
| Timeout (ms) | with_receive_timeout | Integer | 50 | Required |
Example config
Default values as they appear in a saved configuration (for example the JSON block at the end of a cycbox/examples/*.lua file). Settings detected at runtime are omitted.
{
"app": {
"app_codec": "timeout_codec"
},
"timeout_codec": {
"with_receive_timeout": 50
}
}