Commit Graph

28 Commits (5a9ad74818d4828fab6a25e22d650b92818d57b2)

Author SHA1 Message Date
Rajkumar Kanagaraj 13a1130697 Remove the deprecated FileHandle APIs 2020-03-02 06:45:01 -08:00
Kevin Bracey c39959ca8b C++11-ify virtualisation in FileHandle + Serials
Use `override` and `final` where appropriate, and eliminate unnecessary
`virtual`.
2020-02-24 10:37:17 +02:00
Hugues Kamba 20f81e19be Change Doxygen groups structure, splitting first by Public/Internal (#11105)
* Change Doxygen groups structure, splitting first by Public/Internal

This commit also does the following:
* groups the documentation of related API
* moves `events/internal/equeue.h` to `events/equeue.h`
* merges `events/source/README.md` to `events/README.md`
2019-08-02 12:23:47 +01:00
Hugues Kamba 83354e46a7 Platform: Separate internal APIs from public APIs
Also includes:
* rename `mbed_sleep_manager.c` to `mbed_power_mgmt.c` to match its
  header file
* create Doxygen groups for public and internal APIs
* use relative path to include header files where inconsistent
* update references to internal APIs throughout libraries
* update the copyright year for all modified files
2019-08-02 12:23:47 +01:00
Kevin Bracey e96d6581db Add enable API to FileHandle
Add API to dynamically enable/disable input and output on FileHandles.
Aim is to allow power saving by indicating that we permanently or
temporarily do not require input, so that for example serial Rx
interrupts can be released, and deep sleep permitted.
2019-02-21 16:53:22 +02:00
Kevin Bracey ae17f6ebba Add FileHandle::truncate and ftruncate
Add support for file truncation (or extension) to the abstract API.

No hooks to actual implementations in this commit.
2018-12-14 19:29:28 +02:00
Martin Kojtal ad759b7749 platform: add spdx license 2018-11-28 10:39:52 +00:00
Amanda Butler 9ab13df3bd
Make changes from comments to FileHandle.h
Address comments.
2018-10-29 14:09:16 -05:00
Amanda Butler 3a8919b22d
Copy edit FileHandle.h
Copy edit file.
2018-10-17 17:26:27 -05:00
Kevin Gilbert 7709b24b29
api->API
Minor doxygen update, uppercase acronym
2018-10-17 17:20:10 -05:00
Martin Kojtal ffcb6ecfb5 platform: astyle update 2018-06-29 10:38:44 +01:00
Kevin Bracey 59f49e2b96 Add `is_blocking()` method to FileHandle
There was no way to check current blocking state, so no way to modify
and restore status.

Also have default FileHandle::set_blocking() used by real files return a
correct error code when asked for non-blocking, and success when asked
for blocking.

These were minor omissions that are required to implement POSIX fcntl
properly.

fixup! Add `is_blocking()` method to FileHandle
2018-05-03 15:38:33 +03:00
Yossi Levy 8684a63732 Fix Travis CI docs issues 2018-04-02 13:01:21 +03:00
Yossi Levy 57b4653a98 Adding @deprecated functions to the inline documentation of deprecated functions 2018-03-29 12:05:26 +03:00
Kevin Bracey 96c709fb35 Rework retarget opening
Rationalise layers a little more to add the POSIX standard fdopen(int)
and a local open(FileHandle) to map a FileHandle to a POSIX file
descriptor.

fdopen(FileHandle) is now a composite of those two, rather than being
a primitive.
2018-02-06 11:07:21 +02:00
Kevin Bracey 9678c8052e Make UARTSerial send all data when blocking
Previously, write() was somewhat soft - it only ever made one attempt to
wait for buffer space, so it would take as much data as would fit in the
buffer in one call.

This is not the intent of a POSIX filehandle write. It should try to
send everything if blocking, and only send less if interrupted by a
signal:

 - If the O_NONBLOCK flag is clear, write() shall block the calling
   thread until the data can be accepted.

 - If the O_NONBLOCK flag is set, write() shall not block the thread.
   If some data can be written without blocking the thread, write()
   shall write what it can and return the number of bytes written.
   Otherwise, it shall return -1 and set errno to [EAGAIN].

This "send all" behaviour is of slightly limited usefulness in POSIX, as
you still usually have to worry about the interruption possibility:

  - If write() is interrupted by a signal before it writes any data, it
    shall return -1 with errno set to [EINTR].

  - If write() is interrupted by a signal after it successfully writes
    some data, it shall return the number of bytes written.

But as mbed OS does not have the possibility of signal interruption, if we
strengthen write to write everything, we can make applications' lives
easier - they can just do "write(large amount)" confident that it will
all go in one call (if no errors).

So, rework to make multiple writes to the buffer, blocking as necessary,
until all data is written.

This change does not apply to read(), which is correct in only blocking until
some data is available:

 - If O_NONBLOCK is set, read() shall return -1 and set errno to [EAGAIN].

 - If O_NONBLOCK is clear, read() shall block the calling thread until some
   data becomes available.

 - The use of the O_NONBLOCK flag has no effect if there is some data
   available.
2017-11-21 09:51:36 +02:00
Senthil Ramakrishnan 3ad298488c Doxygen comment updates and fixes 2017-10-26 15:36:26 -05:00
Vincent Coubard dcbcf64830 platform: Tag classes DirHandle, FileHandle, FileLike, FileSystemHandle, FileSystemLike, LocalFileHandle, LocalFileSystem and PlatformMutex as non copyable.
This avoid unwanted copy of these type which is a programming error.
2017-06-20 16:23:43 +01:00
Deepika Bhavnani f05e498c73 Resolving doxygen warnings 2017-06-08 15:48:20 -05:00
Sam Grove 2d8bf18317 Fix doxygen warnings. 2017-06-05 17:32:45 -05:00
Hasnain Virk c8933e4c71 Removing _poll_change() for now
There is currently no proper wake up mechanism provided
by mbed-os. _poll_change() was supposed to wake upa blocking
poll() in case of a POLL event but the implementation was dependent
upon underlying wake up mechanism. In the absence of conditioanl
variables or some other alternative, _poll_change() wasn't able to
serve its purpose. Removing it for now. Should be implemented at some later stage
2017-05-31 15:02:11 +03:00
Hasnain Virk c65f81bf46 Remove sigio implementation from FileHandle
Make FileHandle more of an interface class, by requiring implementers to
provide the sigio() functionality themselves.

sigio() and poll() remain parallel independent mechanisms, so FileHandle
implementations must trigger both on state changes.
2017-05-31 15:02:11 +03:00
Hasnain Virk b2408d8a16 Extending FileHandle & introducing mbed_poll
This has been an attempt to extend existing FileHandle to behave like POSIX
file descriptor for input/output resources/devices too.
This will now provide an abstract indicator/handle any arbitrary file or device
type resource. May be in future, sockets too.

In order to correctly detect availability of read/write a FileHandle, we needed
a select or poll mechanisms. We opted for poll as POSIX defines in
http://pubs.opengroup.org/onlinepubs/009695399/functions/poll.html Currently,
mbed::poll() just spins and scans filehandles looking for any events we are
interested in. In future, his spinning behaviour will be replaced with
condition variables.

In retarget.cpp we have introduced an mbed::fdopen() function which is
equivalent to C fdopen(). It attaches a std stream to our FileHandle stream.
newlib-nano somehow does not seem to call isatty() so retarget doesn't work for
device type file handles. We handle this by checking ourselves in
mbed::fdopen() if we wish to attach our stream to std stream.  We also turn off
buffering by C library as our stuff will be buffered already.

sigio() is also provided, matching the API of the Socket class, with a view to
future unification. As well as unblocking poll(), _poll_change calls the user
sigio callback if an event happens, i.e., when FileHandle becomes
readable/writable.
2017-05-31 15:02:11 +03:00
Kevin Bracey 533910cb87 Correct return type of FileHandle::size()
File size should be off_t, not size_t.
2017-05-31 15:02:11 +03:00
Jimmy Brisson f945d71319 Update class documentation tags
stop using scope for \addtogroup. It was placing class methods into the
group documentation instead of the class documentation. The new style is
to explicitly tag the class as @ingroup. This new method will allow the
class to be linked in the group page, and the class page will contain
the detailed documentation of the class methods.
2017-04-04 14:21:53 -05:00
Christopher Haster 18bab4e024 Filesystem: Fixed typo in param naming 2017-03-14 11:04:22 -05:00
Christopher Haster 90fc0b9c47 FileSystem: Reverted deprecation of DirHandle
Should follow same path as FileHandle, although this is less used
and there is currently no route to introduce a hook for a customized
DirHandle in retarget.
2017-03-14 11:02:34 -05:00
Christopher Haster 61c9683644 Filesystem: Moved retarget related file interfaces into platform 2017-03-14 11:02:34 -05:00