HAL-RO-Developer / iot_plat_doc

2 stars 0 forks source link

ESP8266のOverflowを調査 #39

Open hiyanaka opened 7 years ago

hiyanaka commented 7 years ago

背景

ESP8266がOverflowを起こさないようにする。

目的

ESP8266が文字列を送った時に、Overflowを起こすかを調査

対応内容

hiyanaka commented 7 years ago

http://qiita.com/matobaa/items/cc92fb105bdb5cdbe6f3

hiyanaka commented 7 years ago

https://www.mgo-tec.com/blog-entry-arduino-esp8266-ram-size.html

hiyanaka commented 7 years ago
/***
/* 文字列をシリアル通信で送信し、格納データを表示するプログラム
/***
char input[30];   // 文字列格納用
int i = 0;  // 文字数のカウンタ

void setup() {
  Serial.begin(9600);
}

void loop() {

  // データ受信したとき
  if (Serial.available()) {
    input[i] = Serial.read();
     // 文字数が30以上 or 末尾文字
    if (i > 30 || input[i] == '.') {
      // 末尾に終端文字の挿入
      input[i] = '\0';
      // 受信文字列を送信
      Serial.write(input);
      Serial.write("\n");
      // 格納されたデータ数を表示
      Serial.println(i);
    }
    else { i++; }
  }
}
hiyanaka commented 7 years ago

overflow

hiyanaka commented 7 years ago

対処法