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
b0a52ad2
Commit
b0a52ad2
authored
Oct 16, 2009
by
Pavel Vainerman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fized bug in MBTCPMaster
parent
705343d1
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
77 additions
and
11 deletions
+77
-11
MBTCPMaster.cc
extensions/MBTCPMaster/MBTCPMaster.cc
+45
-3
MBTCPMaster.h
extensions/MBTCPMaster/MBTCPMaster.h
+4
-0
RTUExchange.cc
extensions/RTUExchange/RTUExchange.cc
+1
-1
SharedMemory.cc
extensions/SharedMemory/SharedMemory.cc
+19
-2
SharedMemory.h
extensions/SharedMemory/SharedMemory.h
+1
-0
start_fg.sh
extensions/SharedMemory/start_fg.sh
+1
-1
ModbusTCPMaster.h
include/modbus/ModbusTCPMaster.h
+1
-1
ModbusTCPMaster.cc
src/Communications/Modbus/ModbusTCPMaster.cc
+5
-3
No files found.
extensions/MBTCPMaster/MBTCPMaster.cc
View file @
b0a52ad2
...
...
@@ -21,7 +21,8 @@ mbregFromID(false),
activated
(
false
),
noQueryOptimization
(
false
),
allNotRespond
(
false
),
prefix
(
prefix
)
prefix
(
prefix
),
no_extimer
(
false
)
{
// cout << "$ $" << endl;
...
...
@@ -119,7 +120,7 @@ prefix(prefix)
activateTimeout
=
conf
->
getArgPInt
(
"--"
+
prefix
+
"-activate-timeout"
,
20000
);
initMB
(
false
);
//
initMB(false);
printMap
(
rmap
);
// abort();
...
...
@@ -163,6 +164,9 @@ void MBTCPMaster::initMB( bool reopen )
mb
->
setTimeout
(
recv_timeout
);
dlog
[
Debug
::
INFO
]
<<
myname
<<
"(init): ipaddr="
<<
iaddr
<<
" port="
<<
port
<<
endl
;
if
(
dlog
.
debugging
(
Debug
::
LEVEL9
)
)
mb
->
setLog
(
dlog
);
}
catch
(
ModbusRTU
::
mbException
&
ex
)
{
...
...
@@ -197,7 +201,12 @@ void MBTCPMaster::waitSMReady()
void
MBTCPMaster
::
timerInfo
(
TimerMessage
*
tm
)
{
if
(
tm
->
id
==
tmExchange
)
step
();
{
if
(
no_extimer
)
askTimer
(
tm
->
id
,
0
);
else
step
();
}
}
// -----------------------------------------------------------------------------
void
MBTCPMaster
::
step
()
...
...
@@ -1515,6 +1524,9 @@ void MBTCPMaster::updateRSProperty( RSProperty* p, bool write_only )
if
(
!
save
&&
write_only
)
return
;
if
(
dlog
.
debugging
(
Debug
::
INFO
)
)
dlog
[
Debug
::
INFO
]
<<
"udpateP: sid="
<<
p
->
si
.
id
<<
" mbval="
<<
r
->
mbval
<<
endl
;
try
{
if
(
p
->
vType
==
VTypes
::
vtUnknown
)
...
...
@@ -1715,4 +1727,34 @@ void MBTCPMaster::updateRSProperty( RSProperty* p, bool write_only )
}
}
// -----------------------------------------------------------------------------
void
MBTCPMaster
::
execute
()
{
no_extimer
=
true
;
try
{
askTimer
(
tmExchange
,
0
);
}
catch
(...){}
initMB
(
false
);
while
(
1
)
{
try
{
step
();
}
catch
(
Exception
&
ex
)
{
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(execute): "
<<
ex
<<
std
::
endl
;
}
catch
(...)
{
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(execute): catch ..."
<<
endl
;
}
msleep
(
polltime
);
}
}
// -----------------------------------------------------------------------------
extensions/MBTCPMaster/MBTCPMaster.h
View file @
b0a52ad2
...
...
@@ -37,6 +37,8 @@ class MBTCPMaster:
/*! help- */
static
void
help_print
(
int
argc
,
const
char
*
const
*
argv
);
void
execute
();
static
const
int
NoSafetyState
=-
1
;
enum
Timer
...
...
@@ -235,6 +237,8 @@ class MBTCPMaster:
Trigger
trAllNotRespond
;
PassiveTimer
ptAllNotRespond
;
std
::
string
prefix
;
bool
no_extimer
;
};
// -----------------------------------------------------------------------------
#endif // _MBTCPMaster_H_
...
...
extensions/RTUExchange/RTUExchange.cc
View file @
b0a52ad2
...
...
@@ -1546,7 +1546,7 @@ bool RTUExchange::initDeviceInfo( RTUDeviceMap& m, ModbusRTU::ModbusAddr a, UniX
// -----------------------------------------------------------------------------
void
RTUExchange
::
printMap
(
RTUExchange
::
RTUDeviceMap
&
m
)
{
cout
<<
"devices:
"
<<
endl
;
cout
<<
"devices:
num="
<<
m
.
size
()
<<
endl
;
for
(
RTUExchange
::
RTUDeviceMap
::
iterator
it
=
m
.
begin
();
it
!=
m
.
end
();
++
it
)
{
cout
<<
" "
<<
*
(
it
->
second
)
<<
endl
;
...
...
extensions/SharedMemory/SharedMemory.cc
View file @
b0a52ad2
...
...
@@ -17,7 +17,8 @@ SharedMemory::SharedMemory( ObjectId id, string datafile ):
activated
(
false
),
workready
(
false
),
dblogging
(
false
),
msecPulsar
(
0
)
msecPulsar
(
0
),
iotypePulsar
(
UniversalIO
::
DigitalInput
)
{
// cout << "$Id: SharedMemory.cc,v 1.4 2009/01/24 11:20:19 vpashka Exp $" << endl;
...
...
@@ -100,6 +101,19 @@ SharedMemory::SharedMemory( ObjectId id, string datafile ):
siPulsar
.
node
=
conf
->
getLocalNode
();
msecPulsar
=
conf
->
getArgPInt
(
"--pulsar-msec"
,
it
.
getProp
(
"pulsar_msec"
),
5000
);
string
t
=
conf
->
getArgParam
(
"--pulsar-iotype"
,
it
.
getProp
(
"pulsar_iotype"
));
if
(
!
t
.
empty
()
)
{
iotypePulsar
=
UniSetTypes
::
getIOType
(
t
);
if
(
iotypePulsar
==
UniversalIO
::
UnknownIOType
)
{
ostringstream
err
;
err
<<
myname
<<
": Unknown iotype '"
<<
t
<<
"' for pulsar. Must be 'DI' or 'DO'"
;
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(init): "
<<
err
.
str
()
<<
endl
;
throw
SystemError
(
err
.
str
());
}
}
}
}
...
...
@@ -184,7 +198,10 @@ void SharedMemory::timerInfo( TimerMessage *tm )
{
bool
st
=
localGetState
(
ditPulsar
,
siPulsar
);
st
^=
true
;
localSaveState
(
ditPulsar
,
siPulsar
,
st
,
getId
());
if
(
iotypePulsar
==
UniversalIO
::
DigitalInput
)
localSaveState
(
ditPulsar
,
siPulsar
,
st
,
getId
());
else
if
(
iotypePulsar
==
UniversalIO
::
DigitalOutput
)
localSetState
(
ditPulsar
,
siPulsar
,
st
,
getId
());
}
}
}
...
...
extensions/SharedMemory/SharedMemory.h
View file @
b0a52ad2
...
...
@@ -189,6 +189,7 @@ class SharedMemory:
DIOStateList
::
iterator
ditPulsar
;
IOController_i
::
SensorInfo
siPulsar
;
UniversalIO
::
IOTypes
iotypePulsar
;
int
msecPulsar
;
private
:
...
...
extensions/SharedMemory/start_fg.sh
View file @
b0a52ad2
...
...
@@ -4,7 +4,7 @@ export LD_LIBRARY_PATH="../../lib/.libs;../lib/.libs"
ulimit
-Sc
10000000000
./uniset-start.sh
-f
./uniset-smemory
--smemory-id
SharedMemory
--pulsar-id
TestMode_S
\
./uniset-start.sh
-f
./uniset-smemory
--smemory-id
SharedMemory
--pulsar-id
DO_C
\
--confile
test.xml
--datfile
test.xml
\
--unideb-add-levels
info,crit,warn,level9,system
\
--dlog-add-levels
info,crit,warn
...
...
include/modbus/ModbusTCPMaster.h
View file @
b0a52ad2
...
...
@@ -35,7 +35,7 @@ class ModbusTCPMaster:
private
:
ost
::
TCPStream
*
tcp
;
static
int
nTransaction
;
int
nTransaction
;
std
::
queue
<
unsigned
char
>
qrecv
;
PassiveTimer
ptTimeout
;
std
::
string
iaddr
;
...
...
src/Communications/Modbus/ModbusTCPMaster.cc
View file @
b0a52ad2
...
...
@@ -14,6 +14,7 @@ using namespace UniSetTypes;
// -------------------------------------------------------------------------
ModbusTCPMaster
::
ModbusTCPMaster
()
:
tcp
(
0
),
nTransaction
(
0
),
iaddr
(
""
)
{
setCRCNoCheckit
(
true
);
...
...
@@ -56,7 +57,8 @@ mbErrCode ModbusTCPMaster::query( ModbusAddr addr, ModbusMessage& msg,
}
reconnect
();
if
(
!
isConnection
()
)
reconnect
();
assert
(
timeout
);
ptTimeout
.
setTiming
(
timeout
);
...
...
@@ -67,7 +69,7 @@ mbErrCode ModbusTCPMaster::query( ModbusAddr addr, ModbusMessage& msg,
try
{
if
(
nTransaction
>=
numeric_limits
<
int
>::
max
()
)
if
(
nTransaction
>=
numeric_limits
<
ModbusRTU
::
ModbusData
>::
max
()
)
nTransaction
=
0
;
ModbusTCP
::
MBAPHeader
mh
;
...
...
@@ -122,7 +124,7 @@ mbErrCode ModbusTCPMaster::query( ModbusAddr addr, ModbusMessage& msg,
}
if
(
ret
<
(
int
)
sizeof
(
rmh
)
)
return
erHardwareError
;
return
er
TimeOut
;
// return er
HardwareError;
rmh
.
swapdata
();
...
...
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