-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Driver/sensor: enhance sensor driver to support uorb and multi core access sensor by rpmsg #6653
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Contributor
Author
|
@jihandong Please push all uorb relate commit to apps, thanks! |
914f894 to
eeeec1c
Compare
Contributor
Author
|
This PR apache/nuttx-apps#1228 need merge to fix ci issue: we can test sensor driver by uorb_listener, example: |
Contributor
Author
|
uorb PR:apache/nuttx-apps#1230 |
Contributor
|
@Donny9 the PR is too large, could you split the unrelated patch to the new PR? |
This was referenced Jul 25, 2022
Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
If enable SNIOC_READLAST, sensor_read will return 0 when there is no new data until last read. Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
…lock Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
using recursive mutex to fix this issue. Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
CHAMPION-6418 rptun sensor: [ap] [ 5] [<0x2c352c68>] arm_switchcontext+0xc/0x10 [ap] [ 5] [<0x2c322eae>] sem_wait+0x5a/0xbc [ap] [ 5] [<0x2c3376cc>] sensor_rpmsg_find_dev+0x8/0x78 (wait g_lock) [ap] [ 5] [<0x2c338d96>] sensor_rpmsg_suback_handler+0xa/0x4c [ap] [ 5] [<0x2c7630f6>] rpmsg_virtio_rx_callback+0xba/0x1b4 [ap] [ 5] [<0x2c762788>] rproc_virtio_notified+0x44/0x5c [ap] [ 5] [<0x2c762154>] remoteproc_get_notification+0x1c/0x2c [ap] [ 5] [<0x2c335576>] rptun_thread+0x6e/0x164 [ap] [ 5] [<0x2c324aba>] nxtask_start+0x3a/0x60 apps:(note: ipc buffer is busy, it's not enough for dual core.) [ap] [26] [<0x2c323a5e>] nxsig_timedwait+0x8a/0x184 [ap] [26] [<0x2c324344>] nxsig_nanosleep+0x34/0xa4 [ap] [26] [<0x2c324446>] nxsig_usleep+0x26/0x38 [ap] [26] [<0x2c76338e>] rpmsg_virtio_get_tx_payload_buffer+0x5e/0x100 (wait ipc buffer) [ap] [26] [<0x2c33775a>] sensor_rpmsg_advsub_one+0x1e/0xdc (get g_lock) [ap] [26] [<0x2c338312>] sensor_rpmsg_open+0xee/0x178 [ap] [26] [<0x2c3365bc>] sensor_open+0x50/0x234 [ap] [26] [<0x2c749cb8>] open+0xc8/0x194 [ap] [26] [<0x2c375324>] orb_subscribe_multi+0x1c/0x94 Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
note: replace dev lock by upper driver lock rptun: sem_wait sched/semaphore/sem_wait.c:273 nxmutex_lock /home/neo/projects/monkey/nuttx/include/nuttx/mutex.h:161 sensor_close (wait upper driver lock) drivers/sensors/sensor.c:509 sensor_rpmsg_free_stub (get dev lock) drivers/sensors/sensor_rpmsg.c:546 sensor_rpmsg_unsub_handler drivers/sensors/sensor_rpmsg.c:1025 rptun_thread apps: sem_wait sched/semaphore/sem_wait.c:273 sensor_rpmsg_close (wait dev lock) drivers/sensors/sensor_rpmsg.c:613 sensor_close (get upper driver lock) drivers/sensors/sensor.c:512 Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
Signed-off-by: jihandong <jihandong@xiaomi.com>
Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
1. about interval:
If interval is not set, generation is increased by 1 along with
publish and copy, multi-copy is continuous.
If interval is set, pick proper samples from buffer based on
mainline/user generation, multi-copy is one-by-one.
2. about bufferpos:
user->bufferpos always point to next position to check.
data user last read
----------v--------------------------
| | | |
-------------------^-----------------
bufferpos
If buffer is full, bufferpos point to buffer.head
Examples:
If a buffer contains 4 samples, newest generatoin is 40.
-------------------------------------
|10 |20 |30 |40
------------------------------^------
|
if user's next generation is 42, notify user to copy No.40 sample,
because 42 is closer to 40 than 50.
-------------------------------------
|10 |20 |30 |40
----------------------------------^--
|
if user's next generation is 48, do not notify user,
because 48 is closer to 50, which is next mainline sample.
Signed-off-by: jihandong <jihandong@xiaomi.com>
Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
task1: nuttx/arch/arm/src/common/arm_blocktask.c:151 nxsem_wait nuttx/arch/arm/src/../../../sched/semaphore/sem_wait.c:155 (discriminator 2) sem_wait nuttx/arch/arm/src/../../../sched/semaphore/sem_wait.c:273 nxmutex_lock.lto_priv.2 nuttx/include/nuttx/mutex.h:161 sensor_rpmsg_push_event_one nuttx/arch/arm/src/../../../drivers/sensors/sensor_rpmsg.c:748 up_unblock_task nuttx/arch/arm/src/common/arm_unblocktask.c:75 (discriminator 2) sensor_rpmsg_push_event nuttx/arch/arm/src/../../../drivers/sensors/sensor_rpmsg.c:858 write orb_publish_multi nuttx/arch/arm/src/../../../../apps/system/uorb/uORB/uORB.c:188 task2: nxrmutex_lock.isra.0 sensor_read nuttx/arch/arm/src/../../../drivers/sensors/sensor.c:753 sem_post nuttx/arch/arm/src/../../../sched/semaphore/sem_post.c:224 nxmutex_unlock.lto_priv.1 nuttx/include/nuttx/mutex.h:259 sensor_rpmsg_push_event_one nuttx/arch/arm/src/../../../drivers/sensors/sensor_rpmsg.c:787 nxmutex_unlock.lto_priv.1 nuttx/include/nuttx/mutex.h:259 nuttx/arch/arm/src/../../../drivers/sensors/sensor.c:969 sensor_rpmsg_alloc_stub nuttx/arch/arm/src/../../../drivers/sensors/sensor_rpmsg.c:549 sensor_rpmsg_advack_handler Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
xiaoxiang781216
approved these changes
Jul 31, 2022
pkarashchenko
approved these changes
Aug 1, 2022
Merged
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Driver/sensor enhance feature:
Refer to:
https://docs.px4.io/v1.12/en/middleware/uorb.html
Impact
Testing
Vela team CI and unit test.