Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
U
uniset2
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
UniSet project repositories
uniset2
Commits
25ab0edf
Commit
25ab0edf
authored
May 05, 2011
by
Pavel Vainerman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(Modbus): Добавил функции настройки паузы ожидания символа.
Для возможности управления паузой из настроек или командной строки.
parent
f7913a5f
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
26 additions
and
3 deletions
+26
-3
libuniset.spec
conf/libuniset.spec
+4
-1
MBTCPMaster.cc
extensions/MBTCPMaster/MBTCPMaster.cc
+5
-0
MBTCPMaster.h
extensions/MBTCPMaster/MBTCPMaster.h
+1
-0
RTUExchange.cc
extensions/RTUExchange/RTUExchange.cc
+4
-1
RTUExchange.h
extensions/RTUExchange/RTUExchange.h
+1
-0
ModbusClient.h
include/modbus/ModbusClient.h
+7
-1
ModbusServer.h
include/modbus/ModbusServer.h
+4
-0
No files found.
conf/libuniset.spec
View file @
25ab0edf
...
...
@@ -3,7 +3,7 @@
Name: libuniset
Version: 1.0
Release: alt2
7
Release: alt2
8
Summary: UniSet - library for building distributed industrial control systems
License: GPL
Group: Development/C++
...
...
@@ -191,6 +191,9 @@ rm -f %buildroot%_libdir/*.la
%exclude %_pkgconfigdir/libUniSet.pc
%changelog
* Thu May 05 2011 Pavel Vainerman <pv@altlinux.ru> 1.0-alt28
- add setup function for ModbusTCPMaster and ModbusTCPServer
* Wed May 04 2011 Pavel Vainerman <pv@altlinux.ru> 1.0-alt27
- fixed bug in ModbusTCPMaster and ModbusTCPServer
...
...
extensions/MBTCPMaster/MBTCPMaster.cc
View file @
25ab0edf
...
...
@@ -80,6 +80,9 @@ pollThread(0)
initPause
=
conf
->
getArgPInt
(
"--"
+
prefix
+
"-initPause"
,
it
.
getProp
(
"initPause"
),
3000
);
sleepPause_usec
=
conf
->
getArgPInt
(
"--"
+
prefix
+
"-sleepPause-usec"
,
it
.
getProp
(
"slepePause"
),
100
);
force
=
conf
->
getArgInt
(
"--"
+
prefix
+
"-force"
,
it
.
getProp
(
"force"
));
force_out
=
conf
->
getArgInt
(
"--"
+
prefix
+
"-force-out"
,
it
.
getProp
(
"force_out"
));
...
...
@@ -182,6 +185,8 @@ void MBTCPMaster::initMB( bool reopen )
if
(
recv_timeout
>
0
)
mb
->
setTimeout
(
recv_timeout
);
mb
->
setSleepPause
(
sleepPause_usec
);
dlog
[
Debug
::
INFO
]
<<
myname
<<
"(init): ipaddr="
<<
iaddr
<<
" port="
<<
port
<<
endl
;
if
(
dlog
.
debugging
(
Debug
::
LEVEL9
)
)
...
...
extensions/MBTCPMaster/MBTCPMaster.h
View file @
25ab0edf
...
...
@@ -420,6 +420,7 @@ class MBTCPMaster:
bool
force_out
;
/*!< флаг означающий, принудительного чтения выходов */
bool
mbregFromID
;
int
polltime
;
/*!< переодичность обновления данных, [мсек] */
timeout_t
sleepPause_usec
;
PassiveTimer
ptHeartBeat
;
UniSetTypes
::
ObjectId
sidHeartBeat
;
...
...
extensions/RTUExchange/RTUExchange.cc
View file @
25ab0edf
...
...
@@ -62,8 +62,9 @@ prefix(prefix_)
recv_timeout
=
conf
->
getArgPInt
(
"--"
+
prefix
+
"-recv-timeout"
,
it
.
getProp
(
"recv_timeout"
),
50
);
int
alltout
=
conf
->
getArgPInt
(
"--"
+
prefix
+
"-all-timeout"
,
it
.
getProp
(
"all_timeout"
),
2000
);
ptAllNotRespond
.
setTiming
(
alltout
);
sleepPause_usec
=
conf
->
getArgPInt
(
"--"
+
prefix
+
"-sleepPause-usec"
,
it
.
getProp
(
"slepePause"
),
100
);
rs_pre_clean
=
conf
->
getArgInt
(
"--"
+
prefix
+
"-pre-clean"
,
it
.
getProp
(
"pre_clean"
));
noQueryOptimization
=
conf
->
getArgInt
(
"--"
+
prefix
+
"-no-query-optimization"
,
it
.
getProp
(
"no_query_optimization"
));
...
...
@@ -184,6 +185,8 @@ void RTUExchange::initMB( bool reopen )
if
(
recv_timeout
>
0
)
mb
->
setTimeout
(
recv_timeout
);
mb
->
setSleepPause
(
sleepPause_usec
);
dlog
[
Debug
::
INFO
]
<<
myname
<<
"(init): dev="
<<
devname
<<
" speed="
<<
ComPort
::
getSpeed
(
defSpeed
)
<<
endl
;
}
...
...
extensions/RTUExchange/RTUExchange.h
View file @
25ab0edf
...
...
@@ -244,6 +244,7 @@ class RTUExchange:
bool
force_out
;
/*!< флаг означающий, принудительного чтения выходов */
bool
mbregFromID
;
int
polltime
;
/*!< переодичность обновления данных, [мсек] */
timeout_t
sleepPause_usec
;
PassiveTimer
ptHeartBeat
;
UniSetTypes
::
ObjectId
sidHeartBeat
;
...
...
include/modbus/ModbusClient.h
View file @
25ab0edf
...
...
@@ -127,6 +127,9 @@ class ModbusClient
*/
int
setAfterSendPause
(
timeout_t
msec
);
/*! установить паузу при ожидании символа */
inline
void
setSleepPause
(
timeout_t
usec
){
sleepPause_usec
=
usec
;
}
void
initLog
(
UniSetTypes
::
Configuration
*
conf
,
const
std
::
string
name
,
const
std
::
string
logfile
=
""
);
void
setLog
(
DebugStream
&
dlog
);
...
...
@@ -172,7 +175,8 @@ class ModbusClient
ModbusRTU
::
ModbusMessage
qbuf
;
/*!< буфер для посылки сообщений */
timeout_t
replyTimeOut_ms
;
/*!< таймаут на ожидание ответа */
timeout_t
aftersend_msec
;
/*!< пауза после посылки запроса */
timeout_t
aftersend_msec
;
/*!< пауза после посылки запроса */
timeout_t
sleepPause_usec
;
/*!< пауза между попытками чтения символа из канала */
bool
crcNoCheckit
;
...
...
@@ -181,6 +185,8 @@ class ModbusClient
void
printProcessingTime
();
PassiveTimer
tmProcessing
;
private
:
};
...
...
include/modbus/ModbusServer.h
View file @
25ab0edf
...
...
@@ -42,6 +42,9 @@ class ModbusServer
/*! установить время ожидания по умолчанию */
void
setRecvTimeout
(
timeout_t
msec
);
/*! установить паузу при ожидании символа */
inline
void
setSleepPause
(
timeout_t
usec
){
sleepPause_usec
=
usec
;
}
inline
void
setCRCNoCheckit
(
bool
set
){
crcNoCheckit
=
set
;
}
inline
bool
isCRCNoCheckit
(){
return
crcNoCheckit
;
}
...
...
@@ -203,6 +206,7 @@ class ModbusServer
timeout_t
recvTimeOut_ms
;
/*!< таймаут на приём */
timeout_t
replyTimeout_ms
;
/*!< таймаут на формирование ответа */
timeout_t
aftersend_msec
;
/*!< пауза после посылки ответа */
timeout_t
sleepPause_usec
;
/*!< пауза между попытками чтения символа из канала */
bool
onBroadcast
;
/*!< включен режим работы с broadcst-сообщениями */
bool
crcNoCheckit
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment