Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
W
White Rabbit Switch - Software
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
86
Issues
86
List
Board
Labels
Milestones
Merge Requests
4
Merge Requests
4
CI / CD
CI / CD
Pipelines
Schedules
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
White Rabbit Switch - Software
Commits
9fb15841
Commit
9fb15841
authored
Feb 04, 2014
by
José Luis Gutiérrez
Committed by
Alessandro Rubini
Feb 09, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
userspace/tools: add wr_management, to be called by php code
Signed-off-by:
Alessandro Rubini
<
rubini@gnudd.com
>
parent
19692cf9
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
182 additions
and
1 deletion
+182
-1
.gitignore
userspace/tools/.gitignore
+1
-0
Makefile
userspace/tools/Makefile
+4
-1
wr_management.c
userspace/tools/wr_management.c
+177
-0
No files found.
userspace/tools/.gitignore
View file @
9fb15841
...
...
@@ -10,3 +10,4 @@ wmapper
shw_ver
wr_date
fix_tai_offset
wr_management
\ No newline at end of file
userspace/tools/Makefile
View file @
9fb15841
TOOLS
=
rtu_stat wr_mon wr_phytool spll_dbg_proxy load-lm32 load-virtex com
TOOLS
+=
mapper wmapper shw_ver wr_date
TOOLS
+=
mapper wmapper shw_ver wr_date
wr_management
# # Standard stanza for cross-compilation (courtesy of the linux makefile)
...
...
@@ -41,6 +41,9 @@ rtu_stat: rtu_stat.o
wr_mon
:
wr_mon.o term.o
${
CC
}
-o
$@
$^
$(LDFLAGS)
wr_management
:
wr_management.o term.o
${
CC
}
-o
$@
$^
$(LDFLAGS)
wr_phytool
:
wr_phytool.o ../wrsw_hal/rt_client.o
${
CC
}
-o
$@
$^
$(LDFLAGS)
...
...
userspace/tools/wr_management.c
0 → 100644
View file @
9fb15841
/*
* wr_management.c
*
* Obtains the information that is displayed by the local management tool
*
* Created on: Nov 11, 2013
* Authors:
* - José Luis Gutiérrez (jgutierrez@ugr.es)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License...
*/
#include <stdio.h>
#include <stdlib.h>
#include <minipc.h>
#include "term.h"
#define PTP_EXPORT_STRUCTURES
#include "ptpd_exports.h"
#include "hal_client.h"
hexp_port_list_t
port_list
;
static
struct
minipc_ch
*
ptp_ch
;
void
print_args
(
int
argc
,
char
*
argv
[])
{
printf
(
"argc=%d: "
,
argc
);
while
(
argc
>
0
)
{
printf
(
"%s, "
,
argv
[
0
]);
argc
--
;
argv
++
;
}
printf
(
"
\n
"
);
}
void
init
(
int
usecolor
)
{
halexp_client_init
();
ptp_ch
=
minipc_client_create
(
"ptpd"
,
0
);
if
(
!
ptp_ch
)
{
fprintf
(
stderr
,
"Can't establish WRIPC connection "
"to the PTP daemon!
\n
"
);
exit
(
-
1
);
}
term_init
(
usecolor
);
halexp_query_ports
(
&
port_list
);
}
void
show_ports
()
{
int
i
,
j
;
time_t
t
;
struct
tm
*
tm
;
char
datestr
[
32
];
time
(
&
t
);
tm
=
localtime
(
&
t
);
strftime
(
datestr
,
sizeof
(
datestr
),
"%Y-%m-%d %H:%M:%S"
,
tm
);
for
(
i
=
0
;
i
<
18
;
i
++
)
{
char
if_name
[
10
],
found
=
0
;
hexp_port_state_t
state
;
snprintf
(
if_name
,
10
,
"wr%d"
,
i
);
for
(
j
=
0
;
j
<
port_list
.
num_ports
;
j
++
)
if
(
!
strcmp
(
port_list
.
port_names
[
j
],
if_name
))
{
found
=
1
;
break
;
}
if
(
!
found
)
continue
;
halexp_get_port_state
(
&
state
,
if_name
);
if
(
state
.
up
)
term_cprintf
(
C_GREEN
,
"up "
);
else
term_cprintf
(
C_RED
,
"down "
);
switch
(
state
.
mode
)
{
case
HEXP_PORT_MODE_WR_MASTER
:
term_cprintf
(
C_WHITE
,
"Master "
);
break
;
case
HEXP_PORT_MODE_WR_SLAVE
:
term_cprintf
(
C_WHITE
,
"Slave "
);
break
;
}
if
(
state
.
is_locked
)
term_cprintf
(
C_GREEN
,
"Locked "
);
else
term_cprintf
(
C_RED
,
"NoLock "
);
if
(
state
.
rx_calibrated
&&
state
.
tx_calibrated
)
term_cprintf
(
C_GREEN
,
"Calibrated
\n
"
);
else
term_cprintf
(
C_RED
,
"Uncalibrated
\n
"
);
}
}
int
track_onoff
=
1
;
void
show_screen
()
{
term_clear
();
//term_pcprintf(1, 1, C_BLUE, "WR Switch Sync Monitor v 1.0 [q = quit]");
show_ports
();
//show_servo();
fflush
(
stdout
);
}
int
main
(
int
argc
,
char
**
argv
)
{
int
usecolor
=
1
;
if
(
argc
>
1
){
if
(
!
strcmp
(
argv
[
1
],
"ports"
)){
usecolor
=
0
;
init
(
usecolor
);
setvbuf
(
stdout
,
NULL
,
_IOFBF
,
4096
);
if
(
term_poll
(
500
))
{
int
rval
;
track_onoff
=
1
-
track_onoff
;
minipc_call
(
ptp_ch
,
200
,
&
__rpcdef_cmd
,
&
rval
,
PTPDEXP_COMMAND_TRACKING
,
track_onoff
);
}
show_screen
();
term_restore
();
setlinebuf
(
stdout
);
printf
(
"
\n
"
);
}
else
if
(
!
strcmp
(
argv
[
1
],
"fan"
)){
}
else
{
printf
(
"
\n
Param required: "
);
printf
(
"
\n
Program usage: %s [param]"
,
argv
[
0
]);
printf
(
"
\t
ports
\t
-->
\t
WRS ports state
\n
"
);
}
}
else
{
printf
(
"
\n
Param required: "
);
printf
(
"
\n
Program usage: %s [param]"
,
argv
[
0
]);
printf
(
"
\t
ports
\t
-->
\t
WRS ports state
\n
"
);
}
return
0
;
}
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