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
83
Issues
83
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
e99115d5
Commit
e99115d5
authored
Jul 09, 2015
by
Adam Wujek
💬
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
userspace/wrs_watchdog: read number of ports from HAL
Signed-off-by:
Adam Wujek
<
adam.wujek@cern.ch
>
parent
de213a5c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
68 additions
and
1 deletion
+68
-1
wrs_watchdog.c
userspace/wrs_watchdog/wrs_watchdog.c
+68
-1
No files found.
userspace/wrs_watchdog/wrs_watchdog.c
View file @
e99115d5
...
...
@@ -32,6 +32,9 @@
#include <regs/wdog-regs.h>
#include "wrs_watchdog.h"
#include <libwr/shmem.h>
#include <libwr/hal_shmem.h>
#define RST_THR 2
#define wdog_write(reg, val) \
...
...
@@ -43,7 +46,63 @@
static
char
*
prgname
;
int
daemon_mode
;
int
list_mode
;
int
port_num
=
18
;
int
port_num
=
0
;
int
get_nports_from_hal
(
void
)
{
struct
hal_shmem_header
*
h
;
struct
wrs_shm_head
*
hal_head
;
int
hal_nports_local
;
/* local copy of number of ports */
int
ii
;
int
n_wait
=
0
;
/* wait forever for HAL */
while
(
!
(
hal_head
=
wrs_shm_get
(
wrs_shm_hal
,
""
,
WRS_SHM_READ
|
WRS_SHM_LOCKED
)))
{
if
(
n_wait
>
5
)
{
/* print if waiting more than 5 seconds, some waiting
* is expected since hal requires few seconds to start
*/
pr_error
(
"unable to open shm for HAL!
\n
"
);
}
n_wait
++
;
sleep
(
1
);
}
h
=
(
void
*
)
hal_head
+
hal_head
->
data_off
;
n_wait
=
0
;
while
(
1
)
{
/* wait forever for HAL to produce consistent nports */
ii
=
wrs_shm_seqbegin
(
hal_head
);
/* Assume number of ports does not change in runtime */
hal_nports_local
=
h
->
nports
;
if
(
!
wrs_shm_seqretry
(
hal_head
,
ii
))
break
;
if
(
n_wait
>
5
)
{
/* print if waiting more than 5 seconds, some waiting
* is expected since hal requires few seconds to start
*/
pr_error
(
"Wait for HAL.
\n
"
);
}
n_wait
++
;
sleep
(
1
);
}
/* check hal's shm version */
if
(
hal_head
->
version
!=
HAL_SHMEM_VERSION
)
{
pr_error
(
"unknown hal's shm version %i (known is %i)
\n
"
,
hal_head
->
version
,
HAL_SHMEM_VERSION
);
exit
(
-
1
);
}
if
(
hal_nports_local
>
HAL_MAX_PORTS
)
{
pr_error
(
"Too many ports reported by HAL. %d vs %d "
"supported
\n
"
,
hal_nports_local
,
HAL_MAX_PORTS
);
exit
(
-
1
);
}
return
hal_nports_local
;
}
uint32_t
show_counter
(
void
)
{
...
...
@@ -243,6 +302,7 @@ int main(int argc, char *argv[])
break
;
case
'n'
:
port_num
=
atoi
(
optarg
);
pr_info
(
"Read %d ports from cmdline
\n
"
,
port_num
);
break
;
case
'h'
:
default:
...
...
@@ -251,12 +311,19 @@ int main(int argc, char *argv[])
}
}
if
(
!
port_num
)
{
/* if port_num not read from parameter read it from HAL */
port_num
=
get_nports_from_hal
();
pr_info
(
"Read %d ports from HAL
\n
"
,
port_num
);
}
if
(
!
daemon_mode
&&
list_mode
)
{
list_fsms
();
}
if
(
daemon_mode
)
{
daemonize
();
pr_info
(
"Demonize
\n
"
);
endless_watchdog
();
}
...
...
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