-
Notifications
You must be signed in to change notification settings - Fork 136
3.1 Global Tools
-
ValueHelper.cs
ValueHeloper is a value translation tooling class, included ValueHelper(Little Endian), BigEndianValueHelper(Big Endian), BigEndianMsbValueHelper(Big Endian with Most Significant Bit).
ValueHelper(s) are all singleton.-
ByteLength
Byte length of a basic type.
-
GetBytes
Change value type to byte array.
-
ObjectArrayToByteArray
Change value array to byte array.
-
GetValue
Change byte array to value type.
-
ByteArrayToObjectArray
-
ByteArrayToDestinationArray
Change byte array to value array.
-
SetValue
Set a value to byte array.
-
Instractions of "destination system".
Almost all functions in ValueHelper contains a param called "ref pos", this is a "pointer" point to the current position of byte array.
For example, there is a byte array with length 8, now 5th and 6th byte need to be changed to short value.
Currently pos is 4.0x08 0x17 0xa3 0xc4 0x00 0x05 0xa1 0x03 pos=4 Call "ValueHelper.Instance.GetShort" translation function.
(data == byte[], pos == 4) short a = ValueHelper.Instance.GetShort(data, ref pos);
After the translation, pos will be changed to 6 for the next translation.
0x08 0x17 0xa3 0xc4 0x00 0x05 0xa1 0x03 pos=6 -
For getting ValueHelper instance
ValueHelper has a static function called "GetInstance", it has a param called Endian. That means you can get proper ValueHelper by pass a Endian variable to ValueHelper. This is very useful when you want to make endian changable.
-
-
CRC16.cs
CRC16 offers CRC16 check/generation and LRC check/generation.
-
AsyncHelper.cs
AsyncHelper contains frequent async operations.
- RunSync: Run async method syncronize.
- WithCancellation: Run async method with cancellation token.
Also Nito.AsyncEx has been included in Modbus.Net.
-
AddressHelper.cs
AddressHelper include some fast sub address translation functions.
-
Introduction of "sub address system"
Modbus.Net has two coordinations for describing sub address: Absolute Coordinate and Relative Coordinate.
Following passeages will summarize their relationship.
Data read write protocol(3x, 4x) in Modbus uses word for data unit operation. Word contains 2 bytes, which equals ushort in C#.
Absolute Coordinate always regards 1 address to 8 bits. Relative Coordinate regards 1 address depends on data unit operation length.
For instace, Modbus data operation unit always contains 2 bytes, so Relative Coordinate is 16 bits for that.Absolute Relative 30001 6b 3X 1 6b 30001 15b 3X 2 7b 40116 13b 4X 232 5b Besides, Switching read write (0x, 1x) use bit for data unit operation.
So Relative Coordinate is 1 bit for an address.
Absolute Relative 00001 0b 0X 1 0b 00015 0b 0X 2 7b 10116 0b 1X 14 3b In brief, Relative Coordinate represents byte count for an address in a protocol. But only one byte is mapped to an address in Absolute Address.
AddressHelper contains the functions that change numbers between relative coordinate and absolute coordinate.
-
Modbus.Net Hangzhou Delian Science Technology Co.,Ltd. © 2023
-
2 Specification of Modbus.Net main framework
- 2.1 Modbus.Net Architecture
- 2.2 Transmission Control Layer Controller
- 2.3 Transmission Link Layer Connector
- 2.4 Concrete Protocol Layer ProtocolLinker
- 2.5 Abstract Protocol Layer Protocol
- 2.6 Protocol Presentation Layer Utility
- 2.7 Device Application Layer Machine
- 2.8 Task Application Layer MachineJob
-
3 Using Modbus.Net to implement a protocol
- 3.1 Global Tools
- 3.2 Extends Protocol and ProtocolUnit according to protocol specification
- 3.3 Extends Connector to create a link method
- 3.4 Extends Machine and Utility, creating two apis
- 3.5 Extends API methods to Machine and Utility
- 3.6 Extends Formater, Translator and Combiner, Creating Encoding,Decoding,Combining methods for address
- 3.7 Extends Controller, to control message