Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
J
jr3_sensors
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
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
Show more breadcrumbs
Robotlab
jr3_sensors
Commits
fd6a5119
Unverified
Commit
fd6a5119
authored
3 years ago
by
Anton Tetov Johansson
Browse files
Options
Downloads
Patches
Plain Diff
upload of basic example
parent
1c767501
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
c_example/Makefile
+14
-0
14 additions, 0 deletions
c_example/Makefile
c_example/test_jr3_comedi.c
+85
-0
85 additions, 0 deletions
c_example/test_jr3_comedi.c
with
99 additions
and
0 deletions
c_example/Makefile
0 → 100755
+
14
−
0
View file @
fd6a5119
LIBS
=
-lcomedi
-lm
BINS
=
test_jr3_comedi.c
all
:
$(BINS)
clean
:
\r
m
-rf
*
.o
$(
BINS
)
%
:
%.c
$(
CC
)
-o
$@
$(
CFLAGS
)
$^
$(
LIBS
)
%.o
:
%.c
$(
CC
)
-c
-o
$@
$(
CFLAGS
)
$<
This diff is collapsed.
Click to expand it.
c_example/test_jr3_comedi.c
0 → 100755
+
85
−
0
View file @
fd6a5119
// ./test_JR3_comedi /dev/comedi1 0
// see /etc/comedi.conf for device, subdevices and channel
// Example
// configure /dev/comedi1 jr3_pci
// ain 100 /dev/comedi1 0:0
// (port 0:1-6 filter 0 fx..mz(order OK?))
// port 0:7-12 filter 1 fx..mz(??)
// Available: port 0 & 1, but not yet 3 & 4 of receiver card
//
#define CF_JR3 "/dev/comedi1"
#define JR3_PORT 0
#define NBR_CHAN 6
#define _POSIX_C_SOURCE 199309
#include
<time.h>
#include
<comedilib.h>
#include
<stdlib.h>
#include
<stdio.h>
typedef
struct
{
float
a
[
NBR_CHAN
];
}
jr3_data_t
;
typedef
struct
{
double
min
;
double
max
;
double
delta
;
double
maxdata
;
}
info_t
;
int
main
(
int
argc
,
char
*
argv
[])
{
comedi_t
*
cf_jr3
;
int
subdev
;
if
(
argc
>
1
){
cf_jr3
=
comedi_open
(
argv
[
1
]);
subdev
=
atoi
(
argv
[
2
]);
}
else
{
cf_jr3
=
comedi_open
(
CF_JR3
);
subdev
=
JR3_PORT
;
}
if
(
cf_jr3
)
{
int
n
,
chan
;
comedi_range
*
range
;
lsampl_t
maxdata
;
info_t
info
[
NBR_CHAN
];
jr3_data_t
jr3data
;
// [fx,fy,fz,mx,my,mx] ????
for
(
chan
=
0
;
chan
<
NBR_CHAN
;
chan
++
)
{
range
=
comedi_get_range
(
cf_jr3
,
subdev
,
chan
,
0
);
maxdata
=
comedi_get_maxdata
(
cf_jr3
,
subdev
,
chan
);
info
[
chan
].
min
=
range
->
min
;
info
[
chan
].
max
=
range
->
max
;
info
[
chan
].
maxdata
=
maxdata
;
info
[
chan
].
delta
=
(
range
->
max
-
range
->
min
)
/
maxdata
;
printf
(
"channel maxdata min max delta %d %d %f %f %f
\n
"
,
chan
,
maxdata
,
range
->
min
,
range
->
max
,
info
[
chan
].
delta
);
}
while
(
1
)
{
struct
timespec
delay
;
lsampl_t
data
;
delay
.
tv_sec
=
0
;
delay
.
tv_nsec
=
500000000
;
for
(
chan
=
0
;
chan
<
NBR_CHAN
;
chan
++
)
{
int
err
=
comedi_data_read
(
cf_jr3
,
subdev
,
chan
,
0
,
0
,
&
data
);
if
(
err
<
0
)
{
printf
(
"comedi_data_read error: err=%d subdev=%d %d %d
\n
"
,
err
,
subdev
,
chan
,
data
);
}
else
{
jr3data
.
a
[
chan
]
=
info
[
chan
].
min
+
(
double
)
data
*
info
[
chan
].
delta
;
}
}
for
(
chan
=
0
;
chan
<
NBR_CHAN
;
chan
++
)
{
printf
(
" %f "
,
1000
.
0
*
jr3data
.
a
[
chan
]);
}
printf
(
"
\n
"
);
nanosleep
(
&
delay
,
0
);
}
}
else
{
printf
(
"Failed to open device!
\n
"
);
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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