• HALCON串口通讯程序


    串口通讯程序

     
    * Note: This example is meant to demonstrate the use of the serial interface
    * of HALCON.  On Unix machines, the output and input is from /dev/tty, i.e., the
    * window from which you have started HDevelop.  On Windows NT machines,
    * this program will only run if you have a device attached to COM1.
    * Open the serial interface (for reading and writing).
    OpSystem := environment('OS')
    if (OpSystem == 'Windows_NT')
        open_serial ('COM1', SerialHandle)
    else
    *     open_serial ('/dev/tty', SerialHandle)
    endif
    * Set the parameters of the serial interface (e.g., a character-based terminal).
    set_serial_param (SerialHandle, 9600, 8, 'none', 'none', 1, 1000, 'unchanged')
    * Display a nice message on the terminal.
    write_serial (SerialHandle, ords('11,12,1'))
    * Now read 10 characters from the terminal...
    while(1)
    read_serial (SerialHandle, 2, Data)
    * ...and if the user typed some characters within the one second...
    if (|Data| > 0)
        * ...convert the read data to a string.
        Read := chrt(Data)
        if(Read='A0')
            break
        endif
    endif
    wait_seconds (0.1)
    endwhile
    stop ()
    * Finally, close the serial interface so other programs can use it.
    close_serial (SerialHandle)
     
  • 相关阅读:
    [总结]链表与栈
    统计学基础知识
    图卷积神经网络(GCN)入门
    [总结]字符串
    [总结]数组
    [总结]排序算法分析与实现
    [Leetcode]307. Range Sum Query
    深度解析Droupout与Batch Normalization
    深度解析Graph Embedding
    Console命令,让js调试更简单
  • 原文地址:https://www.cnblogs.com/wenluderen/p/4957964.html
Copyright © 2020-2023  润新知