1

i want to send and receive data from/to an arduino connected to a /dev/ttyUSB port (serial) from a kernel module. i have seen enough ways how to do it in userspace, but that's not my question.

it would really help to be able to access a tty by major and minor numbers (188, 0 for /dev/ttyUSB0) as i dont want to use file io in a kernel module

related but didnt answer my question:

How to write to a tty from kernel space with only major and minor device numbers available? (1 answer but uses userspace)

Access /dev/ttyACM0 from kernel (no answers yet)

How can I write to TTY from a kernel module? (1 answer but how to get the struct tty_struct from a serial port?)

Read and write to Arduino serial using a kernel module (1 answer but uses file io and alternative is too vague)

https://unix.stackexchange.com/questions/585573/how-does-serial-driver-get-attached-to-a-tty-port (no answers yet)

gre_gor
  • 6,669
  • 9
  • 47
  • 52
Antoni
  • 356
  • 5
  • 17
  • You need to use in-kernel APIs, otherwise why not to do it in user space? – 0andriy Mar 15 '22 at 09:42
  • "i have seen enough ways how to do it in userspace, but that's not my question." – Antoni Mar 15 '22 at 15:46
  • i want to do it 100% in kernel space – Antoni Mar 15 '22 at 15:47
  • Write a driver and bind it to a corresponding serdev. If there is no serdev, try to find if ACM has any in-kernel APIs, if not, you need to develop them. Opening a file, esp. for a hotpluggable device is an utterly wrong approach. – 0andriy Mar 15 '22 at 16:05

1 Answers1

0

SappyInsane on linuxquestions had the same problem and gave me his solution which worked https://www.linuxquestions.org/questions/linux-kernel-70/reading-from-arduino-serial-in-a-kernel-module-4175704822/

Antoni
  • 356
  • 5
  • 17