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
c63903b4
Commit
c63903b4
authored
Aug 20, 2015
by
Adam Wujek
💬
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'adam-shmem'
Improve opening of shmem.
parents
e2f6609e
d8cd90a8
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
234 additions
and
121 deletions
+234
-121
shmem.h
userspace/libwr/include/libwr/shmem.h
+2
-0
shmem.c
userspace/libwr/shmem.c
+24
-13
snmp_shmem.c
userspace/snmpd/snmp_shmem.c
+52
-16
rtu_stat.c
userspace/tools/rtu_stat.c
+37
-25
wr_mon.c
userspace/tools/wr_mon.c
+49
-28
wr_phytool.c
userspace/tools/wr_phytool.c
+19
-7
wrs_vlans.c
userspace/tools/wrs_vlans.c
+17
-6
wrs_watchdog.c
userspace/wrs_watchdog/wrs_watchdog.c
+18
-14
rtu_drv.c
userspace/wrsw_rtud/rtu_drv.c
+16
-12
No files found.
userspace/libwr/include/libwr/shmem.h
View file @
c63903b4
...
...
@@ -46,6 +46,8 @@ int wrs_shm_put(void *headptr);
/* A reader may wait for the writer (polling on version field) */
void
wrs_shm_wait
(
void
*
headptr
,
int
msec_step
,
int
retries
,
FILE
*
msg
);
int
wrs_shm_get_and_check
(
enum
wrs_shm_name
shm_name
,
struct
wrs_shm_head
**
head
);
/* The writer can allocate structures that live in the area itself */
void
*
wrs_shm_alloc
(
void
*
headptr
,
size_t
size
);
...
...
userspace/libwr/shmem.c
View file @
c63903b4
...
...
@@ -113,21 +113,32 @@ int wrs_shm_put(void *headptr)
return
0
;
}
/* A reader may wait for the writer (polling on version field) */
void
wrs_shm_wait
(
void
*
headptr
,
int
msec_step
,
int
retries
,
FILE
*
msg
)
/* Open shmem and check if data is available
* return 0 when ok, otherwise error
* 1 when openning shmem failed
* 2 when version is 0 */
int
wrs_shm_get_and_check
(
enum
wrs_shm_name
shm_name
,
struct
wrs_shm_head
**
head
)
{
struct
wrs_shm_head
*
head
=
headptr
;
int
i
;
for
(
i
=
0
;
i
<
retries
&&
!
head
->
version
;
i
++
)
{
if
(
!
i
&&
msg
)
fprintf
(
msg
,
"Waiting for my peer..."
);
if
(
msg
)
fprintf
(
stderr
,
"."
);
usleep
(
1000
*
msec_step
);
int
ii
;
int
version
;
/* try to open shmem */
if
(
!
(
*
head
)
&&
!
(
*
head
=
wrs_shm_get
(
shm_name
,
""
,
WRS_SHM_READ
|
WRS_SHM_LOCKED
)))
{
return
1
;
}
ii
=
wrs_shm_seqbegin
(
*
head
);
/* read head version */
version
=
(
*
head
)
->
version
;
if
(
wrs_shm_seqretry
(
*
head
,
ii
)
||
!
version
)
{
/* data in shmem available and version not zero */
return
2
;
}
if
(
i
&&
msg
)
fprintf
(
msg
,
"
\n
"
);
/* all ok */
return
0
;
}
/* The writer can allocate structures that live in the area itself */
...
...
userspace/snmpd/snmp_shmem.c
View file @
c63903b4
...
...
@@ -17,16 +17,27 @@ int *ppsi_ppi_nlinks;
/* RTUd */
struct
wrs_shm_head
*
rtud_head
;
static
void
init_shm_hal
(
void
)
{
hal_head
=
wrs_shm_get
(
wrs_shm_hal
,
""
,
WRS_SHM_READ
);
if
(
!
hal_head
)
{
snmp_log
(
LOG_ERR
,
"unable to open shm for HAL!
\n
"
);
exit
(
-
1
);
int
ret
;
int
n_wait
=
0
;
while
((
ret
=
wrs_shm_get_and_check
(
wrs_shm_hal
,
&
hal_head
))
!=
0
)
{
n_wait
++
;
if
(
n_wait
>
10
)
{
/* timeout! */
if
(
ret
==
1
)
{
snmp_log
(
LOG_ERR
,
"Unable to open HAL's "
"shmem!
\n
"
);
}
if
(
ret
==
2
)
{
snmp_log
(
LOG_ERR
,
"Unable to read HAL's "
"version!
\n
"
);
}
exit
(
-
1
);
}
sleep
(
1
);
}
wrs_shm_wait
(
hal_head
,
500
/* ms */
,
20
,
NULL
);
/* check hal's shm version */
if
(
hal_head
->
version
!=
HAL_SHMEM_VERSION
)
{
...
...
@@ -57,10 +68,22 @@ static void init_shm_hal(void)
static
void
init_shm_ppsi
(
void
)
{
ppsi_head
=
wrs_shm_get
(
wrs_shm_ptp
,
""
,
WRS_SHM_READ
);
if
(
!
ppsi_head
)
{
snmp_log
(
LOG_ERR
,
"unable to open shm for PPSI!
\n
"
);
exit
(
-
1
);
int
ret
;
int
n_wait
=
0
;
while
((
ret
=
wrs_shm_get_and_check
(
wrs_shm_ptp
,
&
ppsi_head
))
!=
0
)
{
n_wait
++
;
if
(
n_wait
>
10
)
{
/* timeout! */
if
(
ret
==
1
)
{
snmp_log
(
LOG_ERR
,
"Unable to open shm for PPSI!
\n
"
);
}
if
(
ret
==
2
)
{
snmp_log
(
LOG_ERR
,
"Unable to read PPSI's version!
\n
"
);
}
exit
(
-
1
);
}
sleep
(
1
);
}
/* check ppsi's shm version */
...
...
@@ -89,11 +112,24 @@ static void init_shm_ppsi(void)
static
void
init_shm_rtud
(
void
)
{
/* open RTUd's shm */
rtud_head
=
wrs_shm_get
(
wrs_shm_rtu
,
""
,
WRS_SHM_READ
);
if
(
!
rtud_head
)
{
snmp_log
(
LOG_ERR
,
"unable to open shm for RTUd!
\n
"
);
exit
(
-
1
);
int
ret
;
int
n_wait
=
0
;
while
((
ret
=
wrs_shm_get_and_check
(
wrs_shm_rtu
,
&
rtud_head
))
!=
0
)
{
n_wait
++
;
if
(
n_wait
>
10
)
{
/* timeout! */
if
(
ret
==
1
)
{
snmp_log
(
LOG_ERR
,
"Unable to open shm for "
"RTUd!
\n
"
);
}
if
(
ret
==
2
)
{
snmp_log
(
LOG_ERR
,
"Unable to read RTUd's "
"version!
\n
"
);
}
exit
(
-
1
);
}
sleep
(
1
);
}
/* check rtud's shm version */
...
...
userspace/tools/rtu_stat.c
View file @
c63903b4
...
...
@@ -131,48 +131,49 @@ void show_help(char *prgname)
int
get_nports_from_hal
(
void
)
{
struct
hal_shmem_header
*
h
;
struct
wrs_shm_head
*
hal_head
;
struct
wrs_shm_head
*
hal_head
=
NULL
;
int
hal_nports_local
;
/* local copy of number of ports */
int
ii
;
int
n_wait
=
0
;
int
ret
;
/* 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
*/
fprintf
(
stderr
,
"rtu_stat: unable to open shm for "
"HAL!
\n
"
);
}
/* wait for HAL */
while
((
ret
=
wrs_shm_get_and_check
(
wrs_shm_hal
,
&
hal_head
))
!=
0
)
{
n_wait
++
;
if
(
n_wait
>
10
)
{
if
(
ret
==
1
)
{
fprintf
(
stderr
,
"rtu_stat: Unable to open "
"HAL's shm !
\n
"
);
}
if
(
ret
==
2
)
{
fprintf
(
stderr
,
"rtu_stat: Unable to read "
"HAL's version!
\n
"
);
}
exit
(
1
);
}
sleep
(
1
);
}
h
=
(
void
*
)
hal_head
+
hal_head
->
data_off
;
n_wait
=
0
;
while
(
1
)
{
/* wait forever for HAL to produce consistent nports */
while
(
1
)
{
/* wait for 10 sec for HAL to produce consistent nports */
n_wait
++
;
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
*/
fprintf
(
stderr
,
"rtu_stat: Wait for HAL.
\n
"
);
fprintf
(
stderr
,
"rtu_stat: Wait for HAL.
\n
"
);
if
(
n_wait
>
10
)
{
exit
(
1
);
}
n_wait
++
;
sleep
(
1
);
}
/* check hal's shm version */
if
(
hal_head
->
version
!=
HAL_SHMEM_VERSION
)
{
fprintf
(
stderr
,
"rtu_stat: unknown
hal
's shm version %i "
fprintf
(
stderr
,
"rtu_stat: unknown
HAL
's shm version %i "
"(known is %i)
\n
"
,
hal_head
->
version
,
HAL_SHMEM_VERSION
);
exit
(
-
1
);
...
...
@@ -258,12 +259,23 @@ int read_htab(int *read_entries)
int
open_rtu_shm
(
void
)
{
int
n_wait
=
0
;
int
ret
;
/* open rtu shm */
rtu_port_shmem
=
wrs_shm_get
(
wrs_shm_rtu
,
""
,
WRS_SHM_READ
);
if
(
!
rtu_port_shmem
)
{
fprintf
(
stderr
,
"rtu_stat: %s: Can't join rtud's shmem: %s
\n
"
,
__func__
,
strerror
(
errno
));
return
-
1
;
while
((
ret
=
wrs_shm_get_and_check
(
wrs_shm_rtu
,
&
rtu_port_shmem
))
!=
0
)
{
n_wait
++
;
if
(
n_wait
>
10
)
{
if
(
ret
==
1
)
{
fprintf
(
stderr
,
"rtu_stat: Unable to open "
"RTUd's shm !
\n
"
);
}
if
(
ret
==
2
)
{
fprintf
(
stderr
,
"rtu_stat: Unable to read "
"RTUd's version!
\n
"
);
}
exit
(
1
);
}
sleep
(
1
);
}
/* check rtu shm version */
...
...
userspace/tools/wr_mon.c
View file @
c63903b4
...
...
@@ -7,6 +7,7 @@
#include <libwr/shmem.h>
#include <libwr/hal_shmem.h>
#include <libwr/switch_hw.h>
#include <libwr/wrs-msg.h>
#include <fpga_io.h>
#include <minipc.h>
#include <signal.h>
...
...
@@ -88,8 +89,8 @@ void ppsi_connect_minipc(void)
}
ptp_ch
=
minipc_client_create
(
"ptpd"
,
0
);
if
(
!
ptp_ch
)
{
fprintf
(
stderr
,
"Can't establish WRIPC connection
"
"to the PTP
daemon!
\n
"
);
pr_error
(
"Can't establish WRIPC connection to the PTP
"
"
daemon!
\n
"
);
exit
(
1
);
}
/* store pid of ppsi connected via minipc */
...
...
@@ -99,57 +100,73 @@ void ppsi_connect_minipc(void)
void
init_shm
(
void
)
{
struct
hal_shmem_header
*
h
;
hal_head
=
wrs_shm_get
(
wrs_shm_hal
,
""
,
WRS_SHM_READ
);
if
(
!
hal_head
)
{
fprintf
(
stderr
,
"unable to open shm for HAL!
\n
"
);
exit
(
1
);
int
ret
;
int
n_wait
=
0
;
while
((
ret
=
wrs_shm_get_and_check
(
wrs_shm_hal
,
&
hal_head
))
!=
0
)
{
n_wait
++
;
if
(
ret
==
1
)
{
pr_error
(
"Unable to open HAL's shm !
\n
"
);
}
if
(
ret
==
2
)
{
pr_error
(
"Unable to read HAL's version!
\n
"
);
}
if
(
n_wait
>
10
)
{
/* timeout! */
exit
(
-
1
);
}
sleep
(
1
);
}
wrs_shm_wait
(
hal_head
,
500
/* ms */
,
20
,
stderr
);
if
(
hal_head
->
version
!=
HAL_SHMEM_VERSION
)
{
fprintf
(
stderr
,
"wr_mon: unknown HAL's shm version %i "
"(known is %i)
\n
"
,
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
);
}
h
=
(
void
*
)
hal_head
+
hal_head
->
data_off
;
/* Assume number of ports does not change in runtime */
hal_nports_local
=
h
->
nports
;
if
(
hal_nports_local
>
HAL_MAX_PORTS
)
{
fprintf
(
stderr
,
"Too many ports reported by HAL. "
"%d vs %d supported
\n
"
,
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
);
}
/* Even after HAL restart, HAL will place structures at the same
* addresses. No need to re-dereference pointer at each read. */
hal_ports
=
wrs_shm_follow
(
hal_head
,
h
->
ports
);
if
(
!
hal_ports
)
{
fprintf
(
stderr
,
"Unable to follow hal_ports pointer in HAL's "
"shmem
"
);
pr_error
(
"Unable to follow hal_ports pointer in HAL's "
"shmem
\n
"
);
exit
(
1
);
}
temp_sensors
=
&
(
h
->
temp
);
ppsi_head
=
wrs_shm_get
(
wrs_shm_ptp
,
""
,
WRS_SHM_READ
);
if
(
!
ppsi_head
)
{
fprintf
(
stderr
,
"unable to open shm for PPSI!
\n
"
);
exit
(
1
);
n_wait
=
0
;
while
((
ret
=
wrs_shm_get_and_check
(
wrs_shm_ptp
,
&
ppsi_head
))
!=
0
)
{
n_wait
++
;
if
(
ret
==
1
)
{
pr_error
(
"Unable to open PPSI's shm !
\n
"
);
}
if
(
ret
==
2
)
{
pr_error
(
"Unable to read PPSI's version!
\n
"
);
}
if
(
n_wait
>
10
)
{
/* timeout! */
exit
(
-
1
);
}
sleep
(
1
);
}
wrs_shm_wait
(
ppsi_head
,
500
/* ms */
,
20
,
stderr
);
/* check hal's shm version */
if
(
ppsi_head
->
version
!=
WRS_PPSI_SHMEM_VERSION
)
{
fprintf
(
stderr
,
"wr_mon: unknown PPSI's shm version %i "
"(known is %i)
\n
"
,
ppsi_head
->
version
,
WRS_PPSI_SHMEM_VERSION
);
pr_error
(
"Unknown PPSI's shm version %i (known is %i)
\n
"
,
ppsi_head
->
version
,
WRS_PPSI_SHMEM_VERSION
);
exit
(
1
);
}
ppg
=
(
void
*
)
ppsi_head
+
ppsi_head
->
data_off
;
ppsi_servo
=
wrs_shm_follow
(
ppsi_head
,
ppg
->
global_ext_data
);
if
(
!
ppsi_servo
)
{
fprintf
(
stderr
,
"Cannot follow ppsi_servo in shmem.
\n
"
);
pr_error
(
"Cannot follow ppsi_servo in shmem.
\n
"
);
exit
(
1
);
}
...
...
@@ -483,8 +500,10 @@ int main(int argc, char *argv[])
{
int
opt
;
int
usecolor
=
1
;
wrs_msg_init
(
argc
,
argv
);
init_shm
();
while
((
opt
=
getopt
(
argc
,
argv
,
"sbgw"
))
!=
-
1
)
while
((
opt
=
getopt
(
argc
,
argv
,
"sbgw
qv
"
))
!=
-
1
)
{
switch
(
opt
)
{
...
...
@@ -498,14 +517,16 @@ int main(int argc, char *argv[])
read_hal
();
show_unadorned_ports
();
exit
(
0
);
case
'q'
:
break
;
/* done in wrs_msg_init() */
case
'v'
:
break
;
/* done in wrs_msg_init() */
default:
fprintf
(
stderr
,
"Unrecognized option.
\n
"
);
pr_error
(
"Unrecognized option.
\n
"
);
break
;
}
}
if
(
shw_fpga_mmap_init
()
<
0
)
{
fprintf
(
stderr
,
"%s: can't initialize FPGA mmap
\n
"
,
argv
[
0
]
);
pr_error
(
"Can't initialize FPGA mmap
\n
"
);
exit
(
1
);
}
term_init
(
usecolor
);
...
...
userspace/tools/wr_phytool.c
View file @
c63903b4
...
...
@@ -57,14 +57,26 @@ int hal_shm_init(void)
{
int
ii
;
struct
hal_shmem_header
*
h
;
/* open shmem to HAL */
hal_head
=
wrs_shm_get
(
wrs_shm_hal
,
""
,
WRS_SHM_READ
|
WRS_SHM_LOCKED
);
if
(
!
hal_head
)
{
fprintf
(
stderr
,
"FATAL: wr_phytool unable to open shm to HAL.
\n
"
);
return
-
1
;
int
n_wait
=
0
;
int
ret
;
/* wait for HAL */
while
((
ret
=
wrs_shm_get_and_check
(
wrs_shm_hal
,
&
hal_head
))
!=
0
)
{
n_wait
++
;
if
(
n_wait
>
10
)
{
if
(
ret
==
1
)
{
fprintf
(
stderr
,
"wr_phytool: Unable to open "
"HAL's shm !
\n
"
);
}
if
(
ret
==
2
)
{
fprintf
(
stderr
,
"wr_phytool: Unable to read "
"HAL's version!
\n
"
);
}
return
(
-
1
);
}
sleep
(
1
);
}
/* check hal's shm version */
if
(
hal_head
->
version
!=
HAL_SHMEM_VERSION
)
{
fprintf
(
stderr
,
"wr_mon: unknown hal's shm version %i "
...
...
userspace/tools/wrs_vlans.c
View file @
c63903b4
...
...
@@ -135,6 +135,8 @@ int main(int argc, char *argv[])
int
c
,
i
,
arg
;
unsigned
long
conf_pmask
=
0
;
//current '--ep' port mask
struct
rtu_shmem_header
*
rtu_hdr
;
int
n_wait
=
0
;
int
ret
;
prgname
=
argv
[
0
];
...
...
@@ -156,13 +158,22 @@ int main(int argc, char *argv[])
}
/* open rtu shm */
rtu_port_shmem
=
wrs_shm_get
(
wrs_shm_rtu
,
""
,
WRS_SHM_READ
);
if
(
!
rtu_port_shmem
)
{
fprintf
(
stderr
,
"%s: Can't join RTU's shmem
\n
"
,
prgname
);
exit
(
1
);
while
((
ret
=
wrs_shm_get_and_check
(
wrs_shm_rtu
,
&
rtu_port_shmem
))
!=
0
)
{
n_wait
++
;
if
(
n_wait
>
10
)
{
if
(
ret
==
1
)
{
fprintf
(
stderr
,
"%s: Unable to open RTUd's "
"shmem!
\n
"
,
prgname
);
}
if
(
ret
==
2
)
{
fprintf
(
stderr
,
"%s: Unable to read RTUd's "
"version!
\n
"
,
prgname
);
}
exit
(
1
);
}
sleep
(
1
);
}
/* FIXME: Wait for rtud to fill shmem */
/* check rtu shm version */
if
(
rtu_port_shmem
->
version
!=
RTU_SHMEM_VERSION
)
{
fprintf
(
stderr
,
"%s: unknown version %i (known is %i)
\n
"
,
...
...
userspace/wrs_watchdog/wrs_watchdog.c
View file @
c63903b4
...
...
@@ -51,41 +51,45 @@ int port_num = 0;
int
get_nports_from_hal
(
void
)
{
struct
hal_shmem_header
*
h
;
struct
wrs_shm_head
*
hal_head
;
struct
wrs_shm_head
*
hal_head
=
NULL
;
int
hal_nports_local
;
/* local copy of number of ports */
int
ii
;
int
n_wait
=
0
;
int
ret
;
/* 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
"
);
}
/* wait for HAL */
while
((
ret
=
wrs_shm_get_and_check
(
wrs_shm_hal
,
&
hal_head
))
!=
0
)
{
n_wait
++
;
if
(
n_wait
>
10
)
{
if
(
ret
==
1
)
{
pr_error
(
"Unable to open HAL's shmem!
\n
"
);
}
if
(
ret
==
2
)
{
pr_error
(
"Unable to read HAL's version!
\n
"
);
}
exit
(
1
);
}
sleep
(
1
);
}
h
=
(
void
*
)
hal_head
+
hal_head
->
data_off
;
n_wait
=
0
;
while
(
1
)
{
/* wait forever for HAL to produce consistent nports */
while
(
1
)
{
/* wait 10 sec for HAL to produce consistent nports */
n_wait
++
;
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
if
(
n_wait
>
10
)
{
/* print if waiting more than
10
seconds, some waiting
* is expected since hal requires few seconds to start
*/
pr_error
(
"Wait for HAL.
\n
"
);
exit
(
1
);
}
n_wait
++
;
sleep
(
1
);
}
...
...
userspace/wrsw_rtud/rtu_drv.c
View file @
c63903b4
...
...
@@ -76,33 +76,37 @@ void init_shm(void)
struct
hal_shmem_header
*
h
;
int
ii
;
int
n_wait
=
0
;
int
ret
;
/* wait for
ever 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
/* wait for HAL */
while
(
(
ret
=
wrs_shm_get_and_check
(
wrs_shm_hal
,
&
hal_head
))
!=
0
)
{
n_wait
++
;
if
(
n_wait
>
10
)
{
/* print if waiting more than
10 seconds, some wait
* is expected since hal requires few seconds to start
*/
pr_error
(
"unable to open shm for HAL!
\n
"
);
if
(
ret
==
1
)
{
pr_error
(
"Unable to open HAL's shmem!
\n
"
);
}
if
(
ret
==
2
)
{
pr_error
(
"Unable to read HAL's version!
\n
"
);
}
exit
(
1
);
}
n_wait
++
;
sleep
(
1
);
}
h
=
(
void
*
)
hal_head
+
hal_head
->
data_off
;
while
(
1
)
{
/* wait
forever
for HAL to produce consistent nports */
while
(
1
)
{
/* wait
10 sec
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 10 seconds, some wait
* is expected since hal requires few seconds to start
*/
if
(
n_wait
>
10
)
{
pr_error
(
"Wait for HAL.
\n
"
);
exit
(
1
);
}
n_wait
++
;
sleep
(
1
);
...
...
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