The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.

Dependents:   hello SerialTestv11 SerialTestv12 Sierpinski ... more

mbed 2

This is the mbed 2 library. If you'd like to learn about Mbed OS please see the mbed-os docs.

Committer:
AnnaBridge
Date:
Thu Jul 06 15:30:22 2017 +0100
Revision:
146:22da6e220af6
Parent:
145:64910690c574
Release 146 of the mbed library.

Who changed what in which revision?

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