Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
F
FMC TDC 1ns 5cha - Software
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
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
FMC TDC 1ns 5cha - Software
Commits
c22f03e3
Commit
c22f03e3
authored
Oct 03, 2012
by
Miguel Gómez Sexto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
library fixes
Signed-off-by:
Miguel Gomez
<
magomez@igalia.com
>
parent
72bcf3bb
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
23 deletions
+18
-23
libtdc.c
lib/libtdc.c
+18
-23
No files found.
lib/libtdc.c
View file @
c22f03e3
...
...
@@ -301,12 +301,9 @@ static int __tdc_chan_to_decimal(int chan)
static
int
__tdc_valid_channel
(
struct
tdc_board
*
b
,
int
chan
)
{
int
chan_dec
;
chan_dec
=
__tdc_chan_to_decimal
(
chan
);
if
(
chan_dec
<
0
||
chan_dec
>
4
)
{
if
(
chan
<
0
||
chan
>
4
)
{
fprintf
(
stderr
,
"%s: Invalid channel: %i
\n
"
,
__func__
,
chan
_dec
);
__func__
,
chan
);
errno
=
EINVAL
;
return
0
;
}
...
...
@@ -318,9 +315,9 @@ static int __tdc_valid_channel(struct tdc_board *b, int chan)
return
0
;
}
if
(
!
(
b
->
chan_config
&
chan
))
{
if
(
!
(
b
->
chan_config
&
(
1
<<
chan
)
))
{
fprintf
(
stderr
,
"%s: Channel not enabled: %i
\n
"
,
__func__
,
chan
_dec
);
__func__
,
chan
);
errno
=
EINVAL
;
return
0
;
}
...
...
@@ -331,17 +328,14 @@ static int __tdc_valid_channel(struct tdc_board *b, int chan)
static
int
__tdc_open_file
(
struct
tdc_board
*
b
,
int
chan
)
{
char
fname
[
128
];
int
chan_dec
;
chan_dec
=
__tdc_chan_to_decimal
(
chan
);
sprintf
(
fname
,
"%s-%i-0-ctrl"
,
b
->
devbase
,
chan_dec
);
sprintf
(
fname
,
"%s-%i-0-ctrl"
,
b
->
devbase
,
chan
);
/* open file */
if
(
b
->
ctrl
[
chan
_dec
]
<=
0
)
{
b
->
ctrl
[
chan
_dec
]
=
open
(
fname
,
O_RDONLY
|
O_NONBLOCK
);
if
(
b
->
ctrl
[
chan
]
<=
0
)
{
b
->
ctrl
[
chan
]
=
open
(
fname
,
O_RDONLY
|
O_NONBLOCK
);
}
if
(
b
->
ctrl
[
chan
_dec
]
<
0
)
if
(
b
->
ctrl
[
chan
]
<
0
)
fprintf
(
stderr
,
"%s: Error opening file: %s
\n
"
,
__func__
,
fname
);
...
...
@@ -351,20 +345,17 @@ static int __tdc_open_file(struct tdc_board *b, int chan)
static
int
__tdc_close_file
(
struct
tdc_board
*
b
,
int
chan
)
{
int
ret
;
int
chan_dec
;
chan_dec
=
__tdc_chan_to_decimal
(
chan
);
ret
=
close
(
b
->
ctrl
[
chan_dec
]);
ret
=
close
(
b
->
ctrl
[
chan
]);
if
(
ret
)
{
char
fname
[
128
];
sprintf
(
fname
,
"%s-%i-0-ctrl"
,
b
->
devbase
,
chan
_dec
);
sprintf
(
fname
,
"%s-%i-0-ctrl"
,
b
->
devbase
,
chan
);
fprintf
(
stderr
,
"%s: Error closing file: %s
\n
"
,
__func__
,
fname
);
return
-
1
;
}
b
->
ctrl
[
chan
_dec
]
=
-
1
;
b
->
ctrl
[
chan
]
=
-
1
;
return
0
;
}
...
...
@@ -375,11 +366,14 @@ int tdc_read(struct tdc_board *b, int chan, struct tdc_time *t,
int
fd
,
i
,
j
;
fd_set
set
;
int
ret
=
0
;
int
chan_dec
;
if
(
!
__tdc_valid_channel
(
b
,
chan
))
chan_dec
=
__tdc_chan_to_decimal
(
chan
);
if
(
!
__tdc_valid_channel
(
b
,
chan_dec
))
return
-
1
;
fd
=
__tdc_open_file
(
b
,
chan
);
fd
=
__tdc_open_file
(
b
,
chan
_dec
);
if
(
fd
<
0
)
return
-
1
;
...
...
@@ -394,6 +388,7 @@ int tdc_read(struct tdc_board *b, int chan, struct tdc_time *t,
t
[
i
].
da_capo
=
ctrl
.
flags
;
i
++
;
ret
=
i
;
continue
;
}
...
...
@@ -427,6 +422,6 @@ int tdc_read(struct tdc_board *b, int chan, struct tdc_time *t,
}
}
__tdc_close_file
(
b
,
chan
);
__tdc_close_file
(
b
,
chan
_dec
);
return
ret
;
}
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