Mistake on this page?
Report an issue in GitHub or email us
SerialWireOutput.h
1 /* mbed Microcontroller Library
2  * Copyright (c) 2017-2019 ARM Limited
3  * SPDX-License-Identifier: Apache-2.0
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 #ifndef MBED_SERIALWIREOUTPUT_H
19 #define MBED_SERIALWIREOUTPUT_H
20 
21 #include "platform/platform.h"
22 
23 #if defined(DEVICE_ITM)
24 
25 #include "platform/FileHandle.h"
26 
27 namespace mbed {
28 /**
29  * \defgroup drivers_SerialWireOutput SerialWireOutput class
30  * \ingroup drivers-public-api
31  * @{
32  */
33 
34 class SerialWireOutput : public FileHandle {
35 
36 public:
37 
38  SerialWireOutput(void);
39 
40  virtual ssize_t write(const void *buffer, size_t size);
41 
42  virtual ssize_t read(void *buffer, size_t size)
43  {
44  /* Reading is not supported by this file handle */
45  return -EBADF;
46  }
47 
48  virtual off_t seek(off_t offset, int whence = SEEK_SET)
49  {
50  /* Seeking is not support by this file handler */
51  return -ESPIPE;
52  }
53 
54  virtual off_t size()
55  {
56  /* Size is not defined for this file handle */
57  return -EINVAL;
58  }
59 
60  virtual int isatty()
61  {
62  /* File handle is used for terminal output */
63  return true;
64  }
65 
66  virtual int close()
67  {
68  return 0;
69  }
70 };
71 
72 /** @}*/
73 
74 } // namespace mbed
75 
76 #endif // DEVICE_ITM
77 
78 #endif // MBED_SERIALWIREOUTPUT_H
virtual ssize_t write(const void *buffer, size_t size)
Write the contents of a buffer to a file.
virtual off_t seek(off_t offset, int whence=SEEK_SET)
Move the file position to a given offset from from a given location.
virtual int isatty()
Check if the file in an interactive terminal device.
Class FileHandle.
Definition: FileHandle.h:46
virtual ssize_t read(void *buffer, size_t size)
Read the contents of a file into a buffer.
virtual int close()
Close a file.
virtual off_t size()
Get the size of the file.
Important Information for this Arm website

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.