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