serial_communication.hpp@0:964bbeb0a1d3, 2016-03-31 (annotated)
- Committer:
- inst
- Date:
- Thu Mar 31 04:42:48 2016 +0000
- Revision:
- 0:964bbeb0a1d3
- Child:
- 1:36cd04f61e68
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
inst | 0:964bbeb0a1d3 | 1 | #ifndef INCLUDED_SERIAL_COMMUNICATION_H |
inst | 0:964bbeb0a1d3 | 2 | #define INCLUDED_SERIAL_COMMUNICATION_H |
inst | 0:964bbeb0a1d3 | 3 | |
inst | 0:964bbeb0a1d3 | 4 | #include <string> |
inst | 0:964bbeb0a1d3 | 5 | #include <map> |
inst | 0:964bbeb0a1d3 | 6 | #include "mbed.h" |
inst | 0:964bbeb0a1d3 | 7 | |
inst | 0:964bbeb0a1d3 | 8 | class serial_communication { |
inst | 0:964bbeb0a1d3 | 9 | public: |
inst | 0:964bbeb0a1d3 | 10 | typedef std::string string; |
inst | 0:964bbeb0a1d3 | 11 | typedef std::map<string, int> map; |
inst | 0:964bbeb0a1d3 | 12 | |
inst | 0:964bbeb0a1d3 | 13 | static serial_communication* instance() { |
inst | 0:964bbeb0a1d3 | 14 | if (instance_ == NULL) { |
inst | 0:964bbeb0a1d3 | 15 | instance_ = new serial_communication; |
inst | 0:964bbeb0a1d3 | 16 | } |
inst | 0:964bbeb0a1d3 | 17 | return instance_; |
inst | 0:964bbeb0a1d3 | 18 | } |
inst | 0:964bbeb0a1d3 | 19 | |
inst | 0:964bbeb0a1d3 | 20 | int get_data(string key); |
inst | 0:964bbeb0a1d3 | 21 | bool update(); |
inst | 0:964bbeb0a1d3 | 22 | |
inst | 0:964bbeb0a1d3 | 23 | void receive(); |
inst | 0:964bbeb0a1d3 | 24 | private: |
inst | 0:964bbeb0a1d3 | 25 | serial_communication(); |
inst | 0:964bbeb0a1d3 | 26 | ~serial_communication(); |
inst | 0:964bbeb0a1d3 | 27 | |
inst | 0:964bbeb0a1d3 | 28 | // 実装しない |
inst | 0:964bbeb0a1d3 | 29 | serial_communication& operator=(const serial_communication&); |
inst | 0:964bbeb0a1d3 | 30 | serial_communication(const serial_communication&); |
inst | 0:964bbeb0a1d3 | 31 | |
inst | 0:964bbeb0a1d3 | 32 | RawSerial serial_; |
inst | 0:964bbeb0a1d3 | 33 | string buffer_; |
inst | 0:964bbeb0a1d3 | 34 | map map_; |
inst | 0:964bbeb0a1d3 | 35 | bool semaphore_; |
inst | 0:964bbeb0a1d3 | 36 | bool is_new_data_existing_; |
inst | 0:964bbeb0a1d3 | 37 | string data_; |
inst | 0:964bbeb0a1d3 | 38 | |
inst | 0:964bbeb0a1d3 | 39 | static serial_communication* instance_; |
inst | 0:964bbeb0a1d3 | 40 | }; |
inst | 0:964bbeb0a1d3 | 41 | |
inst | 0:964bbeb0a1d3 | 42 | #endif |