* state machine corrections
* adding various standard API methods
* Addition/revision/enhancement of the nsapi_ppp glue layer
* Turning off debug by default
Mainly reutilizing code from ublox C027 support lib.
As we are using external PDP context, i.e., an external IP stack,
we will pass username and password to underlying stack running PPP.
We only support CHAP as the authentication protocol.
POSIX poll() provides a mechanism to attach a POLL_HUP event
if the modem or device hangs up on you. POLL_HUP and POLL_OUT are
mutually exclusive. We poll in the PPP_input() routine if the modem
hung up. If it did we stop the data consumption, close PPP and go back
to the driver for reserruction of AT parser and subsequent retries or
application specific actions.
This is achieved by attaching an interrupt to the DCD line of the modem.
When DCD line goes high (off), we have lost the carrier. So we record an
POLLHUP event using _poll_change().
ATParser had been using std <vector> which had been pulling along a lot
of standard C++ stuff. We have an alternative implementation whcih achieves
a similar effect but without using <vector>. this saves a bunch of valuable
RAM resource.
We have also simplified the overall system by introducing proper CR and LF
rather than \r\n type of delimiters. This newline simplification is borrowed
from retarget.cpp.
Existing ATParser is extended to use FileHandle. This essentially detaches
ATParser from previous tight binding with various implementations of serial
interfaces with buffering.
Now the ATParser uses only abstract FileHandle and doesn't really care about
the underlying implementation. Underneath, it could be a USB device type FileHandle
or a Serial device type FileHandle etc.
Some simplification steps were taken as the code provided opportunities to simplify
and optimize.
BufferedSerial is a FileHandle and using SerialBase.
It keeps the SerialBase private however lets the user extend FileHandle
by keeping it public.
It is using CircularBuffer class for having circular buffers.
There are some minor amendments in CircularBuffer too.
Adding an entry for tx/rx buffer sizes in platform/mbed_lib.json.
Default size is 256 bytes.
For RTOS read(), write() calls yield for other threads to carry on with their stuff.
For non-RTOS blovking read or write would mean a loop where 100 percent resources are
consumed by this loop. Need to get a better implementation in. Currently no mechanism to
wake the mcu up after WFE.
mbed::fdopen() is provided in mbed_retarget.cpp which will attach a stream to the
given FileHandle. Removing mbed_set_unbuffered_stream() from stream class as it
is defined in mbed_retarget.cpp. Stream class should not decide whether it wants
to detach buffers from c library or not. mbed::fdopen() will do that based upon
isatty() call. So if a FileHandle is not a tty, i.e., is not a device type, c library
buffering will not be turned off. For device type FileHandles, c library buffering
is turned off.
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.
* Don't set errno when calls are successful (will slightly alleviate the problem
of errno not being thread-safe yet).
* Transfer errors returned from size() and seek() into errno.
* Fix isatty() - could never return 1 from a FileHandle.
* Use more appropriate errors than EBADF in some places (eg ENOENT for non-existant path).
failing on file allocation / opening during Stream creation.
The consequence was application continues running, but any printf
to the Serial object whose Stream was not properly created
would not show any error (and characters would not show either)
Let's add a check to properly inform user of the error.
[Warning] mbed_board.c@99,36: comparison between signed and unsigned
integer expressions [-Wsign-compare] is seen during compilation.
Fix the warning and small improvements.
1. Change type of loop variable "i" to the same type as "size".
Size is > 0 checked by the if statement and i stops at == size
so none can be negative. However size still needs to be signed
to detect error codes from vsnprintf.
2. Reduced scope of stdio_out_prev and make sure it's initialized.
3. Define a name for the error buffer size and use vsnprintf instead
of vsprintf to avoid writing outside of the array.
NOTE: the if(size > 0) statement doesn't need to change. If
the message to write is larger than the buffer size vsnprintf
truncates it automatically but still returns a positive value.
Fix the following compiler warning.
Compile [ 63.7%]: mbed_board.c
[Warning] mbed_board.c@99,36: comparison between signed and unsigned integer expressions [-Wsign-compare]
Signed-off-by: Tony Wu <tonyw@realtek.com>
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.
The current implementation of semihost_disabledebug() hangs when used
with mbed interface firwmare revision 21164, the first version which
added support for this semihost call. I encountered this hang when
running a Release build on my mbed-LPC1768 board as the RTOS attempted
to disable the debugger before the idle thread put the CPU to sleep.
The 21164 interface firmware expects that R1 points to a valid argument
block but the current implementation passes in NULL. The fix was to
pass in a dummy block which is ignored by the newer 141212 revision of
the firmware and allows the 21164 version to proceeed without halting
the CPU until a manual reset.
Before this fix semihost_disabledebug() did work with the latest
mbed interface firmware revision 141212 but I rarely use this revision
of the interface firmware due to the instability issues I have
encountered in the past with its CDC and LocalFileSystem functionality.
With this proposed fix, the code now works with both the 21164 and
141212 revisions of the mbed interface firmware on the mbed-LPC1768.
This patch fixes the declaration of the DIR type and related functions
so that they can be called from C code. This is necessary when enabling
functionality that uses the filesystem in mbed TLS.
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.
As identified by @hasnainvirk, @kjbracey-arm, the FileHandle and
FileBase serve two separate functions and their integration is
limiting for certain use cases.
FileLike is actually the redundant class here, but the multiple
inheritance it provides is used as a hack by the retargeting code
to get at the FileHandle implementation bound to the FileBase name.
It may make more sense for the FileBase to inherit from FileHandle,
(with perhaps a different name), but rather than explore the
possibility, this will just restore the previous hierarchy.
- Fixing code formatting errors with astyle tool.
- Replaced use of TOOLCHAIN_xxx macros with compiler emitted macros.
- Added const to BlockDevice::get_xxx_size() member functions.
- Added documentation for FAT filesystem thread support.
- Added documentation for fat_filesystem_set_errno().
- Added documentation clarifying the reasons for errno/stat symbol definitions in retarget.h.
- Removed FAT filesystem from mbed 2 testing.
- Fixed FATMisc.h Copyright (c) 2016 year to 2017 as its a new file.
- Removed #ifndef NDEBUG from HeapBlockDevice.cpp.
- Removed unnecessary todo comment in retarget.cpp.
- renaming FATFileSystemSetErrno() fat_file_system_set_errno.
- changing FATFileSystem::format() to be mount fs internally in function, rather than expecting fs to be mounted.
- requested const char *filename change.
The attach function is used several other places to indicate
registration for interrupts. This differs significantly to its use in
the Callback class. Additionally, the attach function is unnecessary
given that simple assignment works just as well.
MBED_CONF_PLATFORM_STDIO_CONVERT_NEWLINES was not used in mbed_error_vfprintf causing wrong behavior when the option was selected (no new line is some terminals like putty).
Add sleep/deepsleep functions to platform layer which are replacing HAL
functions with the same name, rename existing symbols in HAL layer
to hal_sleep/hal_deepsleep. This way sleep functions
are always available, even if target doesn't implement them, which makes
the code using sleep clearer. It also enables us to make decision on in
which builds (debug/release) the sleep will be enabled.
Adopting relaxed type-deduction in bound functions better aligns with
the same overloads for member functions, and provides an alternative
solution for the void pointer cast issue, which removes a large amount
of cruft.
The type deduction for the callback constructors was to strict and
prevented implicit casts for the context pointer stored internally.
As noted by @pan-, relaxing the contraints on the templated
parameters allows C++ to correctly infer implicit casts such as
conversions between child and parent classes when inheritance is
involved.
As an additional benefit, this may help the user experience by
defering invalid type errors to when the types are expanded,
limiting the number of error messages presented to users.
Added MBED_STATIC_ASSERT for compile-time assertions, results in
compile-time error if condition is false
The assertion acts as a declaration that can be placed at file scope, in
a code block (except after a label), or as a member of
a C++ class/struct/union.
Unfortunately, there does not exist a backup construct for use in
C class/struct/union contexts. An alternative macro,
MBED_STRUCT_STATIC_ASSERT provides this ability to avoid disabling
static assertions for the majority of mbed-supported C compilers.
In uARM, the library's hook _platform_post_stackheap_init does not seem to
exist and I couldnot find a documentation describing the initialisation
flow. All we know is that _open is called after RAM init and before the
C++ init, so this is a working placeholder.
This is maybe not acceptable so a uARM lib expert may propose a better
hook to fullfil the requirement.
At least this is a workign setup.
This series should solve issue reported here:
STM32 (At least F401) breaks if Tickers are activated in a global object #2115
Various toolchains supported in MBED don't followthe same initialization
steps. This can have impacts on platform behavior.
For STM32, it is needed to call the HAL_Init() _after_ the RAM has been
initialized (sdata from flash / zero initialized data) and _before_ the C++
objects are being created, especially if those objects require support
of tickers for instance.
In GCC and IAR, this was done in previous commit to avoid HAL_Init()
to be called twice.
In ARM this there is no hook defined in MBED yet to place the call.
The proposal is to take benefit of the library's
_platform_post_stackheap_init function that is going to be called before
__rt_lib_init where the C++ object init is done (__cpp_initialize__aeabi_)
This series should solve issue reported here:
STM32 (At least F401) breaks if Tickers are activated in a global object #2115