/*********************************************************************************
* 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: , done.
remote: Total (delta ), reused (delta ), pack-reused
Receiving objects: % (/), 6.23 MiB | bytes/s, done.
Resolving deltas: % (/), 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.
-- The CXX compiler identification is GNU 5.4.
-- 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
[ %] Building C object CMakeFiles/mbpoll.dir/src/mbpoll.c.o
[ %] Building C object CMakeFiles/mbpoll.dir/3rdparty/modbus/modbus.c.o
[ %] Building C object CMakeFiles/mbpoll.dir/3rdparty/modbus/modbus-data.c.o
[ %] Building C object CMakeFiles/mbpoll.dir/3rdparty/modbus/modbus-tcp.c.o
[ %] Building C object CMakeFiles/mbpoll.dir/3rdparty/modbus/modbus-rtu.c.o
[ %] Building C object CMakeFiles/mbpoll.dir/3rdparty/sysio/delay.c.o
[ %] Building C object CMakeFiles/mbpoll.dir/3rdparty/sysio/serial.c.o
[%] Linking C executable mbpoll
[%] Built target mbpoll
root@localhost:/home/zengjf/freemodbus/mbpoll/build# make install
[%] 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 -- - -
General options :
-m # mode (rtu or tcp, TCP is default)
-a # Slave address (- for rtu, - for tcp, is default)
for reading, it is possible to give an address list
separated by commas or colons, for example :
-a ,,,: read [,,,,,,,]
-r # Start reference ( is default)
-c # Number of values to read (-, is default)
-u Read the description of the type, the current status, and other
information specific to a remote device (RTU only)
-t Discrete output (coil) data type (binary or )
-t Discrete input data type (binary or )
-t -bit input register data type
-t :hex -bit input register data type with hex display
-t :int -bit integer data type in input register table
-t :float -bit float data type in input register table
-t -bit output (holding) register data type (default)
-t :hex -bit output (holding) register data type with hex display
-t :int -bit integer data type in output (holding) register table
-t :float -bit float data type in output (holding) register table
- First reference is (PDU addressing) instead
-B Big endian word order for -bit integer and float
- Poll only once only, otherwise every poll rate interval
-l # Poll rate in ms, ( > , is default)
-o # Time-out in seconds (0.01 - 10.00, 1.00 s is default)
Options for ModBus / TCP :
-p # TCP port number ( is default)
Options for ModBus RTU :
-b # Baudrate (-, is default)
-d # Databits ( or , for RTU)
-s # Stopbits ( or , is default)
-P # Parity (none, even, odd, even is default)
- RS- mode (/RTS on after sending)
- RS- 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 -r -c localhost
mbpoll 0.1- - FieldTalk(tm) Modbus(R) Master Simulator
Copyright (c) epsilonRT, All rights reserved.
This software is governed by the CeCILL license <http://www.cecill.info> Protocol configuration: Modbus TCP
Slave configuration...: address = []
start reference = , count =
Communication.........: localhost, port , t/o 1.00 s, poll rate ms
Data type.............: -bit register, input register table -- Polling slave ... Ctrl-C to stop)
[]:
-- Polling slave ... Ctrl-C to stop)
[]:
-- Polling slave ... Ctrl-C to stop)
[]:
-- Polling slave ... Ctrl-C to stop)
[]:
-- Polling slave ... Ctrl-C to stop)
[]:
-- Polling slave ... Ctrl-C to stop)
[]:
-- Polling slave ... Ctrl-C to stop)
[]:
-- Polling slave ... Ctrl-C to stop)
[]:
-- Polling slave ... Ctrl-C to stop)
[]:
-- Polling slave ... Ctrl-C to stop)
[]:
-- Polling slave ... Ctrl-C to stop)
[]:
-- Polling slave ... Ctrl-C to stop)
[]:
^C--- localhost poll statistics ---
frames transmitted, received, errors, 0.0% frame loss everything was closed.
Have a nice day !
root@localhost:/home/zengjf/freemodbus/mbpoll/build#

mbpoll Test FreeModbus TCP Demo的更多相关文章

  1. FreeModbus TCP

    一.Modbus TCP协议格式 Modbus TCP协议数据格式如下图所示: MBAP报文头: Modbus TCP与Modbus RTU相比,没有检验码,也没有所谓的地址码,并且在RTU协议的基础 ...

  2. python tcp .demo

    client: # -*- coding: utf- -*- import socket s=socket.socket(socket.AF_INET,socket.SOCK_STREAM) s.co ...

  3. FreeModbus LINUXTCP Compile ERROR

    /********************************************************************************* * FreeModbus LINU ...

  4. 重新想象 Windows 8 Store Apps (62) - 通信: Socket TCP, Socket UDP

    [源码下载] 重新想象 Windows 8 Store Apps (62) - 通信: Socket TCP, Socket UDP 作者:webabcd 介绍重新想象 Windows 8 Store ...

  5. Android开发:如何实现TCP和UDP传输

    TCP和UDP在网络传输中非常重要,在Android开发中同样重要. 首先来看一下什么是TCP和UDP. 什么是TCP? TCP:Transmission Control Protocol 传输控制协 ...

  6. Android如何实现TCP和UDP传输

    TCP和UDP在网络传输中非常重要,在Android开发中同样重要. 首先我们来看一下什么是TCP和UDP. 什么是TCP? TCP:Transmission Control Protocol 传输控 ...

  7. FreeModbus undefined reference to `pthread_create'

    /********************************************************************************* * FreeModbus unde ...

  8. 重新想象 Windows 8 Store Apps 系列文章索引

    [源码下载][重新想象 Windows 8.1 Store Apps 系列文章] 重新想象 Windows 8 Store Apps 系列文章索引 作者:webabcd 1.重新想象 Windows ...

  9. Windows 8 Store Apps

    重新想象 Windows 8 Store Apps 系列文章索引 Posted on 2013-11-18 08:33 webabcd 阅读(672) 评论(3) 编辑 收藏 [源码下载] 重新想象 ...

随机推荐

  1. spring xml的配置

                    Spring xml文档头得配置 spring文档头一般是可以复制过来得,刚学习得时候一直看网上有没有配置,然后也没有找到,希望以下过程得学习可以给大家带来帮助!! 1 ...

  2. openstack安装指南和在centos7上的安装指南

    openstack安装指南官网:http://docs.openstack.org/project-install-guide/newton/ openstack在centos7上的安装指南官网:ht ...

  3. excel 单元格0 不显示的最佳方法

    excel单元格设自定义格式, 条件:可以单元格内容判断后再设置格式.条件格式化只限于使用三个条件,其中两个条件是明确的,另个是“所有的其他”.条件要放到方括号中.必须进行简单的比较.例如这个条件:单 ...

  4. WinForm之窗体应用程序

    WinForm之窗体应用程序 基本简单数据库操作(增删改查) using System; using System.Collections.Generic; using System.Windows. ...

  5. MINIUI应用

    MINIUI是一款优秀的JS前端web框架,提供丰富.强大控件库,能快速开发企业级Web应用软件. 属于付费插件. 如果有兴趣推荐去这个网址看看.MiniUI 在线示例  http://www.min ...

  6. oracle的case when的用法和decode函数的用法

    oracle中,我们要使用case when时,要怎样使用 如下测试数据,我要把ClassId 的1变成一班,2变成二班,3变成三班,那sql要怎样写呢? 1.case when的用法 -- orac ...

  7. I/O复用(select)——回声服务器端/客户端

    一.select 使用select函数可以将多个文件描述符集中到一起统一监视,监视事件如下: 是否存在待读取数据. 是否可传输无阻塞传输数据. 是否发生异常. 将关心上述3种事件的文件描述发分别注册到 ...

  8. Notes on Large-scale Video Classification with Convolutional Neural Networks

    Use bigger datasets for CNN in hope of better performance. A new data set for sports video classific ...

  9. mac 安装Seaslog扩展及SeasLogger应用

    首先下载 http://pecl.php.net/package/SeasLog 下载最新解压 cd /SeasLog-2.0.2/SeasLog-2.0.2/ phpize ./configure ...

  10. 【SQL】group by 及 having

    Group By 分组汇总 HAVING:给分组设置条件 1.概述 “Group By”从字面意义上理解就是根据“By”指定的规则对数据进行分组,所谓的分组就是将一个“数据集”划分成若干个“小区域”, ...