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
b3e19db3
Commit
b3e19db3
authored
May 18, 2015
by
Pavel Vainerman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(ModbusSlave): исправление ошибки в функции записи нескольких регистров.
parent
2159fa41
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
62 additions
and
18 deletions
+62
-18
libuniset2.spec
conf/libuniset2.spec
+5
-2
MBSlave.cc
extensions/ModbusSlave/MBSlave.cc
+3
-1
mbslave-test-configure.xml
extensions/ModbusSlave/tests/mbslave-test-configure.xml
+30
-15
test_mbslave.cc
extensions/ModbusSlave/tests/test_mbslave.cc
+24
-0
No files found.
conf/libuniset2.spec
View file @
b3e19db3
...
@@ -13,7 +13,7 @@
...
@@ -13,7 +13,7 @@
Name: libuniset2
Name: libuniset2
Version: 2.0
Version: 2.0
Release: alt34.
1
Release: alt34.
2
Summary: UniSet - library for building distributed industrial control systems
Summary: UniSet - library for building distributed industrial control systems
...
@@ -445,6 +445,9 @@ mv -f %buildroot%python_sitelibdir_noarch/* %buildroot%python_sitelibdir/%oname
...
@@ -445,6 +445,9 @@ mv -f %buildroot%python_sitelibdir_noarch/* %buildroot%python_sitelibdir/%oname
# ..
# ..
%changelog
%changelog
* Mon May 18 2015 Pavel Vainerman <pv@altlinux.ru> 2.0-alt34.2
- (ModbusSlave): fixed bug in much_real_write (mbfunc=0x10 processing)
* Mon May 18 2015 Pavel Vainerman <pv@etersoft.ru> 2.0-alt34.1
* Mon May 18 2015 Pavel Vainerman <pv@etersoft.ru> 2.0-alt34.1
- (ModbusSlave): fixed bug in readOutputRegisters
- (ModbusSlave): fixed bug in readOutputRegisters
...
@@ -458,7 +461,7 @@ mv -f %buildroot%python_sitelibdir_noarch/* %buildroot%python_sitelibdir/%oname
...
@@ -458,7 +461,7 @@ mv -f %buildroot%python_sitelibdir_noarch/* %buildroot%python_sitelibdir/%oname
- (ModbusSlave): added support mbfunc.. (use RegID)
- (ModbusSlave): added support mbfunc.. (use RegID)
* Wed May 13 2015 Pavel Vainerman <pv@altlinux.ru> 2.0-alt32
* Wed May 13 2015 Pavel Vainerman <pv@altlinux.ru> 2.0-alt32
- sync from 1.x/master: ModbusMaster: fixed bug: unstable timeout...(
thank`s ilyap@etersoft.ru)
- sync from 1.x/master: ModbusMaster: fixed bug: unstable timeout...(thank`s ilyap@etersoft.ru)
- make style
- make style
* Mon May 11 2015 Pavel Vainerman <pv@altlinux.ru> 2.0-alt31
* Mon May 11 2015 Pavel Vainerman <pv@altlinux.ru> 2.0-alt31
...
...
extensions/ModbusSlave/MBSlave.cc
View file @
b3e19db3
...
@@ -1283,9 +1283,11 @@ ModbusRTU::mbErrCode MBSlave::much_real_write( const ModbusRTU::ModbusData reg,
...
@@ -1283,9 +1283,11 @@ ModbusRTU::mbErrCode MBSlave::much_real_write( const ModbusRTU::ModbusData reg,
int
mbfunc
=
checkMBFunc
?
fn
:
default_mbfunc
;
int
mbfunc
=
checkMBFunc
?
fn
:
default_mbfunc
;
ModbusRTU
::
RegID
regID
=
genRegID
(
reg
,
mbfunc
);
ModbusRTU
::
RegID
regID
=
genRegID
(
reg
,
mbfunc
);
// ищем регистр.. "пропуская дырки"..
// ведь запросить могут начиная с "несуществующего регистра"
for
(
;
i
<
count
;
i
++
)
for
(
;
i
<
count
;
i
++
)
{
{
it
=
iomap
.
find
(
regID
);
it
=
iomap
.
find
(
regID
+
i
);
if
(
it
!=
iomap
.
end
()
)
if
(
it
!=
iomap
.
end
()
)
{
{
...
...
extensions/ModbusSlave/tests/mbslave-test-configure.xml
View file @
b3e19db3
...
@@ -104,10 +104,10 @@
...
@@ -104,10 +104,10 @@
<item
default=
"1"
id=
"1001"
mbs=
"1"
mbreg=
"2"
iotype=
"DI"
name=
"TestReadCoil2_S"
textname=
"Тестовый регистр для ReadCoil"
/>
<item
default=
"1"
id=
"1001"
mbs=
"1"
mbreg=
"2"
iotype=
"DI"
name=
"TestReadCoil2_S"
textname=
"Тестовый регистр для ReadCoil"
/>
<item
id=
"1002"
mbs=
"1"
mbreg=
"3"
iotype=
"DI"
name=
"TestReadCoil3_S"
textname=
"Тестовый регистр для ReadCoil"
/>
<item
id=
"1002"
mbs=
"1"
mbreg=
"3"
iotype=
"DI"
name=
"TestReadCoil3_S"
textname=
"Тестовый регистр для ReadCoil"
/>
<item
default=
"10"
id=
"1003"
mbs=
"1"
mbreg=
"10"
iotype=
"AI"
name=
"TestRead
03
_1"
textname=
"Тестовый регистр для 0x03"
/>
<item
default=
"10"
id=
"1003"
mbs=
"1"
mbreg=
"10"
iotype=
"AI"
name=
"TestRead
10
_1"
textname=
"Тестовый регистр для 0x03"
/>
<item
default=
"11"
id=
"1004"
mbs=
"1"
mbreg=
"11"
iotype=
"AI"
name=
"TestRead
03
_2"
textname=
"Тестовый регистр для 0x03"
/>
<item
default=
"11"
id=
"1004"
mbs=
"1"
mbreg=
"11"
iotype=
"AI"
name=
"TestRead
10
_2"
textname=
"Тестовый регистр для 0x03"
/>
<item
default=
"-10"
id=
"1005"
mbs=
"1"
mbreg=
"12"
iotype=
"AI"
name=
"TestRead
03
_3"
textname=
"Тестовый регистр для 0x03"
/>
<item
default=
"-10"
id=
"1005"
mbs=
"1"
mbreg=
"12"
iotype=
"AI"
name=
"TestRead
10
_3"
textname=
"Тестовый регистр для 0x03"
/>
<item
default=
"-10000"
id=
"1006"
mbs=
"1"
mbreg=
"13"
iotype=
"AI"
name=
"TestRead
03
_4"
textname=
"Тестовый регистр для 0x03"
/>
<item
default=
"-10000"
id=
"1006"
mbs=
"1"
mbreg=
"13"
iotype=
"AI"
name=
"TestRead
10
_4"
textname=
"Тестовый регистр для 0x03"
/>
<item
id=
"1007"
mbs=
"1"
mbreg=
"14"
iotype=
"AI"
name=
"TestRead05"
textname=
"Тестовый регистр для 0x05"
/>
<item
id=
"1007"
mbs=
"1"
mbreg=
"14"
iotype=
"AI"
name=
"TestRead05"
textname=
"Тестовый регистр для 0x05"
/>
<item
id=
"1008"
mbs=
"1"
mbreg=
"15"
iotype=
"AI"
name=
"TestRead06"
textname=
"Тестовый регистр для 0x06"
/>
<item
id=
"1008"
mbs=
"1"
mbreg=
"15"
iotype=
"AI"
name=
"TestRead06"
textname=
"Тестовый регистр для 0x06"
/>
...
@@ -166,17 +166,32 @@
...
@@ -166,17 +166,32 @@
<item
id=
"2024"
mbs=
"1"
mbreg=
"129"
nbit=
"1"
iotype=
"DI"
name=
"Test write nbit 1 (reg2)"
textname=
"Тестовый регистр для проверки записи nbit (reg 2)"
/>
<item
id=
"2024"
mbs=
"1"
mbreg=
"129"
nbit=
"1"
iotype=
"DI"
name=
"Test write nbit 1 (reg2)"
textname=
"Тестовый регистр для проверки записи nbit (reg 2)"
/>
<item
id=
"2025"
mbs=
"1"
mbreg=
"129"
nbit=
"5"
iotype=
"AI"
name=
"Test write nbit 5 (reg2)"
textname=
"Тестовый регистр для проверки записи nbit (reg 2)"
/>
<item
id=
"2025"
mbs=
"1"
mbreg=
"129"
nbit=
"5"
iotype=
"AI"
name=
"Test write nbit 5 (reg2)"
textname=
"Тестовый регистр для проверки записи nbit (reg 2)"
/>
<!-- read 03 count=10 -->
<!-- read 03,04 count=10 -->
<item
default=
"1"
id=
"2026"
mbs=
"1"
mbreg=
"130"
iotype=
"AI"
name=
"Test_CountRead03_1"
textname=
"Тестовый регистр для 0x03"
/>
<item
default=
"1"
id=
"2026"
mbs=
"1"
mbreg=
"130"
iotype=
"AI"
name=
"Test_CountRead10_1"
textname=
"Тестовый регистр для 0x03"
/>
<item
default=
"2"
id=
"2027"
mbs=
"1"
mbreg=
"131"
iotype=
"AI"
name=
"Test_CountRead03_2"
textname=
"Тестовый регистр для 0x03"
/>
<item
default=
"2"
id=
"2027"
mbs=
"1"
mbreg=
"131"
iotype=
"AI"
name=
"Test_CountRead10_2"
textname=
"Тестовый регистр для 0x03"
/>
<item
default=
"3"
id=
"2028"
mbs=
"1"
mbreg=
"132"
iotype=
"AI"
name=
"Test_CountRead03_3"
textname=
"Тестовый регистр для 0x03"
/>
<item
default=
"3"
id=
"2028"
mbs=
"1"
mbreg=
"132"
iotype=
"AI"
name=
"Test_CountRead10_3"
textname=
"Тестовый регистр для 0x03"
/>
<item
default=
"4"
id=
"2029"
mbs=
"1"
mbreg=
"133"
iotype=
"AI"
name=
"Test_CountRead03_4"
textname=
"Тестовый регистр для 0x03"
/>
<item
default=
"4"
id=
"2029"
mbs=
"1"
mbreg=
"133"
iotype=
"AI"
name=
"Test_CountRead10_4"
textname=
"Тестовый регистр для 0x03"
/>
<item
default=
"5"
id=
"2030"
mbs=
"1"
mbreg=
"134"
iotype=
"AI"
name=
"Test_CountRead03_5"
textname=
"Тестовый регистр для 0x03"
/>
<item
default=
"5"
id=
"2030"
mbs=
"1"
mbreg=
"134"
iotype=
"AI"
name=
"Test_CountRead10_5"
textname=
"Тестовый регистр для 0x03"
/>
<item
default=
"6"
id=
"2031"
mbs=
"1"
mbreg=
"135"
iotype=
"AI"
name=
"Test_CountRead03_6"
textname=
"Тестовый регистр для 0x03"
/>
<item
default=
"6"
id=
"2031"
mbs=
"1"
mbreg=
"135"
iotype=
"AI"
name=
"Test_CountRead10_6"
textname=
"Тестовый регистр для 0x03"
/>
<item
default=
"7"
id=
"2032"
mbs=
"1"
mbreg=
"136"
iotype=
"AI"
name=
"Test_CountRead03_7"
textname=
"Тестовый регистр для 0x03"
/>
<item
default=
"7"
id=
"2032"
mbs=
"1"
mbreg=
"136"
iotype=
"AI"
name=
"Test_CountRead10_7"
textname=
"Тестовый регистр для 0x03"
/>
<item
default=
"8"
id=
"2033"
mbs=
"1"
mbreg=
"137"
iotype=
"AI"
name=
"Test_CountRead03_8"
textname=
"Тестовый регистр для 0x03"
/>
<item
default=
"8"
id=
"2033"
mbs=
"1"
mbreg=
"137"
iotype=
"AI"
name=
"Test_CountRead10_8"
textname=
"Тестовый регистр для 0x03"
/>
<item
default=
"9"
id=
"2034"
mbs=
"1"
mbreg=
"138"
iotype=
"AI"
name=
"Test_CountRead03_9"
textname=
"Тестовый регистр для 0x03"
/>
<item
default=
"9"
id=
"2034"
mbs=
"1"
mbreg=
"138"
iotype=
"AI"
name=
"Test_CountRead10_9"
textname=
"Тестовый регистр для 0x03"
/>
<item
default=
"10"
id=
"2035"
mbs=
"1"
mbreg=
"139"
iotype=
"AI"
name=
"Test_CountRead03_10"
textname=
"Тестовый регистр для 0x03"
/>
<item
default=
"10"
id=
"2035"
mbs=
"1"
mbreg=
"139"
iotype=
"AI"
name=
"Test_CountRead10_10"
textname=
"Тестовый регистр для 0x03"
/>
<!-- write10 -->
<!-- специально делаем дырку, чтобы проверить запрос на запись "в несуществующий регистр" среди группы -->
<item
default=
"1"
id=
"2036"
iotype=
"AI"
name=
"Test_CountWrite10_1"
textname=
"Тестовый регистр для 0x10"
/>
<item
default=
"2"
id=
"2037"
iotype=
"AI"
name=
"Test_CountWrite10_1"
textname=
"Тестовый регистр для 0x10"
/>
<item
id=
"2038"
mbs=
"1"
mbreg=
"150"
iotype=
"AI"
name=
"Test_CountWrite10_1"
textname=
"Тестовый регистр для 0x10"
/>
<item
id=
"2039"
mbs=
"1"
mbreg=
"151"
iotype=
"AI"
name=
"Test_CountWrite10_2"
textname=
"Тестовый регистр для 0x10"
/>
<item
id=
"2040"
mbs=
"1"
mbreg=
"152"
iotype=
"AI"
name=
"Test_CountWrite10_3"
textname=
"Тестовый регистр для 0x10"
/>
<item
id=
"2041"
mbs=
"1"
mbreg=
"153"
iotype=
"AI"
name=
"Test_CountWrite10_4"
textname=
"Тестовый регистр для 0x10"
/>
<item
id=
"2042"
mbs=
"1"
mbreg=
"154"
iotype=
"AI"
name=
"Test_CountWrite10_5"
textname=
"Тестовый регистр для 0x10"
/>
<item
id=
"2043"
mbs=
"1"
mbreg=
"155"
iotype=
"AI"
name=
"Test_CountWrite10_6"
textname=
"Тестовый регистр для 0x10"
/>
<item
id=
"2044"
mbs=
"1"
mbreg=
"156"
iotype=
"AI"
name=
"Test_CountWrite10_7"
textname=
"Тестовый регистр для 0x10"
/>
<item
id=
"2045"
mbs=
"1"
mbreg=
"157"
iotype=
"AI"
name=
"Test_CountWrite10_8"
textname=
"Тестовый регистр для 0x10"
/>
<item
id=
"2046"
mbs=
"1"
mbreg=
"158"
iotype=
"AI"
name=
"Test_CountWrite10_9"
textname=
"Тестовый регистр для 0x10"
/>
<item
id=
"2047"
mbs=
"1"
mbreg=
"159"
iotype=
"AI"
name=
"Test_CountWrite10_10"
textname=
"Тестовый регистр для 0x10"
/>
<item
id=
"10000"
iotype=
"DI"
name=
"TestMode_S"
textname=
"Тестовый датчик"
/>
<item
id=
"10000"
iotype=
"DI"
name=
"TestMode_S"
textname=
"Тестовый датчик"
/>
...
...
extensions/ModbusSlave/tests/test_mbslave.cc
View file @
b3e19db3
...
@@ -1081,4 +1081,28 @@ TEST_CASE("read03(04) 10 registers", "[modbus][mbslave][mbtcpslave][readmore]")
...
@@ -1081,4 +1081,28 @@ TEST_CASE("read03(04) 10 registers", "[modbus][mbslave][mbtcpslave][readmore]")
}
}
// -------------------------------------------------------------
// -------------------------------------------------------------
TEST_CASE
(
"write10: 10 registers"
,
"[modbus][mbslave][mbtcpslave][writemore]"
)
{
using
namespace
VTypes
;
InitTest
();
UniSetTypes
::
ObjectId
id
=
2036
;
int
offset
=
2
;
ModbusRTU
::
ModbusData
tREG
=
150
-
offset
;
// реальные регистры начинаются с 150
int
num
=
10
;
ModbusRTU
::
WriteOutputMessage
msg
(
slaveaddr
,
tREG
);
for
(
int
i
=
1
;
i
<=
num
;
i
++
)
msg
.
addData
(
i
);
ModbusRTU
::
WriteOutputRetMessage
ret
=
mb
->
write10
(
msg
);
REQUIRE
(
ret
.
start
==
tREG
);
REQUIRE
(
ret
.
quant
==
num
);
for
(
int
i
=
0
;
i
<
num
;
i
++
)
{
REQUIRE
(
(
signed
short
)
ui
->
getValue
(
id
+
i
)
==
(
i
+
1
)
);
}
}
// -------------------------------------------------------------
/*! \todo Доделать тесты на считывание с разными prop_prefix.. */
/*! \todo Доделать тесты на считывание с разными prop_prefix.. */
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