Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
Firmware
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
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Alberto Ruiz Garcia
Firmware
Commits
a153148e
Commit
a153148e
authored
6 years ago
by
David Sidrane
Committed by
Daniel Agar
6 years ago
Browse files
Options
Downloads
Patches
Plain Diff
camera_capture:Use IOCTL to set capture mode.
parent
928e0140
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
src/drivers/camera_capture/camera_capture.cpp
+38
-7
38 additions, 7 deletions
src/drivers/camera_capture/camera_capture.cpp
src/drivers/camera_capture/camera_capture.hpp
+2
-0
2 additions, 0 deletions
src/drivers/camera_capture/camera_capture.hpp
with
40 additions
and
7 deletions
src/drivers/camera_capture/camera_capture.cpp
+
38
−
7
View file @
a153148e
...
...
@@ -232,24 +232,55 @@ CameraCapture::cycle()
void
CameraCapture
::
set_capture_control
(
bool
enabled
)
{
int
fd
=
-
1
;
fd
=
::
open
(
PX4FMU_DEVICE_PATH
,
O_RDWR
);
if
(
fd
<
0
)
{
PX4_ERR
(
"open fail"
);
return
;
}
input_capture_config_t
conf
;
conf
.
channel
=
5
;
// FMU chan 6
conf
.
filter
=
0
;
conf
.
edge
=
_camera_capture_edge
?
Rising
:
Falling
;
conf
.
callback
=
NULL
;
conf
.
context
=
NULL
;
if
(
enabled
)
{
// register callbacks
if
(
!
_camera_capture_edge
)
{
up_input_capture_set
(
5
,
Falling
,
0
,
&
CameraCapture
::
capture_trampoline
,
this
);
}
else
{
up_input_capture_set
(
5
,
Rising
,
0
,
&
CameraCapture
::
capture_trampoline
,
this
);
conf
.
callback
=
&
CameraCapture
::
capture_trampoline
;
conf
.
context
=
this
;
unsigned
int
capture_count
=
0
;
if
(
::
ioctl
(
fd
,
INPUT_CAP_GET_COUNT
,
(
unsigned
long
)
&
capture_count
)
!=
0
)
{
PX4_INFO
(
"Not in a capture mode"
);
unsigned
long
mode
=
PWM_SERVO_MODE_5PWM1CAP
;
if
(
::
ioctl
(
fd
,
PWM_SERVO_SET_MODE
,
mode
)
==
0
)
{
PX4_INFO
(
"Mode changed to 5PWM1CAP"
);
}
else
{
PX4_ERR
(
"Mode NOT changed to 4PWM2CAP"
);
goto
err_out
;
}
}
}
_capture_enabled
=
true
;
if
(
::
ioctl
(
fd
,
INPUT_CAP_SET_CALLBACK
,
(
unsigned
long
)
&
conf
)
==
0
)
{
_capture_enabled
=
enabled
;
}
else
{
up_input_capture_set
(
5
,
Disabled
,
0
,
NULL
,
NULL
);
PX4_ERR
(
"Unable to set capture callback for chan %u
\n
"
,
conf
.
channel
);
_capture_enabled
=
false
;
goto
err_out
;
}
reset_statistics
(
false
);
err_out
:
::
close
(
fd
);
return
;
}
void
...
...
This diff is collapsed.
Click to expand it.
src/drivers/camera_capture/camera_capture.hpp
+
2
−
0
View file @
a153148e
...
...
@@ -55,6 +55,8 @@
#include
<px4_workqueue.h>
#include
<drivers/drv_hrt.h>
#include
<drivers/drv_gpio.h>
#include
<drivers/drv_pwm_output.h>
#include
<drivers/drv_input_capture.h>
#include
<drivers/device/ringbuffer.h>
...
...
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