zoukankan      html  css  js  c++  java
  • robot 的 串口操作

    1、关闭串口
        如果没有创建串口,关闭串口就会报错

    SerialLibrary.Close Port
    SerialLibrary.Delete All Ports

    Run Keyword And Ignore Error 可以用该命令来忽略错误


    2、添加串口
     
    SerialLibrary.Add Port    ${port}    baudrate=${baudrate}

    #baudrate, bytesize, parity, stopbits,timeout, xonxoff, rtscts, write_timeout, dsrdtr and  inter_byte_timeout.    write_timeout=120.1    


    3、打开串口,获取串口返回的字符编码

    SerialLibrary.Open Port    ${port}
    ${a}    SerialLibrary.Get Encoding
    log    ${a}

    4、往串口写如数据,注明输入字符的编码
    SerialLibrary.Write Data         UTF-8

    5、刷新端口

    SerialLibrary.Flush Port                    
    sleep    1                

    Flush port so that all waiting data is processed.

    刷新端口,以便处理所有等待的数据。

    6、读取串口输出数据
    SerialLibrary.Read All Data


    7、读取有效数据前,删除无效数据
    SerialLibrary.Flush Port
    SerialLibrary.Read All Data
    SerialLibrary.Reset Output Buffer


    8、退出串口
    SerialLibrary.Close Port                
    SerialLibrary.Delete All Ports    

    9、Wait Until Keyword Succeeds    5X    3  运行直到成功


               

  • 相关阅读:
    std::auto_ptr
    make_pair
    _stdcall与_cdecl(了解)
    函数名与函数指针(了解)
    空指针与野指针
    std::bind(二)
    C++ map 映照容器
    sql find duplicate
    数量
    sort sign numeric
  • 原文地址:https://www.cnblogs.com/classics/p/11378394.html
Copyright © 2011-2022 走看看