Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
main.cpp
- Committer:
- yuto17320508
- Date:
- 2019-09-01
- Revision:
- 0:36b37fd10b58
File content as of revision 0:36b37fd10b58:
#include "mbed.h" #include "string" #include "vector" DigitalOut led(LED1); Serial pc(USBTX, USBRX); //rtosの機能を使うときはSerialではなくRawSerialを使えとの情報をみてこうしています。 char data[100]; int data_index = 0; std::vector<std::string> separate_string(std::string input) { std::vector<std::string> return_data; std::string separator = std::string(","); int separator_length = separator.length(); std::string::size_type offset = std::string::size_type(0); while(1) { int pos = input.find(separator, offset); if (pos == std::string::npos) { return_data.push_back(input.substr(offset)); break; } return_data.push_back(input.substr(offset,pos-offset)); offset = pos + separator_length; } return return_data; } int main(void){ while(1){ if (!pc.readable()) continue; char c = pc.getc(); data[data_index++] = c; if (c == '\n') { data[data_index] = '\0'; std::string str; str = data; std::vector<std::string> data_list = separate_string(str); for(int i=0;data_list.size();++i) { pc.puts(data_list[i].c_str()); pc.puts("+"); } data_index = 0; } } }