易截截图软件、单文件、免安装、纯绿色、仅160KB

linux基本驱动和linux字符设备驱动

 先粘贴一个linux最简单的驱动,其实对于一个从2.4玩上来的人来说,驱动不复杂,比较不习惯的是那个makefile
驱动本身:
hello.c:
#include <linux/init.h>
#include <linux/module.h>
#include <linux/kernel.h>
MODULE_LICENSE("Dual BSD/GPL");
static int hello_init(vodi){
    printk(KERN_ALERT "hello world\n");
    return 0;
}
static void hello_exit(vodi){
    printk(KERN_ALERT"bye bye\n");
}
module_init(hello_init);
module_exit(hello_exit);
Makefile:
obj-m := hello.o
KERNELDIR :=/lib/modules/$(shell uname -r)/build
all:
    make -C $(KERNELDIR) M=$(shell pwd) modules
clean:
    rm -rf *.o *.ko
然后附过来一个驱动,暂时没有验证,是字符型的,如果验证好用,我再更新这篇日志
本例是冯国进的 《嵌入式Linux 驱动程序设计从入门到精通》的第一个例子
感觉真是好书   强烈推荐
注释是deep_pro加的 转载请注明!我的特点是文不加点!
这个驱动是在内存中分配一个256字节的空间,供用户态应用程序读写。
先是头文件 demo.h
#ifndef _DEMO_H_
#define _DEMO_H_
#include <linux/ioctl.h> /* needed for the _IOW etc stuff used later */
/********************************************************
* Macros to help debugging
********************************************************/
#undef PDEBUG             /* undef it, just in case */
#ifdef DEMO_DEBUG
#ifdef __KERNEL__
#    define PDEBUG(fmt, args...) printk( KERN_DEBUG "DEMO: " fmt, ## args)
#else//usr space
#    define PDEBUG(fmt, args...) fprintf(stderr, fmt, ## args)
#endif
#else
# define PDEBUG(fmt, args...) /* not debugging: nothing */
#endif
#undef PDEBUGG
#define PDEBUGG(fmt, args...) /* nothing: it's a placeholder */
//设备号
#define DEMO_MAJOR 224
#define DEMO_MINOR 0
#define COMMAND1 1
#define COMMAND2 2
//自己定义的设备结构
struct DEMO_dev
{
    struct cdev cdev;    /* Char de


相关文档:

实战Linux Bluetooth编程(六) L2CAP编程实例

例一:发送Signaling Packet:
Signaling Command是2个Bluetooth实体之间的L2CAP层命令传输。所以得Signaling Command使用CID 0x0001.
多个Command可以在一个C-frame(control frame)中发送。
 如果要直接发送Signaling Command.需要建立SOCK_RAW类型的L2CAP连接Socket。这样才有机会自己填充Command Code,Identi ......

Linux 防火墙开关命令

 1) 永久性生效,重启后不会复原
开启: chkconfig iptables on
关闭: chkconfig iptables off
2) 即时生效,重启后复原
开启: service iptables start
关闭: service iptables stop
开启和关闭端口相关配置文件
/etc/sysconfig/iptables ......

linux做网管

echo "1" > /proc/sys/net/ipv4/ip_forward
modprobe ip_tables
modprobe ip_nat_ftp
modprobe ip_nat_irc
modprobe ip_conntrack
modprobe ip_conntrack_ftp
modprobe ip_conntrack_irc
iptables -F
iptables -X
iptables -Z
iptables -F -t nat
iptables -X -t nat
iptables -Z -t nat
iptables -P INPUT ......

Linux用户管理

 一.添加用户:
su命令使用root权限
修改/etc/passwd,添加用户记录
pwconv让/etc/passwd和/etc/shadow同步
修改/etc/group
创建用户的主目录,并把用户启动文件夹复制到用户的主目录
cp -R /etc/skel /home/xxj
改变新增用户的属主和权限
chown xxj:xxj /home/xxj
ls -ld /home/xxj
chmod 700 /home/xxj
设 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号