11
2- #include " ser .h"
2+ #include " usb .h"
33#include " infinite_sense.h"
44#include " ptp.h"
55#include " sensor.h"
66namespace infinite_sense {
7- SerialManager::SerialManager (const std::string &port, const int baud_rate) {
7+ UsbManager::UsbManager (const std::string &port, const int baud_rate) {
88 port_ = port;
99 serial_ptr_ = std::make_unique<serial::Serial>();
1010 try {
@@ -25,10 +25,10 @@ SerialManager::SerialManager(const std::string &port, const int baud_rate) {
2525 LOG (ERROR) << " Serial port: " << serial_ptr_->getPort () << " initialized and opened." ;
2626 }
2727 ptp_ = std::make_unique<Ptp>();
28- ptp_->SetSerialPtr (serial_ptr_);
28+ ptp_->SetUsbPtr (serial_ptr_);
2929}
3030
31- SerialManager ::~SerialManager () {
31+ UsbManager ::~UsbManager () {
3232 if (serial_ptr_->isOpen ()) {
3333 serial_ptr_->close ();
3434 LOG (ERROR) << " Serial port: " << serial_ptr_->getPort () << " closed." ;
@@ -37,14 +37,14 @@ SerialManager::~SerialManager() {
3737 tx_thread_.join ();
3838}
3939
40- void SerialManager ::Start () {
40+ void UsbManager ::Start () {
4141 started_ = true ;
4242 rx_thread_ = std::thread ([this ] { Receive (); });
4343 tx_thread_ = std::thread ([this ] { TimeStampSynchronization (); });
4444 LOG (INFO) << " Serial manager started" ;
4545}
4646
47- void SerialManager ::Stop () {
47+ void UsbManager ::Stop () {
4848 started_ = false ;
4949 if (serial_ptr_->isOpen ()) {
5050 serial_ptr_->close ();
@@ -54,7 +54,7 @@ void SerialManager::Stop() {
5454 tx_thread_.join ();
5555 LOG (INFO) << " Serial manager stopped" ;
5656}
57- void SerialManager ::Receive () const {
57+ void UsbManager ::Receive () const {
5858 while (started_) {
5959 if (serial_ptr_->available ()) {
6060 std::string serial_recv = serial_ptr_->readline ();
@@ -81,7 +81,7 @@ void SerialManager::Receive() const {
8181 std::this_thread::sleep_for (std::chrono::microseconds{10 });
8282 }
8383}
84- void SerialManager ::TimeStampSynchronization () const {
84+ void UsbManager ::TimeStampSynchronization () const {
8585 while (started_) {
8686 ptp_->SendPtpData ();
8787 }
0 commit comments