Tags: a term images alt Click blog reliable text colorParticipated in a SCTF competition, also wrote a WP, right is one. Because only one question was made .... , but also the simplest of the Modbus protocol topics. As a newly born CTF child, it is also very gratifying ... No matter how much you make, the summary is necessary, and you need to know it thoroughly.1, first open the topic, downloaded to a packet. Open with Wireshark.There is a lot of data
Yesterday in the field to achieve the communication of industrial data, simply write it.1. In accordance with international practice, first introduceModbus Communication protocol sense is a physical level, several terminals in series, by setting each terminal different ID number, to access. Specific hardware implementations have not yet been studied.The system adopts Modbus RTU mode communication, using and checking, low in front.For the introduction
In the industrial field by the PLC remote control inverter application is very common, if the trench wiring inconvenience or frequency converter on the mobile device, then the use of wireless communication is the best solution. The benefits of this program are: No operating costs, no card, autonomous group network, distance, can pass through obstacles, bypassing the barrier, wireless transmission distance of more than 3 kilometers. Here we use Siemens PLC and Delta Inverter as an example, an
1.ModbusModbus technology has become an industry standard. It was developed and developed by the Modicon company. Its communication mainly usesrs232,rs485 and other communication media. It provides users with an open, flexible and standard communication technology that reducesDevelopment and maintenance costs.Modbus communication protocol by the main device to establish a message format, the format includes the device address, function code, data address and outError checking. From the device mu
(a), communication mode of transmission :Communication transmission is divided into independent information headers, and transmitted encoded data. The following communication mode definitions are also compatible with the Modbus RTU Communication protocol:
compilation Code
8 bits Binary
Starting bit
1 guests
Data bits
8 Guests
Parity bit
1-bit (even parity bit)
Label:1. Baidu knows: The time-out setting depends mainly on the response time of the slowest node on the bus, and also on how long it takes the master to poll all the nodes.Assuming that all the nodes on the bus, the response time of the slowest reaction from the node is 100ms, the time-out setting on this basis plus the length of a complete packet transceiver is almost. The longest packet is generally 256 bytes, at 11 bit 9600BPS This will probably need 300ms, then the timeout time is longer t
No more nonsense, the whole program and code will be released later.
Tool Download: http://download.csdn.net/detail/stevenking55/5186848
Tool source code Download:
It's basically three functions:
1.OnButtonjoin () Establishing a connection
void Cclientdlg::onbuttonjoin ()
{
//Todo:add your control notification handler code here
UpdateData (True) ;
CString servername = m_server_addr; Get the server address
int port = atoi (M_port);//Get Port
if (pmysocket! = NULL)
{
//delete pmysocket
Tag:endmodbusmiccrc Conversion toolbarfunctionclassmod NBSP;PUBLICNBSP;FUNCTIONNBSP;CHR_CRC (data () asbyte) AsString ' *rtu method of CRC check calculation dimcrcjaslong
dimiasinteger dimjasinteger CrcJ=65535 ' *CRCJ assignment 65535 fori=0toubound (data) '-2
' * Number of bytes in the loop to validatecrcj=crcjxordata (i) ' * Each byte is different from the current value of CRCJ or for j=0To7 ' * Cycle eight times if CrcJMod2=1Then
' * If the remainder of CRCJ current value e
+2 +3Format seee eeee emmm MMMM MMMM MMMM MMMM MMMMBinary 11000001 01001000 00000000 00000000Hex C1 48 00 00 From this example, you can get the following information:The sign bit is 1 to indicate a negative numberA power is a binary 10000010 or a decimal 130,130 minus 127 is 3, which is the actual power.The mantissa is the binary number after 10010000000000000000000 On the left side of the mantissa there is an omitted decimal point and 1, this 1 is often omitted in the preservation of floating-
Read-Write Analog registers:Send command (host to slave) format:[Device Address][Command Number[High Start register address8bit][Low8bit][high number of registers read8bit][Low8bit] [CRCthe low checksum8bit] [CRCthe High calibration8bit]Example:[11][03][00][6B][00][03][CRC low ][CRC high ]The meanings are as follows:One: device Address, the address in the example is a, the default address of the dissolved oxygen sensor side is 1,.A: the command number of the reading analog is fixed to the agreem
Implementation features
Add different Tlswebsocketlistener to pipeline based on different listener (TcpListener, Tlstcplistener, Websocketlistener, handler) of the User Configuration
Implementation steps
1, according to
SOURCE Blog Address: http://blog.csdn.net/pipinet123MQTT Exchange Group: 221405150 Implementation Capabilities
Add different Tlswebsocketlistener to pipeline based on different user-configured listener (TcpListener, Tlstcplistener,
1. Start-up vessel: Docker run-p 1883:1883-p 8161:8161-d leo/activemq
If there is no Docker, it is also possible to start activemq directly.
We just need to write publisher and Subscriber when the ACTIVEMQ is ready to start.
2. Need to add 2 maven
test Environment:
mqtt_client (Publish) QT 5.6.0 win10
mqtt_client (Subscribe) Ubuntu 12.04
mqtt_broker mosquitto ubuntu 12.0.4
the QT program was developed using the QMQTT library download address
Effect:
QT Client code: mainwindow.h
#ifndef
//////////////////////////////////////// /// // / * readcoils function: the status of the read relay. If yes, true is returned. send data length = 12 Recv Data Length = 10 Start address of the unsigned short int ADDR read relay (relay No.-1 ).
If the request is verified as two ASCII codes, the LRC is the round-robin sum, the modulo of 256, and the complement code, that is, the checksum. If you want four digits, change the modulo value.
Two textbox are used;
Textbox1 for Character
An RTU transmits a higher density than the ASCII. Parameter format: Start bit +8bits data bit + check digit + stop bit.1.1 Check default is parity, recommended for no verification, test to more than one stop bit (that is, stop bit is 2 bits)1.2 Send
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.