Commit 9dbb1617 authored by Pierre NARVOR's avatar Pierre NARVOR
Browse files

[driver] Renamed SerialHandler in SeatracSerial

parent 3925d5dd
......@@ -6,12 +6,12 @@ message(STATUS "Boost version : ${Boost_VERSION}")
message(STATUS "Boost location : ${Boost_INCLUDE_DIRS}")
list(APPEND seatrac_driver_headers
include/seatrac_driver/SerialHandler.h
include/seatrac_driver/SeatracSerial.h
include/seatrac_driver/SeatracDriver.h
)
add_library(seatrac_driver SHARED
src/SerialHandler.cpp
src/SeatracSerial.cpp
src/SeatracDriver.cpp
)
set_target_properties(seatrac_driver PROPERTIES
......
#ifndef _DEF_SEATRAC_DRIVER_SEATRAC_DRIVER_H_
#define _DEF_SEATRAC_DRIVER_SEATRAC_DRIVER_H_
#include <seatrac_driver/SerialHandler.h>
#include <seatrac_driver/SeatracSerial.h>
namespace narval { namespace seatrac {
class SeatracDriver : SerialHandler
class SeatracDriver : SeatracSerial
{
public:
......
#ifndef _DEF_SEATRAC_DRIVER_SERIAL_HANDLE_H_
#define _DEF_SEATRAC_DRIVER_SERIAL_HANDLE_H_
#ifndef _DEF_SEATRAC_DRIVER_SEATRAC_SERIAL_H_
#define _DEF_SEATRAC_DRIVER_SEATRAC_SERIAL_H_
#include <iostream>
#include <sstream>
......@@ -12,7 +12,7 @@
namespace narval { namespace seatrac {
class SerialHandler
class SeatracSerial
{
public:
......@@ -46,11 +46,11 @@ class SerialHandler
public:
SerialHandler(const IoServicePtr& ioService,
SeatracSerial(const IoServicePtr& ioService,
const std::string& port = "/dev/narval_usbl");
};
}; //namespace seatrac
}; //namespace narval
#endif //_DEF_SEATRAC_DRIVER_SERIAL_HANDLE_H_
#endif //_DEF_SEATRAC_DRIVER_SEATRAC_SERIAL_H_
......@@ -17,7 +17,7 @@ void SeatracDriver::crc16_update(uint16_t& checksum, uint8_t v)
SeatracDriver::SeatracDriver(const IoServicePtr& ioService,
const std::string& port) :
SerialHandler(ioService, port)
SeatracSerial(ioService, port)
{}
void SeatracDriver::on_read(ReadBuffer& buffer, size_t byteCount)
......
#include <seatrac_driver/SerialHandler.h>
#include <seatrac_driver/SeatracSerial.h>
namespace narval { namespace seatrac {
SerialHandler::SerialHandler(const IoServicePtr& ioService,
SeatracSerial::SeatracSerial(const IoServicePtr& ioService,
const std::string& port) :
ioService_(ioService),
serial_(*ioService, port)
......@@ -10,7 +10,7 @@ SerialHandler::SerialHandler(const IoServicePtr& ioService,
this->initiate_read();
}
void SerialHandler::reset_serial()
void SeatracSerial::reset_serial()
{
SerialPort::baud_rate baudRate(115200);
SerialPort::character_size cSize(8);
......@@ -27,7 +27,7 @@ void SerialHandler::reset_serial()
this->flush();
}
boost::system::error_code SerialHandler::flush(FlushType flushType)
boost::system::error_code SeatracSerial::flush(FlushType flushType)
{
if(::tcflush(serial_.lowest_layer().native_handle(), flushType) == 0) {
return boost::system::error_code();
......@@ -38,18 +38,18 @@ boost::system::error_code SerialHandler::flush(FlushType flushType)
}
}
void SerialHandler::initiate_read()
void SeatracSerial::initiate_read()
{
this->reset_serial();
boost::asio::async_read_until(serial_, readBuffer_, Delimiter,
boost::bind(&SerialHandler::on_first_read, this, _1, _2));
boost::bind(&SeatracSerial::on_first_read, this, _1, _2));
}
/**
* Grab and discard a first (probably incomplete) chunk of data.
*/
void SerialHandler::on_first_read(const boost::system::error_code& err, size_t byteCount)
void SeatracSerial::on_first_read(const boost::system::error_code& err, size_t byteCount)
{
if(err) {
std::ostringstream oss;
......@@ -60,10 +60,10 @@ void SerialHandler::on_first_read(const boost::system::error_code& err, size_t b
// entering reading loop
boost::asio::async_read_until(serial_, readBuffer_, Delimiter,
boost::bind(&SerialHandler::read_callback, this, _1, _2));
boost::bind(&SeatracSerial::read_callback, this, _1, _2));
}
void SerialHandler::read_callback(const boost::system::error_code& err, size_t byteCount)
void SeatracSerial::read_callback(const boost::system::error_code& err, size_t byteCount)
{
if(err) {
std::ostringstream oss;
......@@ -76,10 +76,10 @@ void SerialHandler::read_callback(const boost::system::error_code& err, size_t b
// looping
boost::asio::async_read_until(serial_, readBuffer_, Delimiter,
boost::bind(&SerialHandler::read_callback, this, _1, _2));
boost::bind(&SeatracSerial::read_callback, this, _1, _2));
}
void SerialHandler::on_read(ReadBuffer& buffer, size_t byteCount)
void SeatracSerial::on_read(ReadBuffer& buffer, size_t byteCount)
{
std::cout << "Read : " << byteCount << " bytes" << std::endl;
......
......@@ -3,8 +3,8 @@ list(APPEND test_names
hello_test.cpp
dump_test.cpp
serial_test.cpp
driver_test.cpp
checksum_test.cpp
# driver_test.cpp
)
list(APPEND test_deps
......
......@@ -6,7 +6,7 @@ using namespace narval::seatrac;
int main()
{
auto service = std::make_shared<SerialHandler::IoService>();
auto service = std::make_shared<SeatracSerial::IoService>();
SeatracDriver serial(service);
service->run();
......
#include <iostream>
using namespace std;
#include <seatrac_driver/SerialHandler.h>
#include <seatrac_driver/SeatracSerial.h>
using namespace narval::seatrac;
int main()
{
auto service = std::make_shared<SerialHandler::IoService>();
SerialHandler serial(service);
auto service = std::make_shared<SeatracSerial::IoService>();
SeatracSerial serial(service);
service->run();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment