std::string_view 的使用
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
#include <thread>
|
||||
#include <string_view>
|
||||
#ifdef __linux__
|
||||
#include "Serial_p.h"
|
||||
#include <map>
|
||||
@@ -216,7 +217,7 @@ std::optional<Baud_Rate_Type> value_to_baud(const long baud_rate) {
|
||||
|
||||
|
||||
|
||||
std::string get_serial_info_str(std::string serial_name) {
|
||||
std::string get_serial_info_str(std::string_view serial_name) {
|
||||
Serial serial;
|
||||
serial.set_serial_name(std::move(serial_name));
|
||||
serial.open();
|
||||
@@ -225,7 +226,7 @@ std::string get_serial_info_str(std::string serial_name) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
int open(const std::string& serial_name) {
|
||||
int open(std::string_view serial_name) {
|
||||
// 打开串口设备 O_RDWR | O_NOCTTY | O_CLOEXEC
|
||||
Serial_FD fd = ::open(serial_name.c_str(), O_RDWR | O_NOCTTY | O_CLOEXEC); // O_RDWR: 可读可写, O_NOCTTY: 不设置为控制终端, O_NDELAY: 非阻塞
|
||||
if (fd == -1) {
|
||||
|
||||
Reference in New Issue
Block a user