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
31c31ceb
Commit
31c31ceb
authored
May 04, 2011
by
Pavel Vainerman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(ModbusTCP): подправил обработку исключений
parent
9a17e83a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
23 deletions
+23
-23
ModbusTCPMaster.cc
src/Communications/Modbus/ModbusTCPMaster.cc
+23
-23
No files found.
src/Communications/Modbus/ModbusTCPMaster.cc
View file @
31c31ceb
...
...
@@ -217,7 +217,7 @@ mbErrCode ModbusTCPMaster::query( ModbusAddr addr, ModbusMessage& msg,
}
catch
(
ModbusRTU
::
mbException
&
ex
)
{
dlog
[
Debug
::
WARN
]
<<
"(query): "
<<
ex
<<
endl
;
dlog
[
Debug
::
WARN
]
<<
"(query): "
<<
ex
<<
endl
;
}
catch
(
SystemError
&
err
)
{
...
...
@@ -232,6 +232,10 @@ mbErrCode ModbusTCPMaster::query( ModbusAddr addr, ModbusMessage& msg,
dlog
[
Debug
::
WARN
]
<<
"(query): tcp error: "
<<
e
.
getString
()
<<
endl
;
return
erTimeOut
;
}
catch
(
std
::
exception
&
e
)
{
dlog
[
Debug
::
CRIT
]
<<
"(query): "
<<
e
.
what
()
<<
std
::
endl
;
}
catch
(...)
{
dlog
[
Debug
::
WARN
]
<<
"(query): cath..."
<<
endl
;
...
...
@@ -272,20 +276,17 @@ void ModbusTCPMaster::reconnect()
tcp
=
new
ost
::
TCPStream
(
iaddr
.
c_str
(),
ost
::
Socket
::
IPV4
,
536
,
true
,
500
);
tcp
->
setTimeout
(
replyTimeOut_ms
);
}
catch
(
ost
::
Socket
*
socket
)
{
ost
::
tpport_t
port
;
int
err
=
socket
->
getErrorNumber
();
ost
::
InetAddress
saddr
=
(
ost
::
InetAddress
)
socket
->
getPeer
(
&
port
);
dlog
[
Debug
::
CRIT
]
<<
"tcp error "
<<
saddr
.
getHostname
()
<<
":"
<<
port
<<
" = "
<<
err
<<
endl
;
}
catch
(
ost
::
SockException
&
e
)
catch
(
std
::
exception
&
e
)
{
dlog
[
Debug
::
CRIT
]
<<
"tcp error: "
<<
e
.
getString
()
<<
endl
;
ostringstream
s
;
s
<<
"(ModbusTCPMaster): connection "
<<
s
.
str
()
<<
" error: "
<<
e
.
what
();
dlog
[
Debug
::
CRIT
]
<<
s
.
str
()
<<
std
::
endl
;
}
catch
(
...
)
catch
(
...
)
{
dlog
[
Debug
::
CRIT
]
<<
"create TCPStream["
<<
iaddr
<<
"] error..."
<<
endl
;
ostringstream
s
;
s
<<
"(ModbusTCPMaster): connection "
<<
s
.
str
()
<<
" error: catch ..."
;
dlog
[
Debug
::
CRIT
]
<<
s
.
str
()
<<
std
::
endl
;
}
}
// -------------------------------------------------------------------------
...
...
@@ -307,26 +308,25 @@ void ModbusTCPMaster::connect( ost::InetAddress addr, int port )
dlog
[
Debug
::
INFO
]
<<
"(ModbusTCPMaster): connect to "
<<
s
.
str
()
<<
endl
;
iaddr
=
s
.
str
();
ost
::
Thread
::
setException
(
ost
::
Thread
::
throwException
);
try
{
tcp
=
new
ost
::
TCPStream
(
iaddr
.
c_str
());
tcp
->
setTimeout
(
replyTimeOut_ms
);
}
catch
(
ost
::
Socket
*
socket
)
catch
(
std
::
exception
&
e
)
{
ost
::
tpport_t
port
;
int
err
=
socket
->
getErrorNumber
();
ost
::
InetAddress
saddr
=
(
ost
::
InetAddress
)
socket
->
getPeer
(
&
port
);
dlog
[
Debug
::
CRIT
]
<<
": tcp error "
<<
saddr
.
getHostname
()
<<
":"
<<
port
<<
" = "
<<
err
<<
endl
;
ostringstream
s
;
s
<<
"(ModbusTCPMaster): connection "
<<
s
.
str
()
<<
" error: "
<<
e
.
what
();
dlog
[
Debug
::
CRIT
]
<<
s
.
str
()
<<
std
::
endl
;
}
catch
(
ost
::
SockException
&
e
)
catch
(
...
)
{
dlog
[
Debug
::
CRIT
]
<<
"tcp error: "
<<
e
.
getString
()
<<
endl
;
ostringstream
s
;
s
<<
"(ModbusTCPMaster): connection "
<<
s
.
str
()
<<
" error: catch ..."
;
dlog
[
Debug
::
CRIT
]
<<
s
.
str
()
<<
std
::
endl
;
}
catch
(...)
{
dlog
[
Debug
::
CRIT
]
<<
"create TCPStream["
<<
iaddr
<<
"] error..."
<<
endl
;
}
// }
}
// -------------------------------------------------------------------------
...
...
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