diff options
author | Cristian Maglie <c.maglie@bug.st> | 2013-05-15 18:06:25 +0200 |
---|---|---|
committer | Cristian Maglie <c.maglie@bug.st> | 2013-05-15 18:06:25 +0200 |
commit | fdba391eb6e7dd0103bda66faaef69a4b7b410d9 (patch) | |
tree | e1223bfc29bed6fd2d8d1c4439ae0073b9442dba /libraries/Bridge/Bridge.h | |
parent | 180713e5e760c6c18eb51bae7d74fa7d7291e168 (diff) |
Update Bridge library
Diffstat (limited to 'libraries/Bridge/Bridge.h')
-rw-r--r-- | libraries/Bridge/Bridge.h | 36 |
1 files changed, 22 insertions, 14 deletions
diff --git a/libraries/Bridge/Bridge.h b/libraries/Bridge/Bridge.h index 0740d4f..f85fa07 100644 --- a/libraries/Bridge/Bridge.h +++ b/libraries/Bridge/Bridge.h @@ -24,17 +24,13 @@ class BridgeClass: public Stream { public: - BridgeClass(Stream &_stream) : index(0), stream(_stream), started(false) { - // Empty - } - + BridgeClass(Stream &_stream); void begin(); + + // Methods to handle processes on the linux side uint8_t runCommand(String &command); - bool commandIsRunning(uint8_t handle); - unsigned int commandExitValue(uint8_t handle); - void cleanCommand(uint8_t handle); unsigned int commandOutputAvailable(uint8_t handle); @@ -42,22 +38,35 @@ public: unsigned int readCommandOutput(uint8_t handle, char *buff, unsigned int size) { return readCommandOutput(handle, reinterpret_cast<uint8_t *>(buff), size); } - void writeCommandInput(uint8_t handle, uint8_t *buff, unsigned int size); - void writeCommandInput(uint8_t handle, char *buff, unsigned int size) - { writeCommandInput(handle, reinterpret_cast<uint8_t *>(buff), size); } + void writeCommandInput(uint8_t handle, const uint8_t *buff, unsigned int size); + void writeCommandInput(uint8_t handle, const char *buff, unsigned int size) + { writeCommandInput(handle, reinterpret_cast<const uint8_t *>(buff), size); } + + // Methods to handle mailbox messages + unsigned int readMessage(uint8_t *buffer, unsigned int size); + void writeMessage(const uint8_t *buffer, unsigned int size); + unsigned int messageAvailable(); + + // Methods to handle key/value datastore + void put(const char *key, const char *value); + unsigned int get(const char *key, uint8_t *buff, unsigned int size); + unsigned int get(const char *key, char *value, unsigned int maxlen) + { get(key, reinterpret_cast<uint8_t *>(value), maxlen); } - // Print methods + // Print methods (proxy to "stream" object) [CM: are these really needed?] size_t write(uint8_t c) { return stream.write(c); } size_t write(const uint8_t *buffer, size_t size) { return stream.write(buffer, size); } - // Stream methods + // Stream methods (proxy to "stream" object) [CM: are these really needed?] int available() { return stream.available(); } int read() { return stream.read(); } int peek() { return stream.peek(); } void flush() { stream.flush(); } - uint8_t transfer(uint8_t *buff, uint8_t len, uint8_t *rxbuff=NULL, uint8_t rxlen=0); + // Trasnfer a frame (with error correction and response) + uint8_t transfer(const uint8_t *buff, uint8_t len, + uint8_t *rxbuff=NULL, uint8_t rxlen=0); private: uint8_t index; int timedRead(unsigned int timeout); @@ -72,7 +81,6 @@ private: private: static const char CTRL_C = 3; - static const char CMD_RECV = 0x00; Stream &stream; bool started; }; |