config AX12
Fork of configure_ax12_test_bras_module by
mbed/Stream.h@2:91b6646ea994, 2017-02-01 (annotated)
- Committer:
- clementlignie
- Date:
- Wed Feb 01 13:42:30 2017 +0000
- Revision:
- 2:91b6646ea994
- Parent:
- 0:c03cffe402df
config AX12
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
slowness | 0:c03cffe402df | 1 | /* mbed Microcontroller Library - Stream |
slowness | 0:c03cffe402df | 2 | * Copyright (c) 2007-2009 ARM Limited. All rights reserved. |
slowness | 0:c03cffe402df | 3 | */ |
slowness | 0:c03cffe402df | 4 | |
slowness | 0:c03cffe402df | 5 | #ifndef MBED_STREAM_H |
slowness | 0:c03cffe402df | 6 | #define MBED_STREAM_H |
slowness | 0:c03cffe402df | 7 | |
slowness | 0:c03cffe402df | 8 | #include "FileLike.h" |
slowness | 0:c03cffe402df | 9 | #include "platform.h" |
slowness | 0:c03cffe402df | 10 | #include <cstdio> |
slowness | 0:c03cffe402df | 11 | |
slowness | 0:c03cffe402df | 12 | namespace mbed { |
slowness | 0:c03cffe402df | 13 | |
slowness | 0:c03cffe402df | 14 | class Stream : public FileLike { |
slowness | 0:c03cffe402df | 15 | |
slowness | 0:c03cffe402df | 16 | public: |
slowness | 0:c03cffe402df | 17 | |
slowness | 0:c03cffe402df | 18 | Stream(const char *name = NULL); |
slowness | 0:c03cffe402df | 19 | virtual ~Stream(); |
slowness | 0:c03cffe402df | 20 | |
slowness | 0:c03cffe402df | 21 | int putc(int c) { |
slowness | 0:c03cffe402df | 22 | fflush(_file); |
slowness | 0:c03cffe402df | 23 | return std::fputc(c, _file); |
slowness | 0:c03cffe402df | 24 | } |
slowness | 0:c03cffe402df | 25 | int puts(const char *s) { |
slowness | 0:c03cffe402df | 26 | fflush(_file); |
slowness | 0:c03cffe402df | 27 | return std::fputs(s, _file); |
slowness | 0:c03cffe402df | 28 | } |
slowness | 0:c03cffe402df | 29 | int getc() { |
slowness | 0:c03cffe402df | 30 | fflush(_file); |
slowness | 0:c03cffe402df | 31 | return std::fgetc(_file); |
slowness | 0:c03cffe402df | 32 | } |
slowness | 0:c03cffe402df | 33 | char *gets(char *s, int size) { |
slowness | 0:c03cffe402df | 34 | fflush(_file); |
slowness | 0:c03cffe402df | 35 | return std::fgets(s,size,_file);; |
slowness | 0:c03cffe402df | 36 | } |
slowness | 0:c03cffe402df | 37 | int printf(const char* format, ...); |
slowness | 0:c03cffe402df | 38 | int scanf(const char* format, ...); |
slowness | 0:c03cffe402df | 39 | |
slowness | 0:c03cffe402df | 40 | operator std::FILE*() { return _file; } |
slowness | 0:c03cffe402df | 41 | |
slowness | 0:c03cffe402df | 42 | #ifdef MBED_RPC |
slowness | 0:c03cffe402df | 43 | virtual const struct rpc_method *get_rpc_methods(); |
slowness | 0:c03cffe402df | 44 | #endif |
slowness | 0:c03cffe402df | 45 | |
slowness | 0:c03cffe402df | 46 | protected: |
slowness | 0:c03cffe402df | 47 | |
slowness | 0:c03cffe402df | 48 | virtual int close(); |
slowness | 0:c03cffe402df | 49 | virtual ssize_t write(const void* buffer, size_t length); |
slowness | 0:c03cffe402df | 50 | virtual ssize_t read(void* buffer, size_t length); |
slowness | 0:c03cffe402df | 51 | virtual off_t lseek(off_t offset, int whence); |
slowness | 0:c03cffe402df | 52 | virtual int isatty(); |
slowness | 0:c03cffe402df | 53 | virtual int fsync(); |
slowness | 0:c03cffe402df | 54 | virtual off_t flen(); |
slowness | 0:c03cffe402df | 55 | |
slowness | 0:c03cffe402df | 56 | virtual int _putc(int c) = 0; |
slowness | 0:c03cffe402df | 57 | virtual int _getc() = 0; |
slowness | 0:c03cffe402df | 58 | |
slowness | 0:c03cffe402df | 59 | std::FILE *_file; |
slowness | 0:c03cffe402df | 60 | |
slowness | 0:c03cffe402df | 61 | }; |
slowness | 0:c03cffe402df | 62 | |
slowness | 0:c03cffe402df | 63 | } // namespace mbed |
slowness | 0:c03cffe402df | 64 | |
slowness | 0:c03cffe402df | 65 | #endif |
slowness | 0:c03cffe402df | 66 |