Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
asterx1_gps
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
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
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
labrobotica
drivers
asterx1_gps
Commits
00500527
Commit
00500527
authored
11 years ago
by
Andreu Corominas-Murtra
Browse files
Options
Downloads
Patches
Plain Diff
Minor changes and code cleaning
parent
45110a41
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/asterx1_gps.cpp
+7
-10
7 additions, 10 deletions
src/asterx1_gps.cpp
src/asterx1_gps.h
+47
-37
47 additions, 37 deletions
src/asterx1_gps.h
with
54 additions
and
47 deletions
src/asterx1_gps.cpp
+
7
−
10
View file @
00500527
#include
"asterx1_gps.h"
CasteRx1
::
CasteRx1
(
const
string
&
hwPortName
,
const
int
acqRate
Index
)
CasteRx1
::
CasteRx1
(
const
string
&
hwPortName
,
const
int
acqRate
)
{
status
=
0
;
config
.
portName
=
hwPortName
;
config
.
acqPeriod
=
acqPeriodValues
[
acqRate
Index
];
config
.
acqPeriod
=
acqPeriodValues
[
acqRate
];
}
CasteRx1
::~
CasteRx1
()
...
...
@@ -12,14 +12,14 @@ CasteRx1::~CasteRx1()
blockList
.
clear
();
if
(
(
status
&
ACQUISITION_RUNNING
)
)
stopAcquisition
();
if
(
(
status
&
DEVICE_OPEN
)
)
closeDevice
();
delete
serialPort
;
cout
<<
"CasteRx1::~CasteRx1(). End of CasteRx1 destructor"
<<
endl
;
//bye bye message
}
int
CasteRx1
::
openDevice
(
int
xx
)
int
CasteRx1
::
openDevice
()
{
cout
<<
xx
<<
endl
;
TRS232_config
serialConfig
;
int
retValue
=
BASIC_SUCCESS
;
TRS232_config
serialConfig
;
try
{
serialPort
=
new
CRS232
(
config
.
portName
);
//creates a new object to manage serial connection
...
...
@@ -84,13 +84,11 @@ int CasteRx1::closeDevice()
retValue
=
PORT_CLOSE_ERROR
;
//status |= DEVICE_OPEN; //close() has failed , so it is still opened
}
}
if
(
retValue
==
BASIC_SUCCESS
)
//if close() is successful, we delete the object
{
status
&=
~
DEVICE_OPEN
;
cout
<<
"CasteRx1::closeDevice(). SUCCESS. Serial port "
<<
config
.
portName
<<
" closed successfully."
<<
endl
;
delete
serialPort
;
}
return
retValue
;
...
...
@@ -102,7 +100,7 @@ int CasteRx1::startAcquisition()
sbfBlockManager
*
blockMng
;
string
cmnd
;
//enables commands a
s input at USB1
//enables commands a
t USB1 device input
retValue
+=
sendCommand
(
"setDataInOut,USB1,CMD,none
\n
"
);
//stops data transmission if it was running
...
...
@@ -138,7 +136,6 @@ int CasteRx1::startAcquisition()
cmnd
.
append
(
config
.
acqPeriod
);
cmnd
.
append
(
"
\n
"
);
retValue
+=
sendCommand
(
cmnd
);
//retValue += sendCommand("setSBFOutput,Stream1,USB1,Group1,msec500\n");
if
(
retValue
==
BASIC_SUCCESS
*
11
)
//success on all commands
{
...
...
@@ -221,7 +218,7 @@ int CasteRx1::readDataFromDevice()
retValue
+=
readNbytes
(
&
buffer
[
0
],
2
,
DATA_TIMEOUT
);
//reads transmitted crc value
crcValue
=
getUI2
(
&
buffer
[
0
]);
//decodes crc value
retValue
+=
readNbytes
(
&
buffer
[
0
],
2
,
DATA_TIMEOUT
);
//reads block id field
blockId
=
(
buffer
[
0
]
&
0xff
)
|
((
buffer
[
1
]
&
0x1f
)
<<
8
);
//decodes blockId (us
i
es only the 13 LS bits)
blockId
=
(
buffer
[
0
]
&
0xff
)
|
((
buffer
[
1
]
&
0x1f
)
<<
8
);
//decodes blockId (uses only the 13 LS bits)
retValue
+=
readNbytes
(
&
buffer
[
2
],
2
,
DATA_TIMEOUT
);
//reads block length
blockLength
=
getUI2
(
&
buffer
[
2
]);
//decodes block length (in bytes)
...
...
This diff is collapsed.
Click to expand it.
src/asterx1_gps.h
+
47
−
37
View file @
00500527
...
...
@@ -131,59 +131,69 @@ const bool inDEGREES = 1;
class
CasteRx1
{
public:
/**
Constructor: just catch the name of the serial port
/** \brief Default constructor
*
* Constructor. Requires port file name and, optionally, acquisition rate.
*
*/
CasteRx1
(
const
string
&
hwPortName
=
"/dev/ttyACM0"
,
const
int
acqRate
Index
=
MSEC500
);
CasteRx1
(
const
string
&
hwPortName
=
"/dev/ttyACM0"
,
const
int
acqRate
=
MSEC500
);
/**
Destructor: Stops acquisition in case it was running and closes serial Port in case it was opened.
/** \brief Destructor
*
* Destructor: Stops acquisition in case it was running and closes serial Port in case it was opened.
*
*/
virtual
~
CasteRx1
();
/**
Opens serial communications and starts serial comm thread.
If success , sets status bit DEVICE_OPEN.
Return values are:
BASIC_SUCCESS
PORT_OPEN_ERROR if thread can't be created or port can't be opened
PORT_CONFIG_ERROR if port can't be configured
/** \brief Open and configure serial device.
*
* Open and configure serial device to 8N1 Byte transmission.
* Launches a thread for serial in/out comms
* Return values are:
* BASIC_SUCCESS
* PORT_OPEN_ERROR if thread can't be created or port can't be opened
* PORT_CONFIG_ERROR if port can't be configured
*/
int
openDevice
(
int
xx
=
3
);
int
openDevice
();
/**
Closes serial comm's , stops comm thread and deletes comm object.
If success , resets status bit DEVICE_OPEN.
Return values are:
BASIC_SUCCESS
PORT_CLOSE_ERROR
/** \brief Closes serial comm
*
* Closes serial comm's , stops comm thread and deletes comm object.
* If success , resets status bit DEVICE_OPEN.
* Return values are:
* BASIC_SUCCESS
* PORT_CLOSE_ERROR
*/
int
closeDevice
();
/**
Configures the device to perform some signal processing basics for mobile robotics.
Starts a mode of operation of continuos data flow from the device at a rate of 2Hz.
Return values are:
BASIC_SUCCESS
ASTERX1_CONFIG_ERROR
/** \brief Starts basic data acquisition
*
* Configures the device to perform some signal processing basics for mobile robotics.
* Starts a mode of operation of continuos data flow from the device at a rate of 2Hz.
* Return values are:
* BASIC_SUCCESS
* ASTERX1_CONFIG_ERROR
*/
int
startAcquisition
();
/**
Stops mode of operation of continuous data flow
Return values are:
BASIC_SUCCESS when device stop is ok
ASTERX1_STOPPINTG_ERROR otherwise.
/** \brief Stops acquisition
*
* Stops continuous acquisition mode
* Return values are:
* BASIC_SUCCESS when device stop is ok
* ASTERX1_STOPPINTG_ERROR otherwise.
*/
int
stopAcquisition
();
/**
Reads current data produced by the device. Ends when all data blocks requested have been received.
Sets status and all data fields.
Return values are:
BASIC_SUCCESS if all blocks are successfully decodes.
ACQUISITION_ERROR otherwise.
Afterwards, call getStatus() to check for gps availability.
/** \brief Decodes the device SBF stream
*
* Reads current data produced by the device. Ends when all data blocks requested have been received.
* Sets status and all data fields.
* Return values are:
* BASIC_SUCCESS if all blocks are successfully decodes.
* ACQUISITION_ERROR otherwise.
*
* After calling this function, call getStatus() to check for gps availability.
*/
int
readDataFromDevice
();
...
...
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