⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 readme.txt

📁 自己编写的mod bus 协议源代码。基于keilc51开发。主要使用回调函数
💻 TXT
字号:
1.Function Code

01 Read Coil Status
======================
QUERY
				Example
Field Name 			(Hex)
Slave Address		 	11
Function 			01
Starting Address Hi 		00
Starting Address Lo 		13
No. of Points Hi 		00
No. of Points Lo 		25
Error Check (LRC or CRC) 	--
---------------------------------------------
RESPONSE
				Example
Field Name 			(Hex)
Slave Address 			11
Function 			01
Byte Count 			05
Data (Coils 27–20)		 CD
Data (Coils 35–28)		 6B
Data (Coils 43–36)		 
Data (Coils 51–44)		 
Data (Coils 56–52)		 1B
Error Check (LRC or CRC) 	--

02 Read Input Status
======================
QUERY
				Example
Field Name 			(Hex)
Slave Address 			11
Function 			02
Starting Address Hi 		00
Starting Address Lo 		C4
No. of Points Hi 		00
No. of Points Lo 		16
Error Check (LRC or CRC)	--
---------------------------------------------
RESPONSE
				Example
Field Name 			(Hex)
Slave Address 			11
Function 			02
Byte Count 			03
Data (Inputs 10204–10197)	 AC
Data (Inputs 10212–10205)	 DB
Data (Inputs 10218–10213)	 35
Error Check (LRC or CRC) 	--

03 Read Holding Registers
======================
QUERY
				Example
Field Name 			(Hex)
Slave Address 			11
Function 			03
Starting Address Hi 		00
Starting Address Lo 		6B
No. of Points Hi 		00
No. of Points Lo 		03
Error Check (LRC or CRC) 	–
---------------------------------------------
RESPONSE
				Example
Field Name 			(Hex)
Slave Address 			11
Function 			03
Byte Count 			06
Data Hi (Register 40108) 	02
Data Lo (Register 40108) 	2B
Data Hi (Register 40109) 	00
Data Lo (Register 40109) 	00
Data Hi (Register 40110) 	00
Data Lo (Register 40110) 	64
Error Check (LRC or CRC) 	––


04 Read Input Registers
======================
QUERY
				Example
Field Name 			(Hex)
Slave Address 			11
Function 			04
Starting Address Hi 		00
Starting Address Lo 		08
No. of Points Hi 		00
No. of Points Lo 		01
Error Check (LRC or CRC) 	--
---------------------------------------------
RESPONSE
				Example
Field Name 			(Hex)
Slave Address 			11
Function 			04
Byte Count 			02
Data Hi (Register 30009) 	00
Data Lo (Register 30009) 	0A
Error Check (LRC or CRC) 	––

05 Force Single Coil
======================
QUERY
				Example
Field Name 			(Hex)
Slave Address 			11
Function 			05
Coil Address Hi			00
Coil Address Lo 		AC
Force Data Hi 			FF
Force Data Lo 			00
Error Check (LRC or CRC) 	––
---------------------------------------------
RESPONSE
				Example
Field Name 			(Hex)
Slave Address 			11
Function 			05
Coil Address Hi 		00
Coil Address Lo 		AC
Force Data Hi 			FF
Force Data Lo 			00
Error Check (LRC or CRC) 	--

06 Preset Single Register
======================
QUERY
				Example
Field Name 			(Hex)
Slave Address 			11
Function 			06
Register Address Hi 		00
Register Address Lo 		01
Preset Data Hi 			00
Preset Data Lo 			03
Error Check (LRC or CRC) 	--
---------------------------------------------
RESPONSE
				Example
Field Name 			(Hex)
Slave Address 			11
Function 			06
Register Address Hi 		00
Register Address Lo 		01
Preset Data Hi 			00
Preset Data Lo 			03
Error Check (LRC or CRC) 	--

2.Exception Codes

Code 	Name 				Meaning
01 	ILLEGAL FUNCTION 		The function code received in the query
					is not an allowable action for the slave.
					If a Poll Program Complete command
					was issued, this code indicates that no
					program function preceded it.
02 	ILLEGAL DATA ADDRESS 		The data address received in the query
					is not an allowable address for the
					slave.
03	ILLEGAL DATA VALUE 		A value contained in the query data
					field is not an allowable value for the
					slave.
04 	SLAVE DEVICE FAILURE 		An unrecoverable error occurred while
					the slave was attempting to perform the
					requested action.
05 	ACKNOWLEDGE 			The slave has accepted the request
					and is processing it, but a long duration
					of time will be required to do so. This
					response is returned to prevent a
					timeout error from occurring in the
					master. The master can next issue a
					Poll Program Complete message to
					determine if processing is completed.
06 	SLAVE DEVICE BUSY 		The slave is engaged in processing a
					long–duration program command. The
					master should retransmit the message
					later when the slave is free.
07 	NEGATIVE ACKNOWLEDGE 		The slave cannot perform the program
					function received in the query. This
					code is returned for an unsuccessful
					programming request using function
					code 13 or 14 decimal. The master
					should request diagnostic or error
					information from the slave.
08 	MEMORY PARITY ERROR 		The slave attempted to read extended
					memory, but detected a parity error in
					the memory. The master can retry the
					request, but service may be required on
					the slave device.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -