Replace direct accesses to sched_active_thread and sched_active_pid with
the helper functions thread_getpid() and thread_get_active(). This serves
two purposes:
1. It makes accidental writes to those variable from outside core less likely.
2. Casting off the volatile qualifier is now well contained to those two
functions
In most places, picolibc and newlib are the same, so use
the existing newlib code when compiling with picolibc.
Signed-off-by: Keith Packard <keithp@keithp.com>
Introduce optional user shell_post_readline_hook, shell_pre_command_hook, shell_post_command_hook.
Enable with USEMODULE=shell_hooks.
Calls user implemented *_hook functions if defined.
If implementation does not exist, nothing happens.
The intent is to make profiling of the shell command timings easier.
Test provided in tests/shell with USEMODULE=shell_hooks.
Originally, the options and flags in the `netif` shell output were
separated by two spaces. For later added flags this is not the case,
making the parsing of those flags and options hard to impossible.
This change adds those missing spaces + comments so it might not happen
again in the future.
The private parts need USB definitions (and are thus preferably used
from USB_H_USER_IS_RIOT_INTERNAL compilation units). Functions like
usb_board_reset_in_bootloader do not depend on USB headers for their
definitions and are fair game throughout the application even for
generic RIOT USB devices.
The code for traversing arrays of shell commands (used to print help messages
and to search for commmand handlers) was needlessly complex.
Co-authored-by: Juan Carrano <j.carrano@fu-berlin.de>
Factor out common code for quoted and unquoted tokens. This makes the code
slighly less clear, but it also eliminates repetition (which may improve
clarity).
Co-authored-by: Juan Carrano <j.carrano@fu-berlin.de>
The tokenizer (the code that breaks up the line given to the shell into
strings to create argv) was quite a messy piece of code. This commit
refactors it into a more traditional state-machine based parser.
This fixes the issues with quote handling exposed by the recently
introduced test.
Co-authored-by: Juan Carrano <j.carrano@fu-berlin.de>
This makes the code of `readline()` clearer and shorter. It also fixes a
minor artifact of the long line handling.
Previously it was not possible to recover from a long line. That is, if too
many characters were sent, the line would be invalidated and pressing backspace
would not fix it- the only option was to discard the line. It is now possible
to bring the line back to size. Note that visual effects when deleting characters
will still depend on the host's terminal.
The new code is written in a way that all writes to memory are guarded by
bounds check, so an assertion was removed.
Co-authored-by: Juan Carrano <j.carrano@fu-berlin.de>
There was some code added to "prevent putchar from being inlined", which
supposedly enlarged the code size.
Co-authored-by: Juan Carrano <j.carrano@fu-berlin.de>
The numeric value for EOF is -1. This caused the shell to return
the same code when EOF was encountered and when the line lenght was
exceeded. Additionally, if the line length is exceeded, the correct
behaviour is to consume the remaining characters until the end of
the line, to prevent the following line from containing (potentially
dangerous) garbage.
Co-authored-by: Hendrik van Essen <hendrik.ve@fu-berlin.de>
If there is more than one interface, print the id of the receiving
interface for convenience.
```
ping6 ff02::1
2020-02-20 18:19:38,644 # 12 bytes from fe80::d0ae:c1b:2054:58e%7: icmp_seq=0 ttl=64 rssi=-45 dBm time=4.801 ms
2020-02-20 18:19:38,652 # 12 bytes from fe80::d0ae:c1b:2054:58c%8: icmp_seq=0 ttl=64 rssi=-63 dBm time=13.422 ms (DUP!)
2020-02-20 18:19:38,661 # 12 bytes from fe80::c78:16d9:8aca:ba9a%8: icmp_seq=0 ttl=64 rssi=-44 dBm time=21.819 ms (DUP!)
2020-02-20 18:19:39,648 # 12 bytes from fe80::d0ae:c1b:2054:58e%7: icmp_seq=1 ttl=64 rssi=-44 dBm time=4.797 ms
2020-02-20 18:19:39,657 # 12 bytes from fe80::d0ae:c1b:2054:58c%8: icmp_seq=1 ttl=64 rssi=-61 dBm time=12.917 ms (DUP!)
2020-02-20 18:19:39,666 # 12 bytes from fe80::c78:16d9:8aca:ba9a%8: icmp_seq=1 ttl=64 rssi=-43 dBm time=21.679 ms (DUP!)
2020-02-20 18:19:40,657 # 12 bytes from fe80::d0ae:c1b:2054:58e%7: icmp_seq=2 ttl=64 rssi=-41 dBm time=4.795 ms
```
Having the definitions sit in the `net/gnrc/sixlowpan/frag.h` header
does not make much sense, when using Selective Fragment Forwarding
(and the fragmentation buffer already includes a
`net/gnrc/sixlowpan/frag/stats.h` header), so they are moved to their
own header. Since with this change it makes more sense to have the
statistics stored in their own sub-module, the pseudo-module is also
actualized.
Previously `ifconfig` would only know link-local addresses
(printed as 'local') and everything else would be 'global'.
This is wrong for site-local and unique local addresses which were
also denoted as global.
So use the already existing helper functions to determine the correct
type of IPv6 address when printing.
This change is in preparation to [PR 10788]. PR 10788 will make the
shell exitable which may lead to unexpected behavior in comparison to
previous usage of the shell.
To prevent this, this PR introduces two "new" functions to the shell's
API: `shell_run_once()` and `shell_run_forever()`.
`shell_run_once()` basically has the same behavior as `shell_run()` in
current master: Start a shell and continue reading lines until EOF is
reached.
`shell_run_forever()` wraps around `shell_run_once()` and restarts the
shell if it exits.
`shell_run()` is re-introduced as a back-porting alias for
`shell_run_forever()`.
As a consequence all current calls to `shell_run()` won't exit even
with [PR 10788] merged (which would add EOT as additional exit
condition for `shell_run_once()`).
[PR 10788]: https://github.com/RIOT-OS/RIOT/pull/10788
Replaces the special heap command approach of the lpc_common module with a more general heap command approach. Module lpc_common was already removed with PR #2118. PR #2118 integrated cpu/lpc_common code in cpu/lpc2387. With PR #3530 special heap handling for cpu/lpc2387 was replaced by newlib memory management which uses _sbrk_r to allocate chunks from the heap. _sbrk_r uses _sheap and _eheap symbols that are defined in lpc2387.ld and can be used together with mallinfo function for heap statistics.
CTRL-C cancels the current line, similar to how getty works.
This is useful if one is using a dumb terminal to communicate with
a node, as it saves having to repeatedly type backspace to discard the
current line. It also helps when connecting to an already running node,
as one does not know what is on the line buffer, the safest thing to do
is to begin by sending a ctrl-C.
This is a suggestion of @benemorius.
- Add SEMTECH_LORAMAC_ALREADY_JOINED ret code for semtech_loramac_join
- Add SEMTECH_LORAMAC_TX_CNF_FAILED ret code for semtech_loramac_send
- Update shell commands to notify when no ACK is received on cnf tx
Add a trivial shell program that scans for all slaves on an I2C bus by iterating
all of the possible 127 I2C addresses and checking for the ACK of the device.
I was looking for a quick way to gauge the link quality between two nodes,
so I added the rssi to the output of the ping6 command.
Maybe this is generally useful to have.
Loosely based on [the original ping] and [netutil]'s ping
New features (compared to old RIOT version):
- non-positional parameters
- Better duplicate detection (addresses #9387)
- Better asynchronous behavior
- Potential for future move to `sock_ip`
- (Optional) DNS-support
- Multithreading-safe (in case shell-command handler gets called
from multiple threads)
[the original ping]: http://ftp.arl.army.mil/~mike/ping.html
[netutil]: https://www.gnu.org/software/inetutils/
When IPv6 is enabled, the MTU is given. So users(*) sending IPv6 packets can
easily figure out what the supported maximum protocol unit is.
However, when IPv6 is disabled and a user wants to send layer 2 frames directly,
no information about the maximum PDU is available using the shell.
When 6LoWPAN is used, a user may be interested in the layer 2 PDU as well in
order to avoid layer 2 fragmentation.
This PR adds the L2-PDU info to the output of the ifconfig shell command, which
is printed regardless of the use of IPv6.
(*): Here "users" refers to human beings interacting with the shell.
Applications can get the maximum PDU of each layer more easily using
gnrc_netapi_get() with NETOPT_MAX_PACKET_SIZE instead of using a shell command.
Currently an interface's existence is not checked when it is supplied
by the user with the `nib` command. This can lead to assertion errors
as soon as the generated entry tries to resolve an address or route
generated with that command and the network interface not being found.
When using a serial terminal without local echo, the current line
would not get updated as the user typed because the shell module's
readline() was not flushing each character.
This commit fixes that behavior. For additional clarity, fflush is
turned into a macro (flush_if_needed) which expands to either a call
to fflush() or empty, according to the standard library used.
This also fixes the erase/line editing behavior (the delete characters
were not being flushed either.)
sc_rtc.c should only be compiled if periph_rtc module is actually used.
In practice there was not linking error when PERIPH_OPTIONAL|_REQUIRED
was not set as shell_commands hides calling the functions with
'#ifdef MODULE_PERIPH_RTC'.
In RIOT native, sending CTRL+D to a shell started using shell_run would resulted in and
endless prompt loop. I've been unable to trigger such a behaviour
on actual hardware using a UART connection, but calling `pm_off` seemed
like a better alternative than having an `#ifdef BOARD_NATIVE`.
Fixes#9946
This updates the ccn-lite package version which brings in the
latest upstream fixes for some compiler issues found on macOS
with clang and newer GCC versions.
A minor adaption of the RIOT shell commands is also included.
When compiled for `hifive1` board with `gcc-7.2.0` this warning was raised:
'ret' may be used uninitialized in this function [-Werror=maybe-uninitialized]
- Use RIOT's GPIO interface to access the sensor to increase portability
- Changed API to allow more than one sensor per board
- Added `sht1x_params.h` that specifies how the sensors is connected - each
board can overwrite default settings by #defining SHT1X_PARAM_CLK and
SHT1X_PARAM_DATA
- Changed arithmetic to use integer calculations only instead of floating point
arithmetic
- Added support for checking the CRC sum
- Allow optional skipping of the CRC check to speed up measuring
- Added support for advanced features like reducing the resolution and skipping
calibration to speed up measuring
- Allow specifying the supply voltage of sensor which heavily influences the
temperature result (and use that information to calculate the correct
temperature)
- Reset sensor on initialization to bring it in a well known state
- Support for the obscure heater feature. (Can be useful to check the
temperature sensor?)
- Updated old SHT11 shell commands to the new driver interface, thus allowing
more than one SHT10/11/15 sensor to be used
- Added new shell command to allow full configuration of all attached SHT1x
sensors
- Removed old command for setting the SHT11 temperature offset, as this feature
is implemented in the new configuration command
The sensor family SHT10, SHT11 and SHT15 only differ in their accuracy (as in
calibration, not as in resolution). Thus, the same driver can be used for all.
The new driver name better reflects this fact.
I'm using something like this command for a while now for debugging
GNRC. Usually, I just patch it into the application I'm using it with,
but I think there is a benefit to also provide it to RIOT upstream
properly.
After thinking about it a bit, I decided to remove the reactive
advertisement of context information all together in the shell command.
RFC 6775 does not explicitly forbids, but it discourages multicast RAs,
which would be the alternative.