【发布时间】:2021-04-21 13:06:04
【问题描述】:
我正在使用连接到 Dragino NB-IoT LTE Bg96 的 Arduino Nano BLE 33。我试图阅读 https 获取电话的回复。 get 调用成功,为了读取它,我将 AT 命令发送到 BG96。然后它将它发送到 Uart,我试图在 arduino 上读取它。但是在 255 个字符后它停止了,我在不同的网站(有不同的响应)上尝试了它,但它在 255 个字符后中断。我之前使用过 uint8_t(for index),所以我认为这是错误,但现在我将其更改为 int 后仍然发生。
我的部分功能:
uint8_t bg96::check_response(char* desired_response){
char character;
int index = 0;
memset(response, 0, ARRAYSIZE);
while (Serial1.available()){
character = Serial1.read();
response[index] = character;
index++;
Serial.print(character);
}
response[index] = '\0';
Serial.print("index : ");
Serial.println(index);
Serial.print("Response:");
Serial.println(response);
回应:
+QHTTPGET: 0,200
AT+QHTTPREAD=80
CONNECT
HTTP/1.1 200 OK
Server: nginx/1.14.2
Content-Type: text/plain; charset=UTF-8
Transfer-Encoding: chunked
Vary: Accept-Encoding
X-Request-Id: 616401ed-bb42-43b3-aba9-ab53952b9405
X-Token-Id: d242eb9a-9dc3index : 255
Response:
应该是:
【问题讨论】:
-
包括
response的声明和其他相关部分。 -
不只是字节之间的间隙导致可用的时间为 0 一小会儿但你停止阅读?
-
我做了一些研究。我怀疑您会对
__#define SERIAL_RX_BUFFER_SIZE的值感兴趣。只需删除这些无用的库并自己编写 UART 驱动程序即可。这并不难。 -
@Lundin,它是带有 mbed 操作系统的 nRF52840
-
这些年来我至少写了二十个,所以我很确定。您需要了解基本的嵌入式系统、基本的电子学和 C 编程。不幸的是,Arduino 不会教你这些先决条件——它只会教你成为一个只能使用预制库而不了解它们如何工作的代码灵长类动物。这就是为什么你应该尽早摆脱它。
标签: c++ https arduino uart arduino-c++