收发交互(写+读)
transactSends data over a serial port and waits for the response in a single step, matching an end marker with a timeout — ideal for AT, Modbus, or GRBL request-response interactions.
Instructions
写入数据后等待回包,在一步内完成,是 AT/Modbus/GRBL 等请求响应式交互的推荐入口。写后只关心"写之后到达"的字节(忽略此前已缓冲的噪声)。timeout_ms 限时等待;match + match_encoding 指定响应结束标志。返回 text/hex/bytes 及 matched/timed_out。交互终端推荐 newline=crlf + match=提示符,避免把字面换行当命令。
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"connection_id": "<connection_id>",
"data": "<data>"
},
"name": "transact"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| data | Yes | 字符串或 {hex}/{base64}/{text} 对象,encoding 决定解码方式 | |
| match | No | 响应结束匹配串,如 "\n"、"OK" | |
| newline | No | 发送时自动追加的换行(none 不加) | |
| encoding | No | data 的编码方式,默认 utf8 | |
| timeout_ms | No | 等待回包的最大毫秒数,默认 5000 | |
| connection_id | Yes | 连接 ID(由 open 返回) | |
| match_encoding | No | match 的编码,默认 utf8 |