linux-kernelserial-portlinux-device-driverandroid-kernel

Interact with virtual serial device in polling mode in linux C


I'm trying to enable polling support for a serial over USB driver on an android kernel, so that I can debug it using kgdboc. I based myself on the code from these githubs:

However, I can't find a way to enable and use char by char polling mode via a C program on userland. Which makes debugging very difficult, since the only thing I can do is to set kgdboc to /dev/ttyGS0 and then send "g" to sysrq-trigger, and pray it works.

In other terms, I need a userland program that triggers the code path which reaches the following operations on the tty_operations structure:

.poll_init = gs_poll_init,
.poll_get_char = gs_poll_get_char,
.poll_put_char = gs_poll_put_char,

Instead, whenever I write to /dev/ttyGS0 I trigger the "write" operation.

Any help will be greatly appreciated.

Thanks!


Solution

  • I ended up creating a driver that exports a sysfs node as Chris Stratton suggested.

    I based myself on this tutorial