2014-05-15 14:43:52 +02:00
|
|
|
/*@!Encoding:1252*/
|
|
|
|
variables
|
|
|
|
{
|
|
|
|
// A normal Modbus Application Header. Every Modbus Packet begins with these 7 (+FuncCode) Bytes
|
2014-05-21 12:53:02 +02:00
|
|
|
struct ModbusApHeader
|
2014-05-15 14:43:52 +02:00
|
|
|
{
|
|
|
|
word TxID;
|
|
|
|
word Protocol;
|
|
|
|
word Length;
|
|
|
|
byte UnitID;
|
|
|
|
byte FuncCode;
|
|
|
|
};
|
|
|
|
// Read Data from the host. We only need the start address and the number of bits/registers we want to read
|
2014-05-21 12:53:02 +02:00
|
|
|
struct ModbusReqRead
|
2014-05-15 14:43:52 +02:00
|
|
|
{
|
|
|
|
struct ModbusApHeader Header;
|
|
|
|
word Address;
|
|
|
|
word Count;
|
|
|
|
};
|
|
|
|
// Write a single value to a bit/register
|
2014-05-21 12:53:02 +02:00
|
|
|
struct ModbusReqWriteSingle
|
2014-05-15 14:43:52 +02:00
|
|
|
{
|
|
|
|
struct ModbusApHeader Header;
|
|
|
|
word Address;
|
|
|
|
word Value;
|
|
|
|
};
|
|
|
|
// Write several values to a bit/register starting with Address
|
2014-05-21 12:53:02 +02:00
|
|
|
struct ModbusReqWriteBits
|
2014-05-15 14:43:52 +02:00
|
|
|
{
|
|
|
|
struct ModbusApHeader Header;
|
|
|
|
word Address;
|
|
|
|
word Count;
|
|
|
|
byte ByteCount;
|
|
|
|
byte Data[246]; // Max length: 1968 bits
|
|
|
|
};
|
|
|
|
// Write several values to bits starting with Address
|
2014-05-21 12:53:02 +02:00
|
|
|
struct ModbusReqWriteRegisters
|
2014-05-15 14:43:52 +02:00
|
|
|
{
|
|
|
|
struct ModbusApHeader Header;
|
|
|
|
word Address;
|
|
|
|
word Count;
|
|
|
|
byte ByteCount;
|
2014-05-21 12:53:02 +02:00
|
|
|
int Data[123]; // Max length: 123 registers
|
2014-05-15 14:43:52 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
// Receive several bit values
|
2014-05-21 12:53:02 +02:00
|
|
|
struct ModbusResReceiveBits
|
2014-05-15 14:43:52 +02:00
|
|
|
{
|
|
|
|
struct ModbusApHeader Header;
|
|
|
|
byte ByteCount;
|
|
|
|
byte Data[250]; // Max length: 2000 bits
|
|
|
|
};
|
|
|
|
// Receive several register values
|
2014-05-21 12:53:02 +02:00
|
|
|
struct ModbusResReceiveRegisters
|
2014-05-15 14:43:52 +02:00
|
|
|
{
|
|
|
|
struct ModbusApHeader Header;
|
|
|
|
byte ByteCount;
|
2014-05-21 12:53:02 +02:00
|
|
|
int Data[125]; // Max length: 125 registers
|
2014-05-15 14:43:52 +02:00
|
|
|
};
|
|
|
|
// Confirm the write of a single bit/register
|
2014-05-21 12:53:02 +02:00
|
|
|
struct ModbusResConfirmSingle
|
2014-05-15 14:43:52 +02:00
|
|
|
{
|
|
|
|
struct ModbusApHeader Header;
|
|
|
|
word Address;
|
|
|
|
int Value;
|
|
|
|
};
|
|
|
|
// Confirm the write of several bits/registers
|
2014-05-21 12:53:02 +02:00
|
|
|
struct ModbusResConfirmMultiple
|
2014-05-15 14:43:52 +02:00
|
|
|
{
|
|
|
|
struct ModbusApHeader Header;
|
|
|
|
word Address;
|
|
|
|
word Count;
|
|
|
|
};
|
|
|
|
}
|