I use Event on for listening the 4G Sim。If the Http Response is a little datas, it work well. But If the Response is relatively much more data, this error will happen.
In the code, the variable line will receive data as much as the http return.
How do I avoid this error?
The main code like this:
uart.on("data", function cb(d) {
line += d;
if (line.startsWith("\r\n")) {
line = line.substr(2);
}
if (line[0] === "\n") {
line = line.substr(1);
}
if (line[0] === "\r") {
line = line.substr(1);
}
if (line[0] === "\u00FF") {
line = line.replace("\u00FF", "");
}
if (line.length > 0) {
for (let h in lineHandlers)
if (line.indexOf(h) > -1) {
line = lineHandlers[h](line.substr(line.indexOf(h)));
}
}
if (handlers) {
for (let h in handlers) {
while (line.substr(0, h.length) === h) {
let resp = handlers[h](line);
if (resp) {
line = resp;
} else {
line = "";
}
return;
}
}
}
You can either you can use XON/OFF software flow control when setting up the Serial device, or you can do hardware flow control too - you then just need to set the modem up to use it
Don't worry about formatting, just type in the text and we'll take care of making sense of it. We will auto-convert links, and if you put asterisks around words we will make them bold.
Tips:
Create headers by underlining text with ==== or ----
To *italicise* text put one asterisk each side of the word
To **bold** text put two asterisks each side of the word
Embed images by entering: ![](https://www.google.co.uk/images/srpr/logo4w.png) That's the hard one: exclamation, square brackets and then the URL to the image in brackets.
* Create lists by starting lines with asterisks
1. Create numbered lists by starting lines with a number and a dot
> Quote text by starting lines with >
Mention another user by @username
For syntax highlighting, surround the code block with three backticks:
```
Your code goes here
```
Just like Github, a blank line must precede a code block.
If you upload more than 5 files we will display all attachments as thumbnails.
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
I ran code in STM32F4DISCOVERY board.
I use Event on for listening the 4G Sim。If the Http Response is a little datas, it work well. But If the Response is relatively much more data, this error will happen.
In the code, the variable line will receive data as much as the http return.
How do I avoid this error?
The main code like this: