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
Revision 0:36b37fd10b58, committed 2019-09-01
- Comitter:
- yuto17320508
- Date:
- Sun Sep 01 09:46:15 2019 +0000
- Commit message:
- first commit
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
mbed.bld | Show annotated file Show diff for this revision Revisions of this file |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Sun Sep 01 09:46:15 2019 +0000 @@ -0,0 +1,55 @@ +#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; + } + + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Sun Sep 01 09:46:15 2019 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400 \ No newline at end of file