Bachelorthesis/Modbus/include/ModbusCommonStructs.cin

74 lines
1.7 KiB
Text
Raw Normal View History

/*@!Encoding:1252*/
variables
{
// A normal Modbus Application Header. Every Modbus Packet begins with these 7 (+FuncCode) Bytes
struct ModbusApHeader
{
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
struct ModbusReqRead
{
struct ModbusApHeader Header;
word Address;
word Count;
};
// Write a single value to a bit/register
struct ModbusReqWriteSingle
{
struct ModbusApHeader Header;
word Address;
word Value;
};
// Write several values to a bit/register starting with Address
struct ModbusReqWriteBits
{
struct ModbusApHeader Header;
word Address;
word Count;
byte ByteCount;
byte Data[246]; // Max length: 1968 bits
};
// Write several values to bits starting with Address
struct ModbusReqWriteRegisters
{
struct ModbusApHeader Header;
word Address;
word Count;
byte ByteCount;
int Data[123]; // Max length: 123 registers
};
// Receive several bit values
struct ModbusResReceiveBits
{
struct ModbusApHeader Header;
byte ByteCount;
byte Data[250]; // Max length: 2000 bits
};
// Receive several register values
struct ModbusResReceiveRegisters
{
struct ModbusApHeader Header;
byte ByteCount;
int Data[125]; // Max length: 125 registers
};
// Confirm the write of a single bit/register
struct ModbusResConfirmSingle
{
struct ModbusApHeader Header;
word Address;
int Value;
};
// Confirm the write of several bits/registers
struct ModbusResConfirmMultiple
{
struct ModbusApHeader Header;
word Address;
word Count;
};
}