Module link_serial
串口类相关
Functions
Serial:new (obj) | 创建串口实例 |
Serial:open () | 打开 |
Serial:write (data) | 写数据 |
Serial:wait (timeout) | 等待数据 |
Serial:read (len) | 读数据 |
Serial:close () | 关闭串口 |
Functions
- Serial:new (obj)
-
创建串口实例
Parameters:
- obj table
Returns:
-
table
- Serial:open ()
-
打开
Returns:
-
boolean 成功与否
- Serial:write (data)
-
写数据
Parameters:
- data string 数据
Returns:
-
boolean 成功与否
- Serial:wait (timeout)
-
等待数据
Parameters:
- timeout integer 超时 ms
Returns:
-
boolean 成功与否
- Serial:read (len)
-
读数据
Parameters:
- len integer 期待长度
Returns:
- boolean 成功与否
- string|nil 数据
- Serial:close ()
- 关闭串口