Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
L
LabConnections.jl
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
Container registry
Model registry
Operate
Environments
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
labdev
LabConnections.jl
Commits
55a9544c
There was a problem fetching the pipeline summary.
Commit
55a9544c
authored
7 years ago
by
Martin Karlsson
Browse files
Options
Downloads
Patches
Plain Diff
Updated comedi.c with comments.
parent
16c5df73
No related branches found
No related tags found
No related merge requests found
Pipeline
#
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/Computer/comedi/comedi.c
+18
-1
18 additions, 1 deletion
src/Computer/comedi/comedi.c
with
18 additions
and
1 deletion
src/Computer/comedi/comedi.c
+
18
−
1
View file @
55a9544c
...
...
@@ -11,47 +11,64 @@ comedi_t *device;
comedi_range
*
range_info
;
lsampl_t
maxdata
;
// Send physical value from computer to process:
int
comedi_write
(
int
comediNbr
,
int
subdev
,
int
chan
,
double
physical_value
)
{
static
int
comedi_value
;
static
int
retval
;
// Convert physical value to comedi value:
range_info
=
comedi_get_range
(
device
,
subdev
,
chan
,
range
);
maxdata
=
comedi_get_maxdata
(
device
,
subdev
,
chan
);
comedi_value
=
comedi_from_phys
(
physical_value
,
range_info
,
maxdata
);
// Send the converted value to device:
retval
=
comedi_data_write
(
device
,
subdev
,
chan
,
range
,
aref
,
comedi_value
);
return
retval
;
}
// Get physical value from process to computer:
double
comedi_read
(
int
comediNbr
,
int
subdev
,
int
chan
)
{
static
double
physical_value
;
lsampl_t
comedi_value
;
// Get comedi value:
comedi_data_read
(
device
,
subdev
,
chan
,
range
,
aref
,
&
comedi_value
);
// Convert comedi value to physical value:
range_info
=
comedi_get_range
(
device
,
subdev
,
chan
,
range
);
maxdata
=
comedi_get_maxdata
(
device
,
subdev
,
chan
);
physical_value
=
comedi_to_phys
(
comedi_value
,
range_info
,
maxdata
);
// Return the converted value:
return
physical_value
;
}
// comedi_path example: "/dev/comedi0"
int
comedi_start
(
char
*
comedi_name
)
{
// Check for connection:
device
=
comedi_open
(
comedi_name
);
if
(
device
==
NULL
)
{
comedi_perror
(
"comedi_open_error"
);
return
-
1
;
}
// Set out-of-range behavior. This affects the behavior of comedi_to_phys
// when converting endpoint sample values, that is, sample values equal to
// 0 or maxdata. With COMEDI_OOR_NUMBER, the endpoint values
// are converted similarly to other values.
comedi_set_global_oor_behavior
(
COMEDI_OOR_NUMBER
);
return
0
;
}
// Send physical value zero from computer to process. This might, for instance,
// be useful prior to closing the connection with the process.
void
comedi_write_zero
(
int
comediNbr
,
int
subdev
,
int
chan
)
{
static
double
physical_value_zero
=
0
.
0
;
static
double
physical_value_zero
=
0
.
0
;
// Physical value zero to send.
static
lsampl_t
comedi_value
;
// Convert physical value zero to comedi value:
range_info
=
comedi_get_range
(
device
,
subdev
,
chan
,
range
);
maxdata
=
comedi_get_maxdata
(
device
,
subdev
,
chan
);
comedi_value
=
comedi_from_phys
(
physical_value_zero
,
range_info
,
maxdata
);
// Send converted value to process.
comedi_data_write
(
device
,
subdev
,
chan
,
range
,
aref
,
comedi_value
);
}
// Shut down communication between computer and process.
void
comedi_stop
(
int
comediNbr
)
{
comedi_close
(
device
);
}
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