LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   opening a serial device from a module (https://www.linuxquestions.org/questions/programming-9/opening-a-serial-device-from-a-module-210/)

norsk 10-25-2000 03:32 PM

I have a project I am working on, where we use a serial port (/dev/ttyS0) to communicate with our real device. Hence the serial port is simply a "bus driver" for the module. I have it working in user mode using standard open/read/write system calls. Now I am in the process of moving the upper driver into the kernel via a module, but I still need to use the serial driver as a bus driver to access my device.

The question is: How do I "open/read/write" the serial from the module. One of my leads is using filp_open(..), get the file * and use the read/write, etc structure methods from there. Is this the best way? or is there another operation I can use to get to the serial device?

I need to configure it to RAW mode, use hardware handshake if available. Pointers greatly appreciated.

thanks
doug



jeremy 10-28-2000 11:56 AM

I believe the answer is ioctl. More information is available here - http://howto.tucows.com/LDP/LDP/lkmpg/node18.html.

norsk 10-28-2000 10:11 PM

open serial device from within a MODULE
 
Thanks jeremy,

but my module will not be a user program where I can open a serial device with the char device name ("/dev/ttyS1"). Rather as a module, I will already in the kernel and cannot use the glibc system call mechanism. It does the user mode to kernel mode transition. My code is already in the kernel, I just don't know the mechansim under linux to "hook" into the "open" path of another device also in the kernel.

Hence, my investigation indicates using the aforemention filp_open call. I need to play with this shortly. I was just wondering if others have tried something like this prior to myself doing it.

again thanks for the post



All times are GMT -5. The time now is 01:09 PM.