小编ald*_*pha的帖子

串口挂起close()

我开发了这个简单的内核模块,它通过使用FIFO队列和定时器来模拟串行端口(从硬件读取:从队列中读出,写入硬件:插入队列中).
源代码如下所示.

  #include <linux/kernel.h>
  #include <linux/errno.h>
  #include <linux/init.h>
  #include <linux/slab.h>
  #include <linux/tty.h>
  #include <linux/tty_flip.h>
  #include <linux/serial.h>
  #include <linux/serial_core.h>
  #include <linux/module.h>


  #define TINY_SERIAL_DEBUG
  #define pr_fmt(fmt) "tiny_serial: " fmt

  #if defined(TINY_SERIAL_DEBUG)
  #define DBG(fmt, ...)  printk(KERN_ALERT pr_fmt(fmt), ##__VA_ARGS__)
  #else 
  #define DBG(fmt, ...)  no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)   
  #endif

  #define DRIVER_AUTHOR "Me Me <me@me.com>"
  #define DRIVER_DESC "Tiny serial driver"

  /* Module information */
  MODULE_AUTHOR( DRIVER_AUTHOR );
  MODULE_DESCRIPTION( DRIVER_DESC );
  MODULE_LICENSE("GPL");

  #define DELAY_TIME        100// HZ * 2    /* 2 seconds per character */
  #define TINY_DATA_CHARACTER    't'

  #define …
Run Code Online (Sandbox Code Playgroud)

c linux serial-port linux-device-driver linux-kernel

5
推荐指数
1
解决办法
152
查看次数