turtlebot3-burger_150.png
turtlebot3-waffle-pi_150.png
turtlebot3-arm_150.png
walking-y2_150.png
turbot3-multi_150.png
turbot3-dl-ros1_150.png
turbot3-ai.png
turbot3-dl-ros2_150.png
turbot3-slam_150.png
turbot3-arm_150.png
turtlebot4-lite_150.png
turtlebot4-pro_150.png
turbot4-dl_150.png
turbot4-ai_150.png
aidriving-racebot_150.png
aidriving-autodrive_150.png
turtlebot-arm_150.png
openmanipulator-x_150.png
Home » Farmbot开发入门教程 » farmbot开发入门教程-lua uart

farmbot开发入门教程-lua uart

纠错,疑问,交流: 请进入讨论区请点击进入页面,扫码加入微信群或Q群进行交流

获取最新文章: 扫一扫加入“创客智造”公众号

说明:

  • FarmBot OS 中的 UART Lua 函数列表

介绍:

uart.列表()

  • 返回 UART 设备列表。
uart_list = uart.list()

for _number, device_path in ipairs(uart_list) do
  toast(inspect(device_path), "debug")
end

uart.open(路径,波特率)

  • 打开 UART 设备(通常通过 USB)进行读写。

  • UART 设备必须连接到 Raspberry Pi,而不是 Arduino。

-- device name, baud rate:
my_uart, error = uart.open("ttyAMA0", 115200)

if error then
    toast(inspect(error), "error")
    return
end

if my_uart then
    -- Wait 60s for data...
    string, error2 = my_uart.read(15000)
    if error2 then
        toast(inspect(error2), "error")
    else
        toast(inspect(string))
    end

    error3 = my_uart.write("Hello, world!")

    if error3 then
        -- Handle errors etc..
    end

    my_uart.close()
end

uart.读取()

  • 查看uart.open()的文档。

uart.写入()

  • 查看uart.open()的文档。

uart.关闭()

  • 查看uart.open()的文档。

纠错,疑问,交流: 请进入讨论区请点击进入页面,扫码加入微信群或Q群进行交流

获取最新文章: 扫一扫加入“创客智造”公众号


标签: none