Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
M
Mock Turtle
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
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
Mock Turtle
Commits
b527257f
Commit
b527257f
authored
Jan 26, 2015
by
Federico Vaga
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lib: according to udev version, path may change
Signed-off-by:
Federico Vaga
<
federico.vaga@cern.ch
>
parent
0f348f1d
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
12 deletions
+32
-12
libwrnc-internal.h
lib/libwrnc-internal.h
+2
-0
libwrnc.c
lib/libwrnc.c
+28
-11
libwrnc.h
lib/libwrnc.h
+2
-1
No files found.
lib/libwrnc-internal.h
View file @
b527257f
...
...
@@ -13,8 +13,10 @@
*/
struct
wrnc_desc
{
char
name
[
WRNC_NAME_LEN
];
/**< Name of the device */
char
path
[
WRNC_PATH_LEN
];
/**< path to device */
int
fd_dev
;
/**< File Descriptor of the device */
int
fd_cpu
[
WRNC_MAX_CPU
];
/**< File Descriptor of the CPUs */
};
#endif
lib/libwrnc.c
View file @
b527257f
...
...
@@ -58,13 +58,16 @@ int wrnc_init()
err
=
glob
(
"/dev/wrnc-[A-Fa-f0-9][A-Fa-f0-9][A-Fa-f0-9][A-Fa-f0-9]"
,
GLOB_NOSORT
,
NULL
,
&
g
);
if
(
err
!=
GLOB_NOMATCH
)
return
-
1
;
err
=
glob
(
"/dev/wr-node-core/wrnc-[A-Fa-f0-9][A-Fa-f0-9][A-Fa-f0-9][A-Fa-f0-9]"
,
GLOB_NOSORT
|
GLOB_APPEND
,
NULL
,
&
g
);
if
(
err
)
return
-
1
;
count
=
g
.
gl_pathc
;
for
(
i
=
0
;
i
<
count
;
++
i
)
strncpy
(
wrnc_dev_list
[
i
],
basename
(
g
.
gl_pathv
[
i
]),
WRNC_NAME_LEN
);
strncpy
(
wrnc_dev_list
[
i
],
basename
(
g
.
gl_pathv
[
i
]),
WRNC_NAME_LEN
);
for
(
i
=
count
;
i
<
WRNC_MAX_CARRIER
;
++
i
)
wrnc_dev_list
[
i
][
0
]
=
'\0'
;
...
...
@@ -128,14 +131,28 @@ char (*wrnc_list())[WRNC_NAME_LEN]
struct
wrnc_dev
*
wrnc_open
(
const
char
*
device
)
{
struct
wrnc_desc
*
wrnc
;
int
i
;
char
path
[
WRNC_PATH_LEN
+
WRNC_NAME_LEN
];
int
i
,
err
;
struct
stat
sb
;
wrnc
=
malloc
(
sizeof
(
struct
wrnc_desc
));
if
(
!
wrnc
)
return
NULL
;
strncpy
(
wrnc
->
name
,
device
,
WRNC_NAME_LEN
);
snprintf
(
path
,
WRNC_PATH_LEN
+
WRNC_NAME_LEN
,
"/dev/%s"
,
wrnc
->
name
);
err
=
stat
(
path
,
&
sb
);
if
(
!
err
)
{
strncpy
(
wrnc
->
path
,
"/dev"
,
WRNC_PATH_LEN
);
}
else
{
snprintf
(
path
,
WRNC_PATH_LEN
+
WRNC_NAME_LEN
,
"/dev/wr-node-core/%s"
,
wrnc
->
name
);
err
=
stat
(
path
,
&
sb
);
if
(
err
)
return
NULL
;
strncpy
(
wrnc
->
path
,
"/dev/wr-node-core"
,
WRNC_PATH_LEN
);
}
wrnc
->
fd_dev
=
-
1
;
for
(
i
=
0
;
i
<
WRNC_MAX_CPU
;
++
i
)
wrnc
->
fd_cpu
[
i
]
=
-
1
;
...
...
@@ -411,8 +428,8 @@ int wrnc_cpu_load_application_raw(struct wrnc_dev *wrnc,
char
path
[
WRNC_DEVICE_PATH_LEN
];
int
fd
,
i
=
0
;
snprintf
(
path
,
WRNC_DEVICE_PATH_LEN
,
"
/dev
/%s-cpu-%02d"
,
wdesc
->
name
,
index
);
snprintf
(
path
,
WRNC_DEVICE_PATH_LEN
,
"
%s
/%s-cpu-%02d"
,
wdesc
->
path
,
wdesc
->
name
,
index
);
fd
=
open
(
path
,
O_WRONLY
);
if
(
!
fd
)
return
-
1
;
...
...
@@ -445,8 +462,8 @@ int wrnc_cpu_dump_application_raw(struct wrnc_dev *wrnc,
char
path
[
WRNC_DEVICE_PATH_LEN
];
int
fd
,
i
=
0
,
c
=
100
;
snprintf
(
path
,
WRNC_DEVICE_PATH_LEN
,
"
/dev
/%s-cpu-%02d"
,
wdesc
->
name
,
index
);
snprintf
(
path
,
WRNC_DEVICE_PATH_LEN
,
"
%s
/%s-cpu-%02d"
,
wdesc
->
path
,
wdesc
->
name
,
index
);
fd
=
open
(
path
,
O_RDONLY
);
if
(
!
fd
)
return
-
1
;
...
...
@@ -562,8 +579,8 @@ struct wrnc_hmq *wrnc_hmq_open(struct wrnc_dev *wrnc, unsigned int index,
return
NULL
;
}
snprintf
(
path
,
64
,
"
/dev
/%s-hmq-%c-%02d"
,
wdesc
->
name
,
(
dir
?
'i'
:
'o'
),
index
);
snprintf
(
path
,
64
,
"
%s
/%s-hmq-%c-%02d"
,
wdesc
->
path
,
wdesc
->
name
,
(
dir
?
'i'
:
'o'
),
index
);
fd
=
open
(
path
,
(
dir
?
O_WRONLY
:
O_RDONLY
));
if
(
fd
<
0
)
return
NULL
;
...
...
@@ -653,7 +670,7 @@ static int wrnc_dev_open(struct wrnc_desc *wdesc)
if
(
wdesc
->
fd_dev
<
0
)
{
snprintf
(
path
,
64
,
"
/dev/%s"
,
wdesc
->
name
);
snprintf
(
path
,
64
,
"
%s/%s"
,
wdesc
->
path
,
wdesc
->
name
);
wdesc
->
fd_dev
=
open
(
path
,
O_RDWR
);
if
(
wdesc
->
fd_dev
<
0
)
return
-
1
;
...
...
lib/libwrnc.h
View file @
b527257f
...
...
@@ -46,7 +46,8 @@ struct wrnc_hmq {
#define WRNC_FMC_OFFSET 2
/* FIXME this is an hack because fmc-bus does not allow
us a dynamic allocation of fake fmc devices */
#define WRNC_NAME_LEN 12
#define WRNC_NAME_LEN 16
#define WRNC_PATH_LEN 32
#define WRNC_SYSFS_PATH_LEN 128
#define WRNC_SYSFS_READ_LEN 32
...
...
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