mbpoll Test FreeModbus TCP Demo

/*********************************************************************************
 *                   mbpoll Test FreeModbus TCP Demo
 * 说明:
 *     使用mbpoll工具对FreeModbus进行测试,本文仅仅涉及编译以及简单测试。FreeModbus
 * 默认没有打开网络传输功能,需要手动打开。
 *
 *                                              2018-1-2 深圳 南山平山村 曾剑锋
 ********************************************************************************/

一、参考文档:
    epsilonrt/mbpoll
        https://github.com/epsilonrt/mbpoll

二、Compile/Install:
    root@localhost:/home/zengjf/freemodbus# git clone https://github.com/epsilonrt/mbpoll.git
    Cloning into 'mbpoll'...
    remote: Counting objects: 263, done.
    remote: Total 263 (delta 0), reused 0 (delta 0), pack-reused 263
    Receiving objects: 100% (263/263), 6.23 MiB | 0 bytes/s, done.
    Resolving deltas: 100% (135/135), done.
    Checking connectivity... done.
    root@localhost:/home/zengjf/freemodbus# cd mbpoll
    root@localhost:/home/zengjf/freemodbus/mbpoll# ls
    3rdparty  CMakeLists.txt  LICENCE  NEWS       README_FR.md  mbpoll.pro      mbpo
    AUTHORS   INSTALL         LICENSE  README.md  TODO          mbpoll.project  pack
    root@localhost:/home/zengjf/freemodbus/mbpoll# mkdir build
    root@localhost:/home/zengjf/freemodbus/mbpoll# cd build/
    root@localhost:/home/zengjf/freemodbus/mbpoll/build# cmake ..
    -- The C compiler identification is GNU 4.9.3
    -- The CXX compiler identification is GNU 5.4.0
    -- Check for working C compiler: /usr/bin/cc
    -- Check for working C compiler: /usr/bin/cc -- works
    -- Detecting C compiler ABI info
    -- Detecting C compiler ABI info - done
    -- Detecting C compile features
    -- Detecting C compile features - done
    -- Check for working CXX compiler: /usr/bin/c++
    -- Check for working CXX compiler: /usr/bin/c++ -- works
    -- Detecting CXX compiler ABI info
    -- Detecting CXX compiler ABI info - done
    -- Detecting CXX compile features
    -- Detecting CXX compile features - done
    -- Configuring done
    -- Generating done
    -- Build files have been written to: /home/zengjf/freemodbus/mbpoll/build
    root@localhost:/home/zengjf/freemodbus/mbpoll/build# ls
    CMakeCache.txt  CPackConfig.cmake        Makefile
    CMakeFiles      CPackSourceConfig.cmake  cmake_install.cmake
    root@localhost:/home/zengjf/freemodbus/mbpoll/build# make
    Scanning dependencies of target mbpoll
    [ 12%] Building C object CMakeFiles/mbpoll.dir/src/mbpoll.c.o
    [ 25%] Building C object CMakeFiles/mbpoll.dir/3rdparty/modbus/modbus.c.o
    [ 37%] Building C object CMakeFiles/mbpoll.dir/3rdparty/modbus/modbus-data.c.o
    [ 50%] Building C object CMakeFiles/mbpoll.dir/3rdparty/modbus/modbus-tcp.c.o
    [ 62%] Building C object CMakeFiles/mbpoll.dir/3rdparty/modbus/modbus-rtu.c.o
    [ 75%] Building C object CMakeFiles/mbpoll.dir/3rdparty/sysio/delay.c.o
    [ 87%] Building C object CMakeFiles/mbpoll.dir/3rdparty/sysio/serial.c.o
    [100%] Linking C executable mbpoll
    [100%] Built target mbpoll
    root@localhost:/home/zengjf/freemodbus/mbpoll/build# make install
    [100%] Built target mbpoll
    Install the project...
    -- Install configuration: ""
    -- Installing: /usr/local/bin/mbpoll
    root@localhost:/home/zengjf/freemodbus/mbpoll/build# mbpoll -h
    usage : mbpoll [ options ] device|host [ writevalues... ] [ options ]
    
    ModBus Master Simulator. It allows to read and write in ModBus slave registers
                             connected by serial (RTU only) or TCP.
    
    Arguments :
      device        Serial port when using ModBus RTU protocol
                      COM1, COM2 ...              on Windows
                      /dev/ttyS0, /dev/ttyS1 ...  on Linux
                      /dev/ser1, /dev/ser2 ...    on QNX
      host          Host name or dotted IP address when using ModBus/TCP protocol
      writevalues   List of values to be written.
                    If none specified (default) mbpoll reads data.
                    If negative numbers are provided, it will precede the list of
                    data to be written by two dashes ('--'). for example :
                    mbpoll -t4:int /dev/ttyUSB0 -- 123 -1568 8974 -12
    General options :
      -m #          mode (rtu or tcp, TCP is default)
      -a #          Slave address (1-255 for rtu, 0-255 for tcp, 1 is default)
                    for reading, it is possible to give an address list
                    separated by commas or colons, for example :
                    -a 32,33,34,36:40 read [32,33,34,36,37,38,39,40]
      -r #          Start reference (1 is default)
      -c #          Number of values to read (1-125, 1 is default)
      -u            Read the description of the type, the current status, and other
                    information specific to a remote device (RTU only)
      -t 0          Discrete output (coil) data type (binary 0 or 1)
      -t 1          Discrete input data type (binary 0 or 1)
      -t 3          16-bit input register data type
      -t 3:hex      16-bit input register data type with hex display
      -t 3:int      32-bit integer data type in input register table
      -t 3:float    32-bit float data type in input register table
      -t 4          16-bit output (holding) register data type (default)
      -t 4:hex      16-bit output (holding) register data type with hex display
      -t 4:int      32-bit integer data type in output (holding) register table
      -t 4:float    32-bit float data type in output (holding) register table
      -0            First reference is 0 (PDU addressing) instead 1
      -B            Big endian word order for 32-bit integer and float
      -1            Poll only once only, otherwise every poll rate interval
      -l #          Poll rate in ms, ( > 100, 1000 is default)
      -o #          Time-out in seconds (0.01 - 10.00, 1.00 s is default)
    Options for ModBus / TCP :
      -p #          TCP port number (502 is default)
    Options for ModBus RTU :
      -b #          Baudrate (1200-921600, 19200 is default)
      -d #          Databits (7 or 8, 8 for RTU)
      -s #          Stopbits (1 or 2, 1 is default)
      -P #          Parity (none, even, odd, even is default)
      -4            RS-485 mode (/RTS on after sending)
      -5            RS-485 mode (/RTS on when sending)
    
      -h            Print this help summary page
      -V            Print version and exit
      -v            Verbose mode.  Causes mbpoll to print debugging messages about
                    its progress.  This is helpful in debugging connection...
    root@localhost:/home/zengjf/freemodbus/mbpoll/build#

三、Test Example:
    root@localhost:/home/zengjf/freemodbus/mbpoll/build# ./mbpoll -m TCP -t 3 -r 1000 -c 1 localhost
    mbpoll 0.1-23 - FieldTalk(tm) Modbus(R) Master Simulator
    Copyright (c) 2015 epsilonRT, All rights reserved.
    This software is governed by the CeCILL license <http://www.cecill.info>
    
    Protocol configuration: Modbus TCP
    Slave configuration...: address = [1]
                            start reference = 1000, count = 1
    Communication.........: localhost, port 502, t/o 1.00 s, poll rate 1000 ms
    Data type.............: 16-bit register, input register table
    
    -- Polling slave 1... Ctrl-C to stop)
    [1000]:         0
    -- Polling slave 1... Ctrl-C to stop)
    [1000]:         0
    -- Polling slave 1... Ctrl-C to stop)
    [1000]:         0
    -- Polling slave 1... Ctrl-C to stop)
    [1000]:         0
    -- Polling slave 1... Ctrl-C to stop)
    [1000]:         0
    -- Polling slave 1... Ctrl-C to stop)
    [1000]:         0
    -- Polling slave 1... Ctrl-C to stop)
    [1000]:         0
    -- Polling slave 1... Ctrl-C to stop)
    [1000]:         0
    -- Polling slave 1... Ctrl-C to stop)
    [1000]:         0
    -- Polling slave 1... Ctrl-C to stop)
    [1000]:         0
    -- Polling slave 1... Ctrl-C to stop)
    [1000]:         0
    -- Polling slave 1... Ctrl-C to stop)
    [1000]:         0
    ^C--- localhost poll statistics ---
    12 frames transmitted, 12 received, 0 errors, 0.0% frame loss
    
    everything was closed.
    Have a nice day !
    root@localhost:/home/zengjf/freemodbus/mbpoll/build#             

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Modbus Poll pro 3.6版本汉化,单文件免注册 Modbus Poll是非常流行的Modbus主站模拟器为你的奴隶设备的测试和调试。支持Modbus RTU / ASCII和Modbus TCP / IP协议。 Modbus从站是模拟多达32个从站设备在32位windows!加快你的PLC编程与此模拟工具。开始编程和测试您从供应商收到从设备前。载有任何打开的文档数据是可访问到主应用程序。相同的用户界面的Modbus投票。支持功能01,02,03,04,05,06,15,16,22和23。 监测串行通信。OLE自动化为使用Visual Basic,Excel会等接口要根据您的具体要求解释和显示的Modbus数据。例如编辑编辑在Excel中你的奴隶的数据。尝试包含的程序Excel的example.xls。 Modbus从站内开每个窗口可以被配置为从相同或不同的从节点表示数据。 Modbus Poll 4.3.4 破解版 Modbus Poll功能 01:读线圈状态 02:读取输入状态 03:读保持寄存器 04:读输入寄存器 05:强制单个线圈 06:预置单个寄存器 15:强制多个线圈 16:预设多个寄存器 22:屏蔽寄存器写 23:读/写寄存器 Modbus Poll特点 Modbus具有以下几个特点: (1)标准、开放,用户可以免费、放心地使用Modbus协议,不需要交纳许可证费,也不会侵犯知识产权。目前,支持Modbus的厂家超过400家,支持Modbus的产品超过600种。 (2)Modbus可以支持多种电气接口,如RS-232、RS-485等,还可以在各种介质上传送,如双绞线、光纤、无线等。 (3)Modbus的帧格式简单、紧凑,通俗易懂。用户使用容易,厂商开发简单。 主要特点: OLE自动化是指简单的接口到Excel RTU模式 ASCII模式 MODBUS TCP / IP 的Modbus UDP / IP协议 打印和打印预览 串行数据流的监控 上下文敏感的帮助 10显示格式,如浮点,双精度等。 可调整的基地址(0或1)。 字体和颜色选择。 广播(从ID为0)。 易于控制的RS-485转换器与RTS切换。 在Modbus网络上传输 标准的Modbus口是使用一RS-232C兼容串行接口,它定义了连接口的针脚、电缆、信号位、传输波特率、奇偶校验。控制器能直接或经由Modem组网。 控制器通信使用主—从技术,即仅一设备(主设备)能初始化传输(查询)。其它设备(从设备)根据主设备查询提供的数据作出相应反应。典型的主设备:主机和可编程仪表。典型的从设备:可编程控制器。 主设备可单独和从设备通信,也能以广播方式和所有从设备通信。如果单独通信,从设备返回一消息作为回应,如果是以广播方式查询的,则不作任何回应。Modbus协议建立了主设备查询的格式:设备(或广播)地址、功能代码、所有要发送的数据、一错误检测域。 从设备回应消息也由Modbus协议构成,包括确认要行动的域、任何要返回的数据、和一错误检测域。如果在消息接收过程中发生一错误,或从设备不能执行其命令,从设备将建立一错误消息并把它作为回应发送出去。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值