Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
cs
ds
4uhv
Commits
722eed44
Commit
722eed44
authored
Apr 11, 2022
by
Alessio Igor Bogani
Browse files
Remove retry logic
parent
6a724cdf
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/Agilent4uhv.cpp
View file @
722eed44
...
...
@@ -1511,7 +1511,6 @@ void Agilent4uhv::send_message(const int win, const windowType type,
const
vector
<
unsigned
char
>
&
payload
)
{
vector
<
unsigned
char
>
header
,
footer
;
int
attempts
=
2
;
init_header
(
win
,
type
,
header
);
int
crc
=
calc_crc
(
header
,
payload
);
...
...
@@ -1522,20 +1521,7 @@ void Agilent4uhv::send_message(const int win, const windowType type,
message
.
insert
(
message
.
end
(),
payload
.
begin
(),
payload
.
end
());
message
.
insert
(
message
.
end
(),
footer
.
begin
(),
footer
.
end
());
retry:
try
{
Serial2Client
::
write
(
message
);
}
catch
(
Tango
::
DevFailed
&
e
)
{
if
(
--
attempts
)
{
// Waiting the device
int
retries
=
0
;
while
(
get_state2
()
!=
Tango
::
ON
&&
retries
++
<
5
)
{
sleep
(
1
);
}
goto
retry
;
}
throw
;
}
Serial2Client
::
write
(
message
);
assert
(
Serial2Client
::
output_length
()
==
0
);
}
...
...
@@ -1543,18 +1529,9 @@ retry:
void
Agilent4uhv
::
receive_message
(
vector
<
unsigned
char
>
&
payload
)
{
vector
<
unsigned
char
>
message
,
crc
;
int
attempts
=
5
;
retry:
try
{
Serial2Client
::
read_until
(
ETX
,
message
);
Serial2Client
::
read
(
CRC_LENGTH
,
crc
);
}
catch
(
Tango
::
DevFailed
&
e
)
{
if
(
--
attempts
)
{
goto
retry
;
}
throw
;
}
Serial2Client
::
read_until
(
ETX
,
message
);
Serial2Client
::
read
(
CRC_LENGTH
,
crc
);
assert
(
Serial2Client
::
input_length
()
==
0
);
message
.
insert
(
message
.
end
(),
crc
.
begin
(),
crc
.
end
());
...
...
@@ -1645,7 +1622,7 @@ void Agilent4uhv::encode(const int &data, vector<unsigned char> &payload)
void
Agilent4uhv
::
decode
(
const
vector
<
unsigned
char
>
&
payload
,
double
&
data
)
{
// Left trim of spaces
size_t
start
;
size_t
start
=
0
;
for
(
size_t
i
=
0
;
i
<
payload
.
size
();
++
i
)
{
if
(
payload
[
i
]
!=
' '
)
{
start
=
i
;
...
...
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