mirror of
https://github.com/westonrobot/ugv_sdk
synced 2023-04-08 06:32:14 +08:00
reverted back changes to function signature of serial rx callback func
This commit is contained in:
@@ -54,6 +54,8 @@ short CursorColor(int fg)
|
|||||||
return (COLOR_YELLOW);
|
return (COLOR_YELLOW);
|
||||||
case 7: /* 111 */
|
case 7: /* 111 */
|
||||||
return (COLOR_WHITE);
|
return (COLOR_WHITE);
|
||||||
|
default:
|
||||||
|
return COLOR_BLACK;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ class AsyncSerial : public AsyncListener,
|
|||||||
public std::enable_shared_from_this<AsyncSerial> {
|
public std::enable_shared_from_this<AsyncSerial> {
|
||||||
public:
|
public:
|
||||||
using ReceiveCallback =
|
using ReceiveCallback =
|
||||||
std::function<void(uint8_t *data, size_t len, const size_t bufsize)>;
|
std::function<void(uint8_t *data, const size_t bufsize, size_t len)>;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
AsyncSerial(std::string port_name, uint32_t baud_rate = 115200);
|
AsyncSerial(std::string port_name, uint32_t baud_rate = 115200);
|
||||||
@@ -56,7 +56,7 @@ class AsyncSerial : public AsyncListener,
|
|||||||
bool tx_in_progress_ = false;
|
bool tx_in_progress_ = false;
|
||||||
|
|
||||||
bool SetupPort();
|
bool SetupPort();
|
||||||
void DefaultReceiveCallback(uint8_t *data, size_t len, const size_t bufsize);
|
void DefaultReceiveCallback(uint8_t *data, const size_t bufsize, size_t len);
|
||||||
void ReadFromPort();
|
void ReadFromPort();
|
||||||
void WriteToPort(bool check_if_busy);
|
void WriteToPort(bool check_if_busy);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -80,8 +80,8 @@ void AsyncSerial::StopService() {
|
|||||||
port_opened_ = false;
|
port_opened_ = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AsyncSerial::DefaultReceiveCallback(uint8_t *data, size_t len,
|
void AsyncSerial::DefaultReceiveCallback(uint8_t *data, const size_t bufsize,
|
||||||
const size_t bufsize) {}
|
size_t len) {}
|
||||||
|
|
||||||
void AsyncSerial::ReadFromPort() {
|
void AsyncSerial::ReadFromPort() {
|
||||||
auto sthis = shared_from_this();
|
auto sthis = shared_from_this();
|
||||||
@@ -93,9 +93,13 @@ void AsyncSerial::ReadFromPort() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sthis->rcv_cb_ != nullptr)
|
if (sthis->rcv_cb_ != nullptr) {
|
||||||
sthis->rcv_cb_(sthis->rx_buf_.data(), bytes_transferred,
|
sthis->rcv_cb_(sthis->rx_buf_.data(), sthis->rx_buf_.size(),
|
||||||
sthis->rx_buf_.size());
|
bytes_transferred);
|
||||||
|
} else {
|
||||||
|
sthis->DefaultReceiveCallback(
|
||||||
|
sthis->rx_buf_.data(), sthis->rx_buf_.size(), bytes_transferred);
|
||||||
|
}
|
||||||
sthis->ReadFromPort();
|
sthis->ReadFromPort();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user