Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
FMC Software Support
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Projects
FMC Software Support
Commits
c5c8ef55
Commit
c5c8ef55
authored
4 years ago
by
Federico Vaga
Browse files
Options
Downloads
Patches
Plain Diff
lib|tools: dump EEPROM content to stdout
Signed-off-by:
Federico Vaga
<
federico.vaga@cern.ch
>
parent
6fddf58a
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
lib/fmc/core.h
+2
-0
2 additions, 0 deletions
lib/fmc/core.h
lib/libfmc.c
+18
-0
18 additions, 0 deletions
lib/libfmc.c
tools/fmc-slot-eeprom.c
+36
-4
36 additions, 4 deletions
tools/fmc-slot-eeprom.c
with
56 additions
and
4 deletions
lib/fmc/core.h
+
2
−
0
View file @
c5c8ef55
...
...
@@ -34,6 +34,8 @@ int fmc_slot_eeprom_type_get(struct fmc_tkn *tkn, unsigned int slot_n,
char
*
str
,
size_t
max_len
);
int
fmc_slot_eeprom_type_set
(
struct
fmc_tkn
*
tkn
,
unsigned
int
slot_n
,
const
char
*
str
,
size_t
max_len
);
int
fmc_slot_eeprom_size
(
struct
fmc_tkn
*
tkn
,
unsigned
int
slot_n
,
unsigned
int
*
size
);
int
fmc_slot_eeprom_read
(
struct
fmc_tkn
*
tkn
,
unsigned
int
slot_n
,
char
*
buf
,
size_t
len
,
off_t
offset
);
int
fmc_slot_eeprom_write
(
struct
fmc_tkn
*
tkn
,
unsigned
int
slot_n
,
...
...
This diff is collapsed.
Click to expand it.
lib/libfmc.c
+
18
−
0
View file @
c5c8ef55
...
...
@@ -368,6 +368,24 @@ int fmc_slot_eeprom_type_set(struct fmc_tkn *tkn, unsigned int slot_n,
return
err
;
}
int
fmc_slot_eeprom_size
(
struct
fmc_tkn
*
tkn
,
unsigned
int
slot_n
,
unsigned
int
*
size
)
{
struct
fmc_carrier
*
carrier
=
(
struct
fmc_carrier
*
)
tkn
;
struct
fmc_slot
*
slot
=
__fmc_slot_get
(
carrier
,
slot_n
);
char
len_c
[
8
];
unsigned
long
len
;
strncpy
(
len_c
,
slot
->
eeprom_type
+
3
,
sizeof
(
len_c
));
len
=
strtol
(
len_c
,
NULL
,
10
);
if
(
errno
==
ERANGE
||
errno
==
EINVAL
)
return
-
1
;
*
size
=
(
len
*
1024
)
/
8
;
return
0
;
}
int
fmc_slot_eeprom_read
(
struct
fmc_tkn
*
tkn
,
unsigned
int
slot_n
,
char
*
buf
,
size_t
len
,
off_t
offset
)
{
...
...
This diff is collapsed.
Click to expand it.
tools/fmc-slot-eeprom.c
+
36
−
4
View file @
c5c8ef55
...
...
@@ -23,7 +23,8 @@ static void help(void)
"
\t
-h print help
\n
"
"
\t
-c carrier number
\n
"
"
\t
-s slot number
\n
"
"
\t
-t EEPROM type to set
\n
"
,
"
\t
-t EEPROM type to set
\n
"
"
\t
-d dump EEPROM content
\n
"
,
name
);
}
...
...
@@ -33,6 +34,29 @@ static void print_version(void)
name
,
git_version
,
fmc_version_get
());
}
static
void
print_dump
(
struct
fmc_tkn
*
fmc
,
unsigned
int
slot_n
,
const
char
*
eeprom_type
)
{
char
*
buf
;
unsigned
int
len
;
int
ret
;
ret
=
fmc_slot_eeprom_size
(
fmc
,
slot_n
,
&
len
);
if
(
ret
<
0
)
fputs
(
"Failed to get EEPROM size
\n
"
,
stderr
);
buf
=
malloc
(
len
);
if
(
!
buf
)
{
fputs
(
"Failed to allocate buffer
\n
"
,
stderr
);
return
;
}
ret
=
fmc_slot_eeprom_read
(
fmc
,
slot_n
,
buf
,
len
,
0
);
if
(
ret
>
0
)
fwrite
(
buf
,
len
,
1
,
stdout
);
else
fputs
(
"Failed to read EEPROM
\n
"
,
stderr
);
}
int
main
(
int
argc
,
char
*
argv
[])
{
struct
fmc_tkn
*
fmc
;
...
...
@@ -41,6 +65,7 @@ int main(int argc, char *argv[])
char
*
eeprom_type
=
NULL
;
char
eeprom_type_rb
[
16
];
int
err
=
0
;
int
dump
=
0
;
char
opt
;
name
=
strndup
(
basename
(
argv
[
0
]),
64
);
...
...
@@ -48,7 +73,7 @@ int main(int argc, char *argv[])
err
=
-
1
;
goto
out_strdup
;
}
while
((
opt
=
getopt
(
argc
,
argv
,
"h?Vc:s:t:"
))
!=
-
1
)
{
while
((
opt
=
getopt
(
argc
,
argv
,
"h?Vc:s:t:
d
"
))
!=
-
1
)
{
switch
(
opt
)
{
case
'h'
:
case
'?'
:
...
...
@@ -71,6 +96,9 @@ int main(int argc, char *argv[])
case
't'
:
eeprom_type
=
optarg
;
break
;
case
'd'
:
dump
=
1
;
break
;
}
}
if
(
carr_n
==
FMC_ID_INVALID
||
slot_n
==
FMC_ID_INVALID
)
{
...
...
@@ -90,8 +118,12 @@ int main(int argc, char *argv[])
}
fmc_slot_eeprom_type_get
(
fmc
,
slot_n
,
eeprom_type_rb
,
sizeof
(
eeprom_type_rb
));
fprintf
(
stdout
,
"fmc-slot.%u.%u EEPROM type %s
\n
"
,
carr_n
,
slot_n
,
eeprom_type_rb
);
if
(
dump
==
0
)
fprintf
(
stdout
,
"fmc-slot.%u.%u EEPROM type %s
\n
"
,
carr_n
,
slot_n
,
eeprom_type_rb
);
else
print_dump
(
fmc
,
slot_n
,
eeprom_type_rb
);
fmc_carrier_close
(
fmc
);
out_open:
out_invalid:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment