yangsong8-a1 opened a new pull request, #21848:
URL: https://github.com/apache/nuttx/pull/21848
## Summary
- Add optional `start_capture`, `stop_capture` and `get_input_state`
methods to `cap_ops_s`, called by the new `CAPIOC_START_CAPTURE`,
`CAPIOC_STOP_CAPTURE` and `CAPIOC_GET_INPUT_STATE` ioctls (`-ENOSYS`
when the method is NULL).
- Add `CAPIOC_SET_EDGE`, handled by the lower half `ioctl`.
- Unknown commands are passed to the lower half `ioctl` with `arg`
unchanged, and return `-ENOTTY` when the lower half has no `ioctl`.
Before, the upper half called a NULL `ops->ioctl`.
The new commands use `_CAPIOC(12)` to `_CAPIOC(15)`. The last two commits
fix an nxstyle error and document the commands.
## Impact
`cap_register()` always registers one channel, so the value that reaches
the lower half `ioctl` is the same as before; the ESP PCNT, GD32 and N32
lower halves see no change. Lower halves without `ioctl` (STM32, ESP
MCPWM, fake capture) now return `-ENOTTY` for unknown commands instead of
crashing.
## Testing
Ubuntu 22.04, gcc 13.1, arm-none-eabi-gcc 10.3, xtensa-esp32s3-elf-gcc.
| Config | apache/master | This PR |
|---|---|---|
| sim:nsh + CAPTURE, test program with two fake lower halves |
`CAPIOC_PULSES` on a lower half without `ioctl`: segmentation fault |
`-ENOTTY`; new ioctls work, see below |
| nucleo-h743zi:capture, esp32s3-devkit:qencoder | builds | builds, 0
warnings in capture.c, esp_pcnt.c, esp_qencoder.c, stm32_capture*.c |
| nucleo-h563zi:capture | not run | builds, 0 warnings in capture.c,
stm32_capture*.c |
sim, this PR:
```
full PULSES ret=0 pulses=42 arg_same=1
full FILTER(1000) ret=-25 lower got arg=1000
lower ioctl SET_EDGE arg=1
full SET_EDGE ret=0
lower start_capture
full START_CAPTURE ret=0
full GET_INPUT_STATE ret=0 state=1
lower stop_capture
full STOP_CAPTURE ret=0
basic START_CAPTURE ret=-38
basic STOP_CAPTURE ret=-38
basic GET_INPUT_STATE ret=-38
basic PULSES (no ops->ioctl) ret=-25
```
apache/master, same program (without the new ioctls): `full PULSES` and
`full FILTER(1000)` print the same lines, then `hello null` crashes the
simulator.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]