# 其它方法

## `Serial.end`

### 函数原型

```cpp
void HardwareSerial::end()
```

### 描述

结束串口通信。

无参数，无返回值。

## `Serial.find`

### 函数原型

```cpp
bool find(char *target);
bool find(uint8_t *target);
bool find(char *target, size_t length);
bool find(uint8_t *target, size_t length);
bool find(char target);
```

### 作用

从串口缓冲区读取数据，直到读取到指定的字符串。

### 参数

* target

  需要搜索的字符串或字符
* length

  最多搜索的长度

### 返回值

Boolean型

* True：找到
* False：没有找到

## `findUntil()`

从串口缓冲区读取数据，直到读取到指定的字符串或指定的停止符。

### 原型

```cpp
bool Serial.findUntil(target, terminal)
```

### 参数：

* target

  需要搜索的字符串或字符
* terminal

  停止符

### 返回值：

bool型数据，是否找到

## `flush()`

等待正在发送的数据发送完成。

### 语法：

```cpp
void Serial.flush()
```

## `parseFloat()`

从串口缓冲区返回第一个有效的float型数据。

### 语法：

```cpp
float Serial.parseFloat()
```

### 返回值：

float 型数据

## `parseInt()`

从串口流中查找第一个有效的整型数据。

### 语法：

```cpp
int Serial.parseInt()
```

### 返回值：

int 型数据

## `peek()`

返回 1 字节的数据，但不会从接受缓冲区删除该数据。

与 `read()` 的不同之处在于 `read()` 读取数据后，会从接受缓冲区删除该数据。

### 语法：

```cpp
int HardwareSerial::peek()
```

### 返回值：

进入接受缓冲区的第一个字节的数据；如果没有可读数据，则返回-1


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://arduino.doc.skyone.host/core/serial/other.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
