发送串口数据
writeSends data to a serial port without reading a response, supporting UTF-8, hex, and Base64 encodings plus optional newline control for command lines.
Instructions
向串口发送数据(只发不收)。data 为字符串,encoding 决定解码方式:utf8(默认,直接按文本)、hex(如 "AF 01")、base64。成功后返回写入字节数。如需"发完等回包"请用 transact。newline 未写时用 open 时的默认。发一行命令建议 newline=crlf,避免把字面换行当命令。
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": "write"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| data | Yes | 字符串或 {hex}/{base64}/{text} 对象,encoding 决定解码方式 | |
| newline | No | 发送时自动追加的换行(none 不加) | |
| encoding | No | data 的编码方式,默认 utf8 | |
| connection_id | Yes | 连接 ID(由 open 返回) |