Commit e247e42a authored by Pavel Vainerman's avatar Pavel Vainerman

make style, minor fixes, version 2.0-alt34

parent c5d199b4
......@@ -13,7 +13,7 @@
Name: libuniset2
Version: 2.0
Release: alt33
Release: alt34
Summary: UniSet - library for building distributed industrial control systems
......@@ -445,6 +445,12 @@ mv -f %buildroot%python_sitelibdir_noarch/* %buildroot%python_sitelibdir/%oname
# ..
%changelog
* Mon May 18 2015 Pavel Vainerman <pv@altlinux.ru> 2.0-alt34
- (ModbusMaster): fixed bug in 'set respond senror mechanism'
- (ModbusMaster): refactoring
- make style
- minor fixes
* Fri May 15 2015 Pavel Vainerman <pv@altlinux.ru> 2.0-alt33
- (ModbusSlave): added support mbfunc.. (use RegID)
......
......@@ -64,7 +64,7 @@ MBExchange::MBExchange( UniSetTypes::ObjectId objId, UniSetTypes::ObjectId shmId
default_timeout = conf->getArgPInt("--" + prefix + "-timeout", it.getProp("timeout"), 5000);
int tout = conf->getArgPInt("--" + prefix + "-reopen-timeout", it.getProp("reopen_timeout"), default_timeout*2);
int tout = conf->getArgPInt("--" + prefix + "-reopen-timeout", it.getProp("reopen_timeout"), default_timeout * 2);
ptReopen.setTiming(tout);
aftersend_pause = conf->getArgPInt("--" + prefix + "-aftersend-pause", it.getProp("aftersend_pause"), 0);
......@@ -1027,7 +1027,7 @@ bool MBExchange::pollRTU( RTUDevice* dev, RegMap::iterator& it )
ModbusRTU::WriteOutputMessage msg(dev->mbaddr, p->mbreg);
for( auto i = 0; i < p->q_count; i++, it++ )
for( unsigned int i = 0; i < p->q_count; i++, it++ )
msg.addData(it->second->mbval);
it--;
......
......@@ -322,9 +322,9 @@ class MBExchange:
std::string prefix;
timeout_t stat_time; /*!< время сбора статистики обмена */
int poll_count;
PassiveTimer ptStatistic; /*!< таймер для сбора статистики обмена */
timeout_t stat_time; /*!< время сбора статистики обмена */
unsigned int poll_count;
PassiveTimer ptStatistic; /*!< таймер для сбора статистики обмена */
std::string prop_prefix; /*!< префикс для считывания параметров обмена */
......
......@@ -226,7 +226,6 @@ class MBTCPMaster:
// т.к. TCP может "зависнуть" на подключении к недоступному узлу
// делаем опрос в отдельном потоке
std::shared_ptr<ThreadCreator<MBTCPMaster>> pollThread; /*!< поток опроса */
UniSetTypes::uniset_rwmutex tcpMutex;
};
// -----------------------------------------------------------------------------
#endif // _MBTCPMaster_H_
......
......@@ -22,10 +22,10 @@ namespace ModbusRTU
{
// Базовые типы
typedef unsigned char ModbusByte; /*!< modbus-байт */
const int BitsPerByte = 8;
const unsigned short BitsPerByte = 8;
typedef unsigned char ModbusAddr; /*!< адрес узла в modbus-сети */
typedef unsigned short ModbusData; /*!< размер данных в modbus-сообщениях */
const int BitsPerData = 16;
const unsigned short BitsPerData = 16;
typedef unsigned short ModbusCRC; /*!< размер CRC16 в modbus-сообщениях */
// ---------------------------------------------------------------------
......@@ -33,44 +33,44 @@ namespace ModbusRTU
enum SlaveFunctionCode
{
fnUnknown = 0x00,
fnReadCoilStatus = 0x01, /*!< read coil status */
fnReadCoilStatus = 0x01, /*!< read coil status */
fnReadInputStatus = 0x02, /*!< read input status */
fnReadOutputRegisters = 0x03, /*!< read register outputs or memories or read word outputs or memories */
fnReadInputRegisters = 0x04, /*!< read input registers or memories or read word outputs or memories */
fnReadInputRegisters = 0x04, /*!< read input registers or memories or read word outputs or memories */
fnForceSingleCoil = 0x05, /*!< forces a single coil to either ON or OFF */
fnWriteOutputSingleRegister = 0x06, /*!< write register outputs or memories */
fnDiagnostics = 0x08, /*!< Diagnostics (Serial Line only) */
fnForceMultipleCoils = 0x0F, /*!< force multiple coils */
fnWriteOutputRegisters = 0x10, /*!< write register outputs or memories */
fnReadFileRecord = 0x14, /*!< read file record */
fnForceMultipleCoils = 0x0F, /*!< force multiple coils */
fnWriteOutputRegisters = 0x10, /*!< write register outputs or memories */
fnReadFileRecord = 0x14, /*!< read file record */
fnWriteFileRecord = 0x15, /*!< write file record */
fnMEI = 0x2B, /*!< Modbus Encapsulated Interface */
fnSetDateTime = 0x50, /*!< set date and time */
fnRemoteService = 0x53, /*!< call remote service */
fnJournalCommand = 0x65, /*!< read,write,delete alarm journal */
fnFileTransfer = 0x66 /*!< file transfer */
fnRemoteService = 0x53, /*!< call remote service */
fnJournalCommand = 0x65, /*!< read,write,delete alarm journal */
fnFileTransfer = 0x66 /*!< file transfer */
};
/*! Коды диагностически подфункций (для запроса 0x08) */
enum DiagnosticsSubFunction
{
subEcho = 0x00, /*!< (0) Return Query Data (echo) */
dgRestartComm = 0x01, /*!< (1) Restart Communications Option */
dgDiagReg = 0x02, /*!< (2) Return Diagnostic Register */
subEcho = 0x00, /*!< (0) Return Query Data (echo) */
dgRestartComm = 0x01, /*!< (1) Restart Communications Option */
dgDiagReg = 0x02, /*!< (2) Return Diagnostic Register */
dgChangeASCII = 0x03, /*!< (3) Change ASCII Input Delimiter */
dgForceListen = 0x04, /*!< (4) Force Listen Only Mode */
// 05.. 09 RESERVED
dgClearCounters = 0x0A, /*!< (10)Clear Counters and Diagnostic Register */
dgBusMsgCount = 0x0B, /*!< (11) Return Bus Message Count */
dgBusErrCount = 0x0C, /*!< (12) Return Bus Communication Error Count */
dgBusExceptCount = 0x0D, /*!< (13) Return Bus Exception Error Count */
dgClearCounters = 0x0A, /*!< (10)Clear Counters and Diagnostic Register */
dgBusMsgCount = 0x0B, /*!< (11) Return Bus Message Count */
dgBusErrCount = 0x0C, /*!< (12) Return Bus Communication Error Count */
dgBusExceptCount = 0x0D, /*!< (13) Return Bus Exception Error Count */
dgMsgSlaveCount = 0x0E, /*!< (14) Return Slave Message Count */
dgNoNoResponseCount = 0x0F, /*!< (15) Return Slave No Response Count */
dgSlaveNAKCount = 0x10, /*!< (16) Return Slave NAK Count */
dgSlaveBusyCount = 0x11, /*!< (17) Return Slave Busy Count */
dgBusCharOverrunCount = 0x12, /*!< (18) Return Bus Character Overrun Count */
dgSlaveBusyCount = 0x11, /*!< (17) Return Slave Busy Count */
dgBusCharOverrunCount = 0x12, /*!< (18) Return Bus Character Overrun Count */
// = 0x13, /*!< RESERVED */
dgClearOverrunCounter = 0x14 /*!< (20) Clear Overrun Counter and FlagN.A. */
dgClearOverrunCounter = 0x14 /*!< (20) Clear Overrun Counter and FlagN.A. */
// 21 ...65535 RESERVED
};
......@@ -121,9 +121,9 @@ namespace ModbusRTU
enum
{
/*! максимальное количество данных в пакете (c учётом контрольной суммы) */
MAXLENPACKET = 508, /*!< максимальная длина пакета 512 - header(2) - CRC(2) */
BroadcastAddr = 255, /*!< адрес для широковещательных сообщений */
MAXDATALEN = 127 /*!< максимальное число слов, которое можно запросить.
MAXLENPACKET = 508, /*!< максимальная длина пакета 512 - header(2) - CRC(2) */
BroadcastAddr = 255, /*!< адрес для широковещательных сообщений */
MAXDATALEN = 127 /*!< максимальное число слов, которое можно запросить.
Связано с тем, что в ответе есть поле bcnt - количество байт
Соответственно максимум туда можно записать только 255
*/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment