Improved comments

This commit is contained in:
Jonny007-MKD 2014-08-29 16:13:05 +00:00
parent be86c13ffa
commit d145a51671
2 changed files with 29 additions and 30 deletions

View file

@ -2,18 +2,18 @@
// This file shall contain all information about device specific parameters. // This file shall contain all information about device specific parameters.
/// The aim of this file is to centralize this device specific information so that new Vendors can be added easily /// The aim of this file is to centralize this device specific information so that new Vendors can be added easily
/// Currently supported are Wago 750-881 and B&R X20BC0087. /// Currently supported are Wago 750-881 and B&R X20BC0087 hopefully only the vendors have to be distinguished
/// The Modbus specification leaves room for several parameters than can vary from vendor to vendor (and perhaps also from device to device). These parameters are: /// The Modbus specification leaves room for several parameters than can vary from vendor to vendor (and perhaps also from device to device). These parameters are:
/// - Start addresses for reading input bits/registers /// - Start addresses for reading input bits/registers
/// - Start addresses for reading output bits/registers /// - Start addresses for reading output bits/registers
/// - Start addresses for writing input bits/registers /// - Start addresses for writing input bits/registers
/// - Start addresses for writing output bits/registers /// - Start addresses for writing output bits/registers
/// - Maximum number of connected IO (bits and registers) /// - Maximum number of connected IO (bits and registers)
/// - Size of the receive window (how many telegrams can be processed at the same time) /// - Size of the receive window (how many requests can be received and buffered)
/// This file is used at two position: The majority of the functions are used to analyze devices when making the config. The minority has to be called when initiating a Modbus client so it knows about the addresses and window size. /// This file is used at two positions: The majority of the functions are used to analyze devices when making the config. The minority has to be called when initiating a Modbus client so it knows about the addresses and window size.
variables variables
{ {
// This structure is used by the Modbus Client. // This structure is used by the Modbus Client. It describes the device
struct struct
{ {
struct // Start addresses struct // Start addresses
@ -113,8 +113,8 @@ void DeviceInit(byte vendor)
/// <MakeConfig> /// <MakeConfig>
void _DeviceParseCode(word dev, enum Vendor vendor, struct deviceIOs dios) void _DeviceParseCode(word dev, enum Vendor vendor, struct deviceIOs dios)
{ {
byte input; byte input; // Yes: INPUT module; No: OUTPUT module
byte numChannels; byte numChannels; // Quantity of channels
char module[10]; char module[10];
strncpy(module, "..%d,", elCount(module)); strncpy(module, "..%d,", elCount(module));
@ -247,14 +247,14 @@ byte _DeviceGetInformation(enum Vendor vendor)
ModbusReadRegisters(0x2031, 64); // Connected IO 2 ModbusReadRegisters(0x2031, 64); // Connected IO 2
ModbusReadRegisters(0x2032, 64); // Connected IO 3 ModbusReadRegisters(0x2032, 64); // Connected IO 3
ModbusReadRegisters(0x2033, 63); // Connected IO 4 ModbusReadRegisters(0x2033, 63); // Connected IO 4
return 10; return 10; // 10 is the number of lines above (number of responses that we expect)
case BuR: case BuR:
ModbusReadRegisters(0x1083, 1); // Product Code ModbusReadRegisters(0x1083, 1); // Product Code
ModbusReadRegisters(0x1101, 1); // Number of AIs ModbusReadRegisters(0x1101, 1); // Number of AIs
ModbusReadRegisters(0x1103, 1); // Number of AOs ModbusReadRegisters(0x1103, 1); // Number of AOs
ModbusReadRegisters(0x1105, 1); // Number of DIs ModbusReadRegisters(0x1105, 1); // Number of DIs
ModbusReadRegisters(0x1107, 1); // Number of DOs ModbusReadRegisters(0x1107, 1); // Number of DOs
return 5; return 5; // 5 is the number of lines above (number of responses that we expect)
default: default:
writeDbg(AlgoError, "DeviceGetInformation: Unknown vendor id: %d", vendor); writeDbg(AlgoError, "DeviceGetInformation: Unknown vendor id: %d", vendor);
OnModbusClientPanics(VendorIdUnknown); OnModbusClientPanics(VendorIdUnknown);

View file

@ -5,7 +5,7 @@ variables
// Some constants // Some constants
const long WSA_IO_PENDING = 997; const long WSA_IO_PENDING = 997;
const long WSAEWOULDBLOCK = 10035; const long WSAEWOULDBLOCK = 10035;
const dword INVALID_IP = 0xffffffff; const dword INVALID_IP = 0xFFFFFFFF;
long gIpLastErr = 0; long gIpLastErr = 0;
char gIpLastErrStr[512] = ""; char gIpLastErrStr[512] = "";
@ -17,7 +17,6 @@ variables
dword gRemoteIP = INVALID_IP; dword gRemoteIP = INVALID_IP;
word gRemotePort = 0; word gRemotePort = 0;
// The buffer where to received telegrams are put // The buffer in which received telegrams are saved
byte gRxBuffer[8192]; byte gRxBuffer[8192];
} }