The Linux ping utility has the nice feature that fills the ICMPv6 echo
request payload with a pattern `payload_index & 0xFF`.
Then the ICMPv6 echo response payload is checked to verify that the pattern
is still intact.
This way corrupted messages can be detected.
In the past that revealed some 6lo-fragmentation bugs in Linux when
corrupted replies arrived.
This feature is also useful for RIOT, so implement it in RIOTs `ping`
command.
The `udp` command is a valuable debugging tool that is also useful
outside of the gnrc_networking example.
To enable easy sending of udp messages in other applications during
development, move the `udp` command to the shell module and introduce
the `gnrc_udp_cmd` pseudo-module to enable it.
Lists state, link type, v4/v6 addresses.
Currently read-only.
Using lwIP debug system to print addresses, to limit dependencies
and work with dual stack setup. Most other code seems to only
allow either v4 or v6 networking. For that to compile I
had to change the `SZT_F` format string due to this error:
```
error: format '%lu' expects argument of type 'long unsigned int',
but argument 2 has type 'size_t {aka unsigned int}'
```
Switching to the lwIP default format string here.
Outputs the following on my ESP32 board with Ethernet,
when both v4 and v6 are enabled in examples/paho-mqtt:
```
> ifconfig
Iface ET0 HWaddr: 24:0a:c4:e6:0e:9f Link: up State: up
Link type: wired
inet addr: 10.4.4.81 mask: 255.255.254.0 gw: 10.4.4.1
inet6 addr: fe80:0:0:0:260a:c4ff:fee6:e9f scope: link
inet6 addr: 2001:db8:1000:0:260a:c4ff:fee6:e9f scope: global
Iface ET1 HWaddr: 24:0a:c4:e6:0e:9c Link: up State: up
Link type: wireless
inet addr: 10.4.4.82 mask: 255.255.254.0 gw: 10.4.4.1
inet6 addr: fe80:0:0:0:260a:c4ff:fee6:e9c scope: link
inet6 addr: 2001:db8:1000:0:260a:c4ff:fee6:e9c scope: global
>
```
Previously a value of 0 was used for the RSSI to signal that this value is not
present in `gnrc_netif_hdr_t`. However, an RSSI of 0 dBm is legal and even very
plausible data.
This commit defines `GNRC_NETIF_HDR_NO_RSSI` as `INT16_MIN`, which is below the
noise floor in the vacuum of outer space and hence impossible to receive.
For consistency, also GNRC_NETIF_HDR_NO_LQI is defined.
Ctrl-D was not caught in a special case so it was interpreted as
a standard character. Handle it now the same way like EOF and
terminate the shell instance.
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