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
098c55eb
Commit
098c55eb
authored
Jan 28, 2014
by
Pavel Vainerman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(MBSlave): исправил ошибку с неправильной работой счётчика запросов
parent
2c7ee345
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
21 additions
and
6 deletions
+21
-6
test.xml
conf/test.xml
+5
-0
MBSlave.cc
extensions/ModbusSlave/MBSlave.cc
+8
-5
MBSlave.h
extensions/ModbusSlave/MBSlave.h
+0
-1
start_tcp_fg.sh
extensions/ModbusSlave/start_tcp_fg.sh
+1
-0
start_tcp_fg2.sh
extensions/ModbusSlave/start_tcp_fg2.sh
+7
-0
No files found.
conf/test.xml
View file @
098c55eb
...
...
@@ -60,6 +60,9 @@
</GateList>
</MBMultiMaster1>
<MBSlave2
addr=
"0x3"
>
</MBSlave2>
<MBSlave1
addr=
"0x31"
aftersend-pause=
"0"
dev=
"/dev/ttyS0"
levels=
"info,warn,crit"
name=
"MBSlave1"
poll_time=
"200"
reply_timeout=
"60"
speed=
"9600"
>
<filelist>
<!-- Список файлов разрешённых для передачи по modbus
...
...
@@ -207,6 +210,7 @@
<item
id=
"55"
iotype=
"AI"
name=
"AI55_S"
textname=
"AI sensor 55"
rrd=
"1"
rrd1_ds=
"GAUGE:20:U:U"
/>
<item
id=
"56"
iotype=
"AI"
name=
"AI56_S"
textname=
"AI sensor 56"
rrd=
"2"
rrd2_ds=
"COUNTER:20:U:U"
/>
<item
id=
"57"
iotype=
"AI"
name=
"AI57_S"
textname=
"AI sensor 57"
rrd=
"2"
rrd2_ds=
"DERIVE:20:U:U"
/>
<item
id=
"58"
iotype=
"AI"
name=
"SVU_AskCount_AS"
textname=
"svu asl count"
/>
</sensors>
<thresholds
name=
"thresholds"
>
<sensor
iotype=
"AI"
name=
"AI_AS"
>
...
...
@@ -244,6 +248,7 @@
<item
id=
"6009"
name=
"MBMaster2"
/>
<item
id=
"6010"
name=
"MBMultiMaster1"
/>
<item
id=
"6011"
name=
"RRDStorage1"
/>
<item
id=
"6012"
name=
"MBSlave2"
/>
</objects>
</ObjectsMap>
<messages
idfromfile=
"1"
name=
"messages"
>
...
...
extensions/ModbusSlave/MBSlave.cc
View file @
098c55eb
...
...
@@ -379,6 +379,7 @@ void MBSlave::execute_rtu()
{
ModbusRTUSlaveSlot
*
rscomm
=
dynamic_cast
<
ModbusRTUSlaveSlot
*>
(
mbslot
);
ModbusRTU
::
mbErrCode
prev
=
erNoError
;
while
(
1
)
{
try
...
...
@@ -395,10 +396,10 @@ void MBSlave::execute_rtu()
askCount
=
askCount
>=
numeric_limits
<
long
>::
max
()
?
0
:
askCount
+
1
;
if
(
res
!=
ModbusRTU
::
erNoError
)
errmap
[
res
]
++
;
prev
=
res
;
}
prev
=
res
;
if
(
res
!=
ModbusRTU
::
erNoError
&&
res
!=
ModbusRTU
::
erTimeOut
)
dlog
[
Debug
::
WARN
]
<<
myname
<<
"(execute_rtu): "
<<
ModbusRTU
::
mbErr2Str
(
res
)
<<
endl
;
...
...
@@ -460,6 +461,8 @@ void MBSlave::execute_tcp()
{
ModbusTCPServerSlot
*
sslot
=
dynamic_cast
<
ModbusTCPServerSlot
*>
(
mbslot
);
ModbusRTU
::
mbErrCode
prev
=
erNoError
;
while
(
1
)
{
try
...
...
@@ -476,9 +479,9 @@ void MBSlave::execute_tcp()
askCount
=
askCount
>=
numeric_limits
<
long
>::
max
()
?
0
:
askCount
+
1
;
if
(
res
!=
ModbusRTU
::
erNoError
)
errmap
[
res
]
++
;
prev
=
res
;
}
prev
=
res
;
if
(
res
!=
ModbusRTU
::
erNoError
&&
res
!=
ModbusRTU
::
erTimeOut
)
dlog
[
Debug
::
WARN
]
<<
myname
<<
"(execute_tcp): "
<<
ModbusRTU
::
mbErr2Str
(
res
)
<<
endl
;
...
...
extensions/ModbusSlave/MBSlave.h
View file @
098c55eb
...
...
@@ -185,7 +185,6 @@ class MBSlave:
bool
respond_invert
;
PassiveTimer
ptTimeout
;
ModbusRTU
::
mbErrCode
prev
;
long
askCount
;
typedef
std
::
map
<
ModbusRTU
::
mbErrCode
,
unsigned
int
>
ExchangeErrorMap
;
ExchangeErrorMap
errmap
;
/*!< статистика обмена */
...
...
extensions/ModbusSlave/start_tcp_fg.sh
View file @
098c55eb
#!/bin/sh
uniset-start.sh
-f
./uniset-mbslave
--confile
test.xml
--dlog-add-levels
info,crit,warn
\
--smemory-id
SharedMemory
\
--mbs-name
MBSlave1
\
--mbs-type
TCP
--mbs-inet-addr
127.0.0.1
--mbs-inet-port
2048
--mbs-reg-from-id
1
--mbs-my-addr
0x01
\
--mbs-askcount-id
SVU_AskCount_AS
--mbs-respond-id
RespondRTU_S
--mbs-respond-invert
1
...
...
extensions/ModbusSlave/start_tcp_fg2.sh
0 → 100755
View file @
098c55eb
#!/bin/sh
uniset-start.sh
-f
./uniset-mbslave
--confile
test.xml
--dlog-add-levels
info,crit,warn
\
--smemory-id
SharedMemory
\
--mbs-name
MBSlave2
--mbs-type
TCP
--mbs-inet-addr
localhost
--mbs-inet-port
2050
--mbs-reg-from-id
1
--mbs-my-addr
0x01
\
# --mbs-askcount-id SVU_AskCount_AS --mbs-respond-id RespondRTU_S --mbs-respond-invert 1
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