Adjust the sample to work with the priority boost. It illustrates zbus
being used inside an ISR instead of into the main function.
Signed-off-by: Rodrigo Peixoto <rodrigopex@gmail.com>
Replace mutexes with semaphores to protect the channels in conjunction with
a priority boost algorithm based on the observers' priority.
Signed-off-by: Rodrigo Peixoto <rodrigopex@gmail.com>
Check the return code of sys_csrand_get when testing the function.
Ignoring it is bad practice and can also be a security issue if users
copy-paste this test code.
Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
Previously posix_apis.test_realtime was failing (very)
frequently in CI, and in particular, when running on Qemu,
POSIX, or SMP targets.
We are using CLOCK_REALTIME for this test, which incurs an
additional syscall overhead above CLOCK_MONOTONIC. The act
of sleeping itself also incurs a syscall overhead.
The latency from one iteration to the next of the internal
loop is a bit of a random process due to scheduler or clock
noise (although the noise itself is still bounded).
In order to make this test robust against such noise, assert
only on the average time from one iteration to the next,
rather than the instantaneous time.
Rather than calculating a sample mean, use a running average
(aka Cumulative Moving Average) to save some bytes.
Report results, including low and high watermarks before
asserting that the average iteration time within expected
range.
==============================================================
START - test_realtime
I: n: 20, sleep: 100, margin: 10, lo: 110, avg: 110, hi: 110
PASS - test_realtime in 2.198 seconds
==============================================================
Expect to see the low and high watermarks change more on
Qemu and POSIX platforms when running several jobs in parallel
with twister (such as in CI).
Signed-off-by: Christopher Friedt <cfriedt@meta.com>
We try to implement Zephyr's POSIX API as regular library
functions, so remove the __syscall annotation from
clock_gettime() and implement the syscall portion of it under
the hood.
This also adds a bit of a micro-optimization in that
we can do a lot of processing outside of the system call.
In fact, processing CLOCK_MONOTONIC likely does not
require any syscall other than k_uptime_ticks().
Signed-off-by: Christopher Friedt <cfriedt@meta.com>
The clock_settime() function should not accept an input timespec
with nanosecond values < 0 or >= NSEC_PER_SEC.
Signed-off-by: Christopher Friedt <cfriedt@meta.com>
Add tests for the following two macros
* ARRAY_FOR_EACH(array, idx_var)
* ARRAY_FOR_EACH_PTR(array, ptr_var)
Signed-off-by: Christopher Friedt <cfriedt@meta.com>
AFAIK, we do not have array for-each loops. Seemed like an
obvious gap to fill, so introduce two variants:
* ARRAY_FOR_EACH(array, idx_var)
* ARRAY_FOR_EACH_PTR(array, ptr_var)
Signed-off-by: Christopher Friedt <cfriedt@meta.com>
Update description of board_runner_args() function so that it is
described that app_set_runner_args macro must be defined before the call
to `find_package(Zephyr)`.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
We would drop the received packet if the source address is our
address so tweak the test and make source address different.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
We would drop the received packet if the source address is our
address so tweak the test and make source address different.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Add after() function for the test suite, which does cleanup on still
open sockets. Otherwise, an individual test case failure affects all
other test cases, blurring the test suite results.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
DTLS socket is not really connection-less as UDP, as it required the
DTLS handshake to take place before the socket is usable. Therefore,
align the DTLS connect() behavior with regular TLS.
The change is backward compatible. connect() call is still optional for
DTLS socket (the handshake can still take place from send()/recv()) and
a socket option was provided to disable DTLS handshake on connect().
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
When using DTLS socket, the application may choose to monitor socket
with poll() before handshake has been complete. This could lead to
potential crash (as the TLS context may have been left uninitialized)
and unexpected POLLIN reports (while handshake was still not complete).
This commit fixes the above - POLLIN will only be reported once
handshake is complete and data is available
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
In case a socket error was caused by TLS layer, it was not reported with
POLLERR. This commit fixes this.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
In case TLS session is closed at the TLS level (and thus recv() reports
0 to the application) a certain race occurs between consecutive recv()
call, and TCP session teardown. As mbedtls_ssl_read() only reports
session close upon receiving CLOSE alert, consecutive non-blocking
recv() calls would report EAGAIN instead of connection closed, if called
before underlying TCP connection was closed.
Fix this, by storing the information that TLS session has ended at TLS
socket level. The new flag will be checked before attempting further
mbed TLS actions, so that connection status is reported correctly.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
HDA DMA driver uses an excessive value of 128 bytes as required alignment
for DMA buffer size. This may result in the correct buffer size (e.g.
32-byte aligned, which is DT-compliant) being silently truncated before
writing it into DGBS register. This patch changes the requirement to the
value implied by DGBS register format (effectively reduces to 16 bytes).
Signed-off-by: Tomasz Lissowski <tomasz.lissowski@intel.com>
The setting of initial state in handled by the common driver,
which calls the enable function for any regulator that has
regulator-boot-on set, and is not already enabled.
Signed-off-by: Andy Sinclair <andy.sinclair@nordicsemi.no>
The CMUX resync mechanism can get stuck between states
MODEM_CMUX_RECEIVE_STATE_RESYNC_0 and
MODEM_CMUX_RECEIVE_STATE_RESYNC_1 if the resync flags, which are
sent only once in state MODEM_CMUX_RECEIVE_STATE_SOF, are not
responded to, or the response is lost.
This patch ensures resync flags are sent from states
MODEM_CMUX_RECEIVE_STATE_SOF, MODEM_CMUX_RECEIVE_STATE_RESYNC_1
and MODEM_CMUX_RECEIVE_STATE_RESYNC_2 if its determined that the
resync flags are not being responded to.
Signed-off-by: Bjarki Arge Andreasen <bjarki@arge-andreasen.me>
The chat module contains an array of three lists of matches,
one of which are static, two of which are contained within the
currently running script. The current match, which is an
object stored in one of the three lists, is stored in its own
pointer in the chat module context.
A memory error occurs when the script is stopped, while the
chat module is using one of the matches stored withing the
script. This commit clears the match pointer when the script
is stopped if the match is stored within the script.
Signed-off-by: Bjarki Arge Andreasen <bjarki@arge-andreasen.me>
The device_runtime header includes references to struct device
and k_timeout_t, but only zephyr/device.h is included. k_timeout_t
is in zephyr/kernel, so it must also be included.
Signed-off-by: Bjarki Arge Andreasen <bjarki@arge-andreasen.me>
When not using 4 channel capture, overflows were never reported
to the application, because the check was in the
four_channel_capture_support branch.
Signed-off-by: Fabian Pflug <fabian.pflug@grandcentrix.net>
If we receive a IPv4 packet to v4 mapped address, the relevant
net_context is bound to IPv6. This causes issues if we try
to get the family from the context struct in sendto.
Fix this by checking if the destination address is IPv4 but
the socket is bound to IPv6 and v4 mapping is enabled.
If all these criterias are set, then set the family of the
packet separately and do not get it from net_context.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Clearify the sec parameter in the documentation of bt_conn_set_security.
This should make the API documentation easier to understand.
Signed-off-by: Jan Müller <jan.mueller@nordicsemi.no>
Check the return values from the I2C API functions called in init() and
fail driver initialization if unsuccessful.
Fixes: #66827
Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
The QCCID handler is Quectel specific and as such may not be part
of the modem cellular driver which only supports commands defined
in 3GPP TS 27.007
Signed-off-by: Bjarki Arge Andreasen <bjarki@arge-andreasen.me>
The modem_cellular.c driver now uses a common script to get
signal strenght, which is run on demand. This is more efficient
than polling it, and simpler since every modem doesn't have to
define their own variant of the script.
Additionally, the CSQ handler now stores the "raw" rssi value
returned from AT+CSQ to be parsed by the cellular_modem_get_signal
implementation.
Signed-off-by: Bjarki Arge Andreasen <bjarki@arge-andreasen.me>
Move the implementations of the cellular API in modem_cellular.c
to an cellular_driver_structure, and implement this API structure
withing the device drivers.
Signed-off-by: Bjarki Arge Andreasen <bjarki@arge-andreasen.me>
The current cellular API header is not written to conform with
the device driver model. This commit fixes that.
Signed-off-by: Bjarki Arge Andreasen <bjarki@arge-andreasen.me>
In Passive Receive mode, ESP modem will buffer rx data.
This fix makes the data still available to user,
even though the peer has closed the socket.
Otherwise, user will fail to get the last rx data,
when the socket is closed by the peer.
Signed-off-by: Chun-Chieh Li <ccli8@nuvoton.com>
After a call to k_work_flush returns the sync variable
may still be modified by the workq. This is because
the work queue thread continues to modify the flag in
sync even after k_work_flush returns. This commit adds
K_WORK_FLUSHING_BIT, and with this bit, we moved the
logic of waking up the caller from handle_flush to the
finalize_flush_locked in workq, so that after waking up
the caller, the workqueue will no longer operate on sync.
Fixes: #64530
Signed-off-by: Junfan Song <sjf221100@gmail.com>
Added CRC4 and CRC4_TI to the supported crc_types[] array.
On some SoCs, like ESP32-S3, missing values can cause hardfaults
due to attempts to access the zero address.
Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
Make sure iovec is initialized to a value so that there
is no possibility that it is accessed uninitialized.
Fixes: #66838
Coverity-CID: 334911
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
The original idea was to check that we have enough network
interfaces in the system. The check needs to verify max IPv4
and IPv6 supported interfaces instead of always checking
IPv6 one.
Fixes: #66843
Coverity-CID: 334899
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Removes deprecated boards that were added in/before September
2021, which would be prior to the release of Zephyr 2.7.
Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
This commit adds a new Kconfig for the nRF 802.15.4 radio driver that
allows the user to specify the number of encryption keys the driver can
simultaneously store.
Signed-off-by: Jędrzej Ciupis <jedrzej.ciupis@nordicsemi.no>
There are multiple Kconfig symbols that are only available when the
radio hardware is present. As a result, the nRF 802.15.4 radio driver
is more difficult to configure on multicore architectures. Also, such
solution goes against the principle of hiding the details of the
platform behind the driver's interface.
This commit moves all the Kconfig options that correspond to settings
present in common nRF 802.15.4 configuration header so that they're
available no matter if the API is serialized.
Signed-off-by: Jędrzej Ciupis <jedrzej.ciupis@nordicsemi.no>
Don't execute `irq_enable` in process of the `ra_icu_irq_connect_dynamic`.
The caller of `ra_icu_irq_connect_dynamic` is only `gpio_ra_pin_configure`
at this time. `gpio_ra_pin_configure` calls `irq_enable` just after called
`ra_icu_irq_connect_dynamic`.
So removing 'irq_enable' from 'ra_icu_irq_connect_dynamic' has no effect
on behavior.
Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@fujitsu.com>