I'm developing a linux kernel module and I need to read data from serial port (characters). I want to set characters (example : 'D' , 'T' and '-') as entries coming from serial port and I want read these entries. I spent a long period trying with "inb(0x3f8)" and "termios" but it didn't work out. However writing data work correctly with "outb" I have Ubuntu 10.10 as System installed as guest on VirtualBox on VBox configuration I set :
activated serial port
port number : COM1 IRQ 4 PORT I/O : 0x3f8
Port/path D:\Oracle\serial.txt
I think if you run in a kernel thread, it is possible to use filp_open, or some other function to gain a file operations pointer, which you can then use "normal" calls on via the file_operations pointer.
This only works if you're running in a "normal" context - of a "user" process or possibly kernel-thread, it definitely won't work correctly if you're in some "unusual" context.
In a normal task, these calls can be blocking, and everything will "just work". I think. I have tried it with sockets and it works.
You might have an issue with mounted filesystems, because kernel threads might get a namespace which contains few (or no) file nodes. This might mean that it's easier to open the device in userspace and pass it through in some way.
Also be aware of the limited stack size in the kernel.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.