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
27995254
Commit
27995254
authored
8 years ago
by
Miguel Arroyo
Committed by
Lorenz Meier
8 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Commandline Interface and Mode options
parent
9bd3f6c9
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/drivers/drv_gps.h
+4
-0
4 additions, 0 deletions
src/drivers/drv_gps.h
src/drivers/gps/devices
+1
-1
1 addition, 1 deletion
src/drivers/gps/devices
src/drivers/gps/gps.cpp
+70
-37
70 additions, 37 deletions
src/drivers/gps/gps.cpp
with
75 additions
and
38 deletions
src/drivers/drv_gps.h
+
4
−
0
View file @
27995254
...
...
@@ -58,3 +58,7 @@ typedef enum {
GPS_DRIVER_MODE_ASHTECH
}
gps_driver_mode_t
;
typedef
enum
{
GPS_DRIVER_UART
=
0
,
GPS_DRIVER_SPI
}
gps_driver_interface_t
;
This diff is collapsed.
Click to expand it.
devices
@
3fa8711f
Compare
3cac6a5b
...
3fa8711f
Subproject commit 3
cac6a5bc5826d7ac495827a46b6
3f4
7
6d
82ba86
Subproject commit 3
fa8711feb16b1
3f4
b
6d
47bb97cdd0cf34362019
This diff is collapsed.
Click to expand it.
src/drivers/gps/gps.cpp
+
70
−
37
View file @
27995254
...
...
@@ -103,7 +103,8 @@ public:
class
GPS
{
public:
GPS
(
const
char
*
uart_path
,
bool
fake_gps
,
bool
enable_sat_info
,
int
gps_num
);
GPS
(
const
char
*
path
,
gps_driver_mode_t
mode
,
gps_driver_interface_t
interface
,
bool
fake_gps
,
bool
enable_sat_info
,
int
gps_num
);
virtual
~
GPS
();
virtual
int
init
();
...
...
@@ -124,6 +125,7 @@ private:
bool
_baudrate_changed
;
///< flag to signal that the baudrate with the GPS has changed
bool
_mode_changed
;
///< flag that the GPS mode has changed
gps_driver_mode_t
_mode
;
///< current mode
gps_driver_interface_t
_interface
;
GPSHelper
*
_helper
;
///< instance of GPS parser
GPS_Sat_Info
*
_sat_info
;
///< instance of GPS sat info data object
struct
vehicle_gps_position_s
_report_gps_pos
;
///< uORB topic for gps position
...
...
@@ -241,11 +243,13 @@ volatile bool is_gps1_advertised = false; ///< for the second gps we want to mak
}
GPS
::
GPS
(
const
char
*
uart_path
,
bool
fake_gps
,
bool
enable_sat_info
,
int
gps_num
)
:
GPS
::
GPS
(
const
char
*
path
,
gps_driver_mode_t
mode
,
gps_driver_interface_t
interface
,
bool
fake_gps
,
bool
enable_sat_info
,
int
gps_num
)
:
_task_should_exit
(
false
),
_healthy
(
false
),
_mode_changed
(
false
),
_mode
(
GPS_DRIVER_MODE_UBX
),
_mode
(
mode
),
_interface
(
interface
),
_helper
(
nullptr
),
_sat_info
(
nullptr
),
_report_gps_pos_pub
{
nullptr
},
...
...
@@ -263,7 +267,7 @@ GPS::GPS(const char *uart_path, bool fake_gps, bool enable_sat_info, int gps_num
_dump_from_device
(
nullptr
)
{
/* store port name */
strncpy
(
_port
,
uart_
path
,
sizeof
(
_port
));
strncpy
(
_port
,
path
,
sizeof
(
_port
));
/* enforce null termination */
_port
[
sizeof
(
_port
)
-
1
]
=
'\0'
;
...
...
@@ -699,13 +703,24 @@ GPS::task_main()
_helper
=
nullptr
;
}
GPSHelper
::
Interface
helper_interface
=
GPSHelper
::
Interface
::
UART
;
switch
(
_interface
)
{
case
GPS_DRIVER_UART
:
helper_interface
=
GPSHelper
::
Interface
::
UART
;
break
;
case
GPS_DRIVER_SPI
:
helper_interface
=
GPSHelper
::
Interface
::
SPI
;
break
;
default:
break
;
}
switch
(
_mode
)
{
case
GPS_DRIVER_MODE_UBX
:
#ifndef __PX4_POSIX_RPI
_helper
=
new
GPSDriverUBX
(
GPSHelper
::
Interface
::
UART
,
&
GPS
::
callback
,
this
,
&
_report_gps_pos
,
_p_report_sat_info
);
#else
_helper
=
new
GPSDriverUBX
(
GPSHelper
::
Interface
::
SPI
,
&
GPS
::
callback
,
this
,
&
_report_gps_pos
,
_p_report_sat_info
);
#endif
_helper
=
new
GPSDriverUBX
(
helper_interface
,
&
GPS
::
callback
,
this
,
&
_report_gps_pos
,
_p_report_sat_info
);
break
;
case
GPS_DRIVER_MODE_MTK
:
...
...
@@ -810,30 +825,7 @@ GPS::task_main()
_rate_rtcm_injection
=
0.0
f
;
}
}
#if !defined(__PX4_POSIX_RPI)
/* select next mode */
switch
(
_mode
)
{
case
GPS_DRIVER_MODE_UBX
:
_mode
=
GPS_DRIVER_MODE_MTK
;
break
;
case
GPS_DRIVER_MODE_MTK
:
_mode
=
GPS_DRIVER_MODE_ASHTECH
;
break
;
case
GPS_DRIVER_MODE_ASHTECH
:
_mode
=
GPS_DRIVER_MODE_UBX
;
break
;
default:
break
;
}
#endif
}
}
PX4_INFO
(
"exiting"
);
...
...
@@ -955,7 +947,8 @@ namespace gps
{
void
start
(
const
char
*
uart_path
,
bool
fake_gps
,
bool
enable_sat_info
,
int
gps_num
);
void
start
(
const
char
*
path
,
gps_driver_mode_t
mode
,
gps_driver_interface_t
interface
,
bool
fake_gps
,
bool
enable_sat_info
,
int
gps_num
);
void
stop
();
void
test
();
void
reset
();
...
...
@@ -965,7 +958,8 @@ void info();
* Start the driver.
*/
void
start
(
const
char
*
uart_path
,
bool
fake_gps
,
bool
enable_sat_info
,
int
gps_num
)
start
(
const
char
*
path
,
gps_driver_mode_t
mode
,
gps_driver_interface_t
interface
,
bool
fake_gps
,
bool
enable_sat_info
,
int
gps_num
)
{
if
(
g_dev
[
gps_num
-
1
]
!=
nullptr
)
{
PX4_WARN
(
"GPS %i already started"
,
gps_num
);
...
...
@@ -973,7 +967,7 @@ start(const char *uart_path, bool fake_gps, bool enable_sat_info, int gps_num)
}
/* create the driver */
g_dev
[
gps_num
-
1
]
=
new
GPS
(
uart_path
,
fake_gps
,
enable_sat_info
,
gps_num
);
g_dev
[
gps_num
-
1
]
=
new
GPS
(
path
,
mode
,
interface
,
fake_gps
,
enable_sat_info
,
gps_num
);
if
(
!
g_dev
[
gps_num
-
1
]
||
OK
!=
g_dev
[
gps_num
-
1
]
->
init
())
{
if
(
g_dev
[
gps_num
-
1
]
!=
nullptr
)
{
...
...
@@ -1054,6 +1048,8 @@ gps_main(int argc, char *argv[])
const
char
*
device_name2
=
nullptr
;
bool
fake_gps
=
false
;
bool
enable_sat_info
=
false
;
gps_driver_interface_t
interface
=
GPS_DRIVER_UART
;
gps_driver_mode_t
mode
=
GPS_DRIVER_MODE_UBX
;
if
(
argc
<
2
)
{
goto
out
;
...
...
@@ -1088,6 +1084,43 @@ gps_main(int argc, char *argv[])
}
}
/* Detect interface option */
for
(
int
i
=
2
;
i
<
argc
;
i
++
)
{
if
(
!
strcmp
(
argv
[
i
],
"-i"
))
{
int
interface_arg
=
i
+
1
;
if
(
interface_arg
<
argc
)
{
if
(
!
strcmp
(
argv
[
interface_arg
],
"spi"
))
{
interface
=
GPS_DRIVER_SPI
;
}
else
if
(
!
strcmp
(
argv
[
interface_arg
],
"uart"
))
{
interface
=
GPS_DRIVER_UART
;
}
}
}
}
/* Detect mode/protocol option */
for
(
int
i
=
2
;
i
<
argc
;
i
++
)
{
if
(
!
strcmp
(
argv
[
i
],
"-p"
))
{
int
mode_arg
=
i
+
1
;
if
(
mode_arg
<
argc
)
{
if
(
!
strcmp
(
argv
[
mode_arg
],
"ubx"
))
{
mode
=
GPS_DRIVER_MODE_UBX
;
}
else
if
(
!
strcmp
(
argv
[
mode_arg
],
"mtk"
))
{
mode
=
GPS_DRIVER_MODE_MTK
;
}
else
if
(
!
strcmp
(
argv
[
mode_arg
],
"ash"
))
{
mode
=
GPS_DRIVER_MODE_ASHTECH
;
}
}
}
}
/* Allow to use a second gps device */
for
(
int
i
=
2
;
i
<
argc
;
i
++
)
{
if
(
!
strcmp
(
argv
[
i
],
"-dualgps"
))
{
...
...
@@ -1100,10 +1133,10 @@ gps_main(int argc, char *argv[])
}
}
gps
::
start
(
device_name
,
fake_gps
,
enable_sat_info
,
1
);
gps
::
start
(
device_name
,
mode
,
interface
,
fake_gps
,
enable_sat_info
,
1
);
if
(
device_name2
)
{
gps
::
start
(
device_name2
,
fake_gps
,
enable_sat_info
,
2
);
gps
::
start
(
device_name2
,
mode
,
interface
,
fake_gps
,
enable_sat_info
,
2
);
}
}
...
...
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