Skip to main content
Glama

set_config

Modify configuration parameters like baud rate, data bits, and flow control for an open serial port without closing and reopening the connection.

Instructions

修改已打开串口的配置(热更新,无需关闭重开)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
portYes串口路径
baudrateNo波特率,支持的值:[300, 600, 1200, 2400, 4800, 9600, 14400, 19200, 38400, 57600, 115200, 230400, 460800, 921600]
bytesizeNo数据位,支持的值:[5, 6, 7, 8]
parityNo校验位,支持的值:['N', 'E', 'O', 'M', 'S']
stopbitsNo停止位,支持的值:[1.0, 1.5, 2.0]
flow_controlNo流控制,支持的值:['none', 'hardware', 'software']
read_timeout_msNo读取超时(毫秒),范围 0-60000
write_timeout_msNo写入超时(毫秒),范围 0-60000

Implementation Reference

  • The handler function implementing the 'set_config' tool logic, which calls the serial manager to update port configuration.
    def set_config( port: str, baudrate: int | None = None, bytesize: int | None = None, parity: str | None = None, stopbits: float | None = None, flow_control: str | None = None, read_timeout_ms: int | None = None, write_timeout_ms: int | None = None, ) -> dict[str, Any]: """修改串口配置(热更新) Args: port: 串口路径 baudrate: 波特率(可选) bytesize: 数据位(可选) parity: 校验位(可选) stopbits: 停止位(可选) flow_control: 流控制(可选) read_timeout_ms: 读取超时(可选) write_timeout_ms: 写入超时(可选) Returns: 更新后的串口状态 """ manager = get_serial_manager() status = manager.set_config( port=port, baudrate=baudrate, bytesize=bytesize, parity=parity, stopbits=stopbits, flow_control=flow_control, read_timeout_ms=read_timeout_ms, write_timeout_ms=write_timeout_ms, ) return status.to_dict()
  • The schema definition for the 'set_config' tool, including inputSchema used for validation.
    SET_CONFIG_TOOL: dict[str, Any] = { "name": "set_config", "description": "修改已打开串口的配置(热更新,无需关闭重开)", "inputSchema": { "type": "object", "properties": { "port": { "type": "string", "description": "串口路径", }, "baudrate": { "type": "integer", "description": f"波特率,支持的值:{list(SUPPORTED_BAUDRATES)}", }, "bytesize": { "type": "integer", "description": f"数据位,支持的值:{list(SUPPORTED_BYTESIZES)}", }, "parity": { "type": "string", "description": f"校验位,支持的值:{[p.value for p in Parity]}", }, "stopbits": { "type": "number", "description": f"停止位,支持的值:{[s.value for s in StopBits]}", }, "flow_control": { "type": "string", "description": f"流控制,支持的值:{[f.value for f in FlowControl]}", }, "read_timeout_ms": { "type": "integer", "description": "读取超时(毫秒),范围 0-60000", }, "write_timeout_ms": { "type": "integer", "description": "写入超时(毫秒),范围 0-60000", }, }, "required": ["port"], }, }
  • Registration of the 'set_config' tool in the list_tools handler.
    types.Tool( name=SET_CONFIG_TOOL["name"], description=SET_CONFIG_TOOL["description"], inputSchema=SET_CONFIG_TOOL["inputSchema"], ),
  • Dispatch to the 'set_config' handler in the call_tool implementation.
    elif name == "set_config": result = set_config(**arguments)
  • Import of the set_config handler and SET_CONFIG_TOOL schema for use in server.py.
    from .tools.port_ops import ( CLOSE_PORT_TOOL, GET_STATUS_TOOL, OPEN_PORT_TOOL, SET_CONFIG_TOOL, close_port, get_status, open_port, set_config,

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/donnel666/uart-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server