The prosthetic control(MIT)

Committer:
ganlikun
Date:
Thu Jun 23 05:23:34 2022 +0000
Revision:
0:20e0c61e0684
01

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ganlikun 0:20e0c61e0684 1 /* mbed Microcontroller Library
ganlikun 0:20e0c61e0684 2 * Copyright (c) 2006-2013 ARM Limited
ganlikun 0:20e0c61e0684 3 *
ganlikun 0:20e0c61e0684 4 * Licensed under the Apache License, Version 2.0 (the "License");
ganlikun 0:20e0c61e0684 5 * you may not use this file except in compliance with the License.
ganlikun 0:20e0c61e0684 6 * You may obtain a copy of the License at
ganlikun 0:20e0c61e0684 7 *
ganlikun 0:20e0c61e0684 8 * http://www.apache.org/licenses/LICENSE-2.0
ganlikun 0:20e0c61e0684 9 *
ganlikun 0:20e0c61e0684 10 * Unless required by applicable law or agreed to in writing, software
ganlikun 0:20e0c61e0684 11 * distributed under the License is distributed on an "AS IS" BASIS,
ganlikun 0:20e0c61e0684 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
ganlikun 0:20e0c61e0684 13 * See the License for the specific language governing permissions and
ganlikun 0:20e0c61e0684 14 * limitations under the License.
ganlikun 0:20e0c61e0684 15 */
ganlikun 0:20e0c61e0684 16 #ifndef MBED_STREAM_H
ganlikun 0:20e0c61e0684 17 #define MBED_STREAM_H
ganlikun 0:20e0c61e0684 18
ganlikun 0:20e0c61e0684 19 #include "platform/platform.h"
ganlikun 0:20e0c61e0684 20 #include "platform/FileLike.h"
ganlikun 0:20e0c61e0684 21 #include "platform/FileHandle.h"
ganlikun 0:20e0c61e0684 22 #include "platform/NonCopyable.h"
ganlikun 0:20e0c61e0684 23 #include <cstdio>
ganlikun 0:20e0c61e0684 24 #include <cstdarg>
ganlikun 0:20e0c61e0684 25
ganlikun 0:20e0c61e0684 26 namespace mbed {
ganlikun 0:20e0c61e0684 27 /** \addtogroup platform */
ganlikun 0:20e0c61e0684 28 /** @{*/
ganlikun 0:20e0c61e0684 29
ganlikun 0:20e0c61e0684 30 extern void mbed_set_unbuffered_stream(std::FILE *_file);
ganlikun 0:20e0c61e0684 31 extern int mbed_getc(std::FILE *_file);
ganlikun 0:20e0c61e0684 32 extern char* mbed_gets(char *s, int size, std::FILE *_file);
ganlikun 0:20e0c61e0684 33 /** @}*/
ganlikun 0:20e0c61e0684 34
ganlikun 0:20e0c61e0684 35 /** File stream
ganlikun 0:20e0c61e0684 36 *
ganlikun 0:20e0c61e0684 37 * @note Synchronization level: Set by subclass
ganlikun 0:20e0c61e0684 38 * @ingroup platform
ganlikun 0:20e0c61e0684 39 */
ganlikun 0:20e0c61e0684 40 class Stream : public FileLike, private NonCopyable<Stream> {
ganlikun 0:20e0c61e0684 41
ganlikun 0:20e0c61e0684 42 public:
ganlikun 0:20e0c61e0684 43 Stream(const char *name=NULL);
ganlikun 0:20e0c61e0684 44 virtual ~Stream();
ganlikun 0:20e0c61e0684 45
ganlikun 0:20e0c61e0684 46 int putc(int c);
ganlikun 0:20e0c61e0684 47 int puts(const char *s);
ganlikun 0:20e0c61e0684 48 int getc();
ganlikun 0:20e0c61e0684 49 char *gets(char *s, int size);
ganlikun 0:20e0c61e0684 50 int printf(const char* format, ...);
ganlikun 0:20e0c61e0684 51 int scanf(const char* format, ...);
ganlikun 0:20e0c61e0684 52 int vprintf(const char* format, std::va_list args);
ganlikun 0:20e0c61e0684 53 int vscanf(const char* format, std::va_list args);
ganlikun 0:20e0c61e0684 54
ganlikun 0:20e0c61e0684 55 operator std::FILE*() {return _file;}
ganlikun 0:20e0c61e0684 56
ganlikun 0:20e0c61e0684 57 protected:
ganlikun 0:20e0c61e0684 58 virtual int close();
ganlikun 0:20e0c61e0684 59 virtual ssize_t write(const void* buffer, size_t length);
ganlikun 0:20e0c61e0684 60 virtual ssize_t read(void* buffer, size_t length);
ganlikun 0:20e0c61e0684 61 virtual off_t seek(off_t offset, int whence);
ganlikun 0:20e0c61e0684 62 virtual off_t tell();
ganlikun 0:20e0c61e0684 63 virtual void rewind();
ganlikun 0:20e0c61e0684 64 virtual int isatty();
ganlikun 0:20e0c61e0684 65 virtual int sync();
ganlikun 0:20e0c61e0684 66 virtual off_t size();
ganlikun 0:20e0c61e0684 67
ganlikun 0:20e0c61e0684 68 virtual int _putc(int c) = 0;
ganlikun 0:20e0c61e0684 69 virtual int _getc() = 0;
ganlikun 0:20e0c61e0684 70
ganlikun 0:20e0c61e0684 71 std::FILE *_file;
ganlikun 0:20e0c61e0684 72
ganlikun 0:20e0c61e0684 73 /** Acquire exclusive access to this object.
ganlikun 0:20e0c61e0684 74 */
ganlikun 0:20e0c61e0684 75 virtual void lock() {
ganlikun 0:20e0c61e0684 76 // Stub
ganlikun 0:20e0c61e0684 77 }
ganlikun 0:20e0c61e0684 78
ganlikun 0:20e0c61e0684 79 /** Release exclusive access to this object.
ganlikun 0:20e0c61e0684 80 */
ganlikun 0:20e0c61e0684 81 virtual void unlock() {
ganlikun 0:20e0c61e0684 82 // Stub
ganlikun 0:20e0c61e0684 83 }
ganlikun 0:20e0c61e0684 84 };
ganlikun 0:20e0c61e0684 85
ganlikun 0:20e0c61e0684 86 } // namespace mbed
ganlikun 0:20e0c61e0684 87
ganlikun 0:20e0c61e0684 88 #endif
ganlikun 0:20e0c61e0684 89
ganlikun 0:20e0c61e0684 90