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
02639411
Commit
02639411
authored
10 years ago
by
Andrew Tridgell
Committed by
Lorenz Meier
10 years ago
Browse files
Options
Downloads
Patches
Plain Diff
hmc5883: added -T option to enable temperature compensation
this also fixes the behaviour of the -C option
parent
e17936e2
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/drivers/hmc5883/hmc5883.cpp
+18
-21
18 additions, 21 deletions
src/drivers/hmc5883/hmc5883.cpp
with
18 additions
and
21 deletions
src/drivers/hmc5883/hmc5883.cpp
+
18
−
21
View file @
02639411
...
...
@@ -1413,7 +1413,7 @@ void test(enum HMC5883_BUS busid);
void
reset
(
enum
HMC5883_BUS
busid
);
int
info
(
enum
HMC5883_BUS
busid
);
int
calibrate
(
enum
HMC5883_BUS
busid
);
void
temp_enable
(
HMC5883_BUS
busid
,
bool
enable
);
int
temp_enable
(
HMC5883_BUS
busid
,
bool
enable
);
void
usage
();
/**
...
...
@@ -1478,8 +1478,6 @@ start(enum HMC5883_BUS busid, enum Rotation rotation)
if
(
!
started
)
errx
(
1
,
"driver start failed"
);
exit
(
0
);
}
/**
...
...
@@ -1624,12 +1622,7 @@ int calibrate(enum HMC5883_BUS busid)
close
(
fd
);
if
(
ret
==
OK
)
{
errx
(
0
,
"PASS"
);
}
else
{
errx
(
1
,
"FAIL"
);
}
return
ret
;
}
/**
...
...
@@ -1659,7 +1652,7 @@ reset(enum HMC5883_BUS busid)
/**
* enable/disable temperature compensation
*/
void
int
temp_enable
(
enum
HMC5883_BUS
busid
,
bool
enable
)
{
struct
hmc5883_bus_option
&
bus
=
find_bus
(
busid
);
...
...
@@ -1673,7 +1666,8 @@ temp_enable(enum HMC5883_BUS busid, bool enable)
if
(
ioctl
(
fd
,
MAGIOCSTEMPCOMP
,
(
unsigned
)
enable
)
<
0
)
err
(
1
,
"set temperature compensation failed"
);
exit
(
0
);
close
(
fd
);
return
0
;
}
/**
...
...
@@ -1711,8 +1705,9 @@ hmc5883_main(int argc, char *argv[])
enum
HMC5883_BUS
busid
=
HMC5883_BUS_ALL
;
enum
Rotation
rotation
=
ROTATION_NONE
;
bool
calibrate
=
false
;
bool
temp_compensation
=
false
;
while
((
ch
=
getopt
(
argc
,
argv
,
"XISR:C"
))
!=
EOF
)
{
while
((
ch
=
getopt
(
argc
,
argv
,
"XISR:C
T
"
))
!=
EOF
)
{
switch
(
ch
)
{
case
'R'
:
rotation
=
(
enum
Rotation
)
atoi
(
optarg
);
...
...
@@ -1731,6 +1726,9 @@ hmc5883_main(int argc, char *argv[])
case
'C'
:
calibrate
=
true
;
break
;
case
'T'
:
temp_compensation
=
true
;
break
;
default:
hmc5883
::
usage
();
exit
(
0
);
...
...
@@ -1744,16 +1742,15 @@ hmc5883_main(int argc, char *argv[])
*/
if
(
!
strcmp
(
verb
,
"start"
))
{
hmc5883
::
start
(
busid
,
rotation
);
if
(
calibrate
)
{
if
(
hmc5883
::
calibrate
(
busid
)
==
0
)
{
errx
(
0
,
"calibration successful"
);
}
else
{
errx
(
1
,
"calibration failed"
);
}
}
else
{
exit
(
0
);
if
(
calibrate
&&
hmc5883
::
calibrate
(
busid
)
!=
0
)
{
errx
(
1
,
"calibration failed"
);
}
if
(
temp_compensation
)
{
// we consider failing to setup temperature
// compensation as non-fatal
hmc5883
::
temp_enable
(
busid
,
true
);
}
exit
(
0
);
}
/*
...
...
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