1

I'm trying to describe my problem from the beginning. I'm a newbie in linux diver development, so please point out my problems about my consideration in my project.

I'm now developing a linux driver for a modem, but not a typical one. I hope it can work as a net adapter, rather than a modem. It is connected with computer with serial port. Because of the nature of my problem, I have to use a USB-serial converter. Most of the answer suggest to use a user space driver instead. However, as I want to provide a networking interface like eth0, I have to make it in the kernel. Besides open/read/write ttyUSB0 file, I do not have any other idea solving this problem.

I'm now using code like this

struct file *f; 
mm_segment_t oldfs; 
struct tty_struct *tty; 
struct termios term; 
unsigned char buffer[255]; 

f=filp_open("/dev/ttyS0",O_RDWR | O_NDELAY,0); 
oldfs=getfs(); 
set_fs(KERNEL_DS); 
f->f_pos=0; 
tty=(struct tty_struct*)f->private_data; 

tty->termios->c_flag=B9600 | CRTSCTS | CS8 | CLOCAL | CREAD; 

At this time, tty->termios is NULL, so I can not do the last step. What I do is:

struct ktermio term;
//setting the termio
tty->termios = &term;

And the result of this is that the setting is not applied to the serial port. Even if I change it to a absolutely wrong baud rate, I still receive fragments. Some of them are correct, while some are not. What is the problem, and what should I do.

dsolimano
  • 8,870
  • 3
  • 48
  • 63
Yifan Sun
  • 772
  • 1
  • 10
  • 25
  • I don't think you should start coding on Linux by coding a kernel module. You really should learn and be at ease first with user-level applications. Kernel programming requires a good feeling of the syscalls in Linux, and only user-level application software uses them. – Basile Starynkevitch Sep 30 '12 at 16:19
  • Thank you for your reply. I have made a user space program which is working pretty well now. If I can make a user space drive that can provide socket for other programs, I would be very happy to do so. I just don't know what is the typical solution to my problem. Thanks – Yifan Sun Sep 30 '12 at 16:58
  • The typical solution is a Unix domain socket. – Ignacio Vazquez-Abrams Oct 01 '12 at 06:07
  • I think what you mean is a user space driver. But is it possible to use functions like 'ping' through my network interface? – Yifan Sun Oct 02 '12 at 03:52

0 Answers0