Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Tammo Jan Dijkema
dt_ctrl
Commits
00e102f8
Commit
00e102f8
authored
Feb 19, 2013
by
Jeroen Vreeken
Browse files
prevent j2000 tracker from hogging the cpu
parent
14b372fb
Changes
2
Hide whitespace changes
Inline
Side-by-side
console/console/console_j2000tracker.c
View file @
00e102f8
...
...
@@ -667,21 +667,27 @@ int main(int argc, char **argv)
if
(
fd_cmd
>=
high
)
high
=
fd_cmd
+
1
;
}
if
(
trace_fd
(
traceval_el
)
<
0
)
{
printf
(
"Reconnect elevation trace
\n
"
);
sleep
(
1
);
trace_init
(
trace_host
,
trace_port
,
el_trace_name
,
traceval_el
);
}
if
(
trace_fd
(
traceval_el
)
>=
0
)
{
FD_SET
(
trace_fd
(
traceval_el
),
&
fdset_rx
);
if
(
trace_fd
(
traceval_el
)
>=
high
)
high
=
trace_fd
(
traceval_el
)
+
1
;
}
else
{
trace_init
(
trace_host
,
trace_port
,
el_trace_name
,
traceval_el
);
}
if
(
trace_fd
(
traceval_az
)
<
0
)
{
printf
(
"Reconnect azimuth trace
\n
"
);
sleep
(
1
);
trace_init
(
trace_host
,
trace_port
,
az_trace_name
,
traceval_az
);
}
if
(
trace_fd
(
traceval_az
)
>=
0
)
{
FD_SET
(
trace_fd
(
traceval_az
),
&
fdset_rx
);
if
(
trace_fd
(
traceval_az
)
>=
high
)
high
=
trace_fd
(
traceval_az
)
+
1
;
}
else
{
trace_init
(
trace_host
,
trace_port
,
az_trace_name
,
traceval_az
);
}
fdset_cmd_clients
(
&
fdset_rx
,
&
high
);
...
...
console/console/setpoint.c
View file @
00e102f8
...
...
@@ -164,28 +164,28 @@ int setpoint_command_setpoint(struct setpoint_command *sp_cmd, float sp)
f
.
f
=
sp
;
*
(
uint32_t
*
)
arg
=
htonl
(
f
.
u
);
do
{
while
(
sp_cmd
->
fd
==
-
1
)
{
sleep
(
1
);
sp_cmd
->
fd
=
tcp_connect
(
sp_cmd
->
host
,
sp_cmd
->
port
);
setpoint_command_init_spg
(
sp_cmd
);
}
if
(
sp_cmd
->
fd
<
0
)
{
sleep
(
1
);
sp_cmd
->
fd
=
tcp_connect
(
sp_cmd
->
host
,
sp_cmd
->
port
);
setpoint_command_init_spg
(
sp_cmd
);
if
(
sp_cmd
->
fd
<
0
)
return
1
;
}
ret
=
write
(
sp_cmd
->
fd
,
command
,
4
);
ret
=
write
(
sp_cmd
->
fd
,
command
,
4
);
if
(
ret
!=
4
)
{
printf
(
"Connection to controller command socket lost.
\n
"
);
close
(
sp_cmd
->
fd
);
sp_cmd
->
fd
=
-
1
;
}
else
{
ret
=
write
(
sp_cmd
->
fd
,
arg
,
4
);
if
(
ret
!=
4
)
{
printf
(
"Connection to controller command socket lost.
\n
"
);
close
(
sp_cmd
->
fd
);
sp_cmd
->
fd
=
-
1
;
}
else
{
ret
=
write
(
sp_cmd
->
fd
,
arg
,
4
);
if
(
ret
!=
4
)
{
printf
(
"Connection to controller command socket lost.
\n
"
);
close
(
sp_cmd
->
fd
);
sp_cmd
->
fd
=
-
1
;
}
}
}
while
(
ret
!=
4
);
}
return
0
;
}
...
...
@@ -201,28 +201,28 @@ int setpoint_command_speed(struct setpoint_command *sp_cmd, float speed)
f
.
f
=
speed
;
*
(
uint32_t
*
)
arg
=
htonl
(
f
.
u
);
do
{
while
(
sp_cmd
->
fd
==
-
1
)
{
sleep
(
1
);
sp_cmd
->
fd
=
tcp_connect
(
sp_cmd
->
host
,
sp_cmd
->
port
);
setpoint_command_init_spg
(
sp_cmd
);
}
if
(
sp_cmd
->
fd
<
0
)
{
sleep
(
1
);
sp_cmd
->
fd
=
tcp_connect
(
sp_cmd
->
host
,
sp_cmd
->
port
);
setpoint_command_init_spg
(
sp_cmd
);
if
(
sp_cmd
->
fd
<
0
)
return
1
;
}
ret
=
write
(
sp_cmd
->
fd
,
command
,
4
);
ret
=
write
(
sp_cmd
->
fd
,
command
,
4
);
if
(
ret
!=
4
)
{
printf
(
"Connection to controller command socket lost.
\n
"
);
close
(
sp_cmd
->
fd
);
sp_cmd
->
fd
=
-
1
;
}
else
{
ret
=
write
(
sp_cmd
->
fd
,
arg
,
4
);
if
(
ret
!=
4
)
{
printf
(
"Connection to controller command socket lost.
\n
"
);
close
(
sp_cmd
->
fd
);
sp_cmd
->
fd
=
-
1
;
}
else
{
ret
=
write
(
sp_cmd
->
fd
,
arg
,
4
);
if
(
ret
!=
4
)
{
printf
(
"Connection to controller command socket lost.
\n
"
);
close
(
sp_cmd
->
fd
);
sp_cmd
->
fd
=
-
1
;
}
}
}
while
(
ret
!=
4
);
}
return
0
;
}
...
...
@@ -240,30 +240,28 @@ int setpoint_command_setpoint_time(struct setpoint_command *sp_cmd,
*
(
uint32_t
*
)
arg
=
htonl
(
f
.
u
);
*
(
uint32_t
*
)
&
arg
[
4
]
=
htonl
(
sptime
);
do
{
if
(
sp_cmd
->
fd
==
-
1
)
{
sp_cmd
->
fd
=
tcp_connect
(
sp_cmd
->
host
,
sp_cmd
->
port
);
if
(
sp_cmd
->
fd
<
0
)
{
return
1
;
}
setpoint_command_init_spg
(
sp_cmd
);
}
if
(
sp_cmd
->
fd
<
0
)
{
sleep
(
1
);
sp_cmd
->
fd
=
tcp_connect
(
sp_cmd
->
host
,
sp_cmd
->
port
);
setpoint_command_init_spg
(
sp_cmd
);
if
(
sp_cmd
->
fd
<
0
)
return
1
;
}
ret
=
write
(
sp_cmd
->
fd
,
command
,
4
);
if
(
ret
!=
4
)
{
ret
=
write
(
sp_cmd
->
fd
,
command
,
4
);
if
(
ret
!=
4
)
{
printf
(
"Connection to controller command socket lost.
\n
"
);
close
(
sp_cmd
->
fd
);
sp_cmd
->
fd
=
-
1
;
}
else
{
ret
=
write
(
sp_cmd
->
fd
,
arg
,
8
);
if
(
ret
!=
8
)
{
printf
(
"Connection to controller command socket lost.
\n
"
);
close
(
sp_cmd
->
fd
);
sp_cmd
->
fd
=
-
1
;
}
else
{
ret
=
write
(
sp_cmd
->
fd
,
arg
,
8
);
if
(
ret
!=
8
)
{
printf
(
"Connection to controller command socket lost.
\n
"
);
close
(
sp_cmd
->
fd
);
sp_cmd
->
fd
=
-
1
;
}
}
}
while
(
ret
!=
4
&&
ret
!=
8
);
}
return
0
;
}
...
...
@@ -273,21 +271,21 @@ int setpoint_command_setpoint_any(struct setpoint_command *sp_cmd,
{
int
ret
;
do
{
while
(
sp_cmd
->
fd
==
-
1
)
{
sleep
(
1
);
sp_cmd
->
fd
=
tcp_connect
(
sp_cmd
->
host
,
sp_cmd
->
port
);
setpoint_command_init_spg
(
sp_cmd
);
}
if
(
sp_cmd
->
fd
<
0
)
{
sleep
(
1
);
sp_cmd
->
fd
=
tcp_connect
(
sp_cmd
->
host
,
sp_cmd
->
port
);
setpoint_command_init_spg
(
sp_cmd
);
if
(
sp_cmd
->
fd
<
0
)
return
1
;
}
ret
=
write
(
sp_cmd
->
fd
,
cmd
,
len
);
if
(
ret
!=
len
)
{
printf
(
"Connection to controller command socket lost.
\n
"
);
close
(
sp_cmd
->
fd
);
sp_cmd
->
fd
=
-
1
;
}
}
while
(
ret
!=
len
);
ret
=
write
(
sp_cmd
->
fd
,
cmd
,
len
);
if
(
ret
!=
len
)
{
printf
(
"Connection to controller command socket lost.
\n
"
);
close
(
sp_cmd
->
fd
);
sp_cmd
->
fd
=
-
1
;
}
return
0
;
}
Write
Preview
Supports
Markdown
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