linux串口编程
linux串口编程(要点总结) 收藏
串口编程
查询硬件的方式:查询方式、中断方式、DMA方式。串口很多是使用中断方式,这种方式一般来讲对CPU比较有效。
UART的操作主要包括以下几个部分:
数据发送;数据接受;产生中断;产生波特率;Loopback模式;红外模式;自动流控模式;
串口参数的配置主要包括:波特率、数据位、停止位、流控协议。
在linux下操作串口与操作文件相同。
在使用串口之前必须设置相关配置,包括:波特率、数据位、校验位、停止位等。串口设置由下面结构体实现。
Struct termios{
tcflag_t c_iflag; /* input flags */
tcflag_t c_oflag; /* output flags */
tcflag_t c_cflag; /* control flags */
tcflag_t c_lflag; /* local flags */
cc_t c_cc[NCCS]; /* control character */
};
串口配置流程
1、保存原先串口配置,使用tcgetattr(fd,&oldtio)函数
struct termios newtio,oldtio;
tcgetattr(fd,&oldtio);
2、激活选项,有CLOCAL 和CREAD,用于本地连接和接收使能。
newtio.c_cflag |= CLOCAL | CREAD
3、设置波特率,使用函数cfsetispeed、cfsetospeed。
cfsetipeed(&newtio, B115200);
cfsetospeed(&newtio, B115
相关文档:
方法一: Expect 实现交互
UNIX 窗口中 输入以下命令:
expect ftplinux.txt 10.0.15.22 ftplinux.txt
ftplinux.txt 中内容如下:
--开始-----
spawn ftp [lindex $argv 0]
expect "Name(*):"
send "ftp\r"
expect "Password:*"
send "hell05a\r"
expect "ftp> ......
Name
hosts - The static table lookup for host names
Synopsis
/etc/hosts
Description
This manual page describes the format of the /etc/hosts
file. This file is a simple text file that
associates IP addresses with hostnames, one line per IP address. For
each host a single line should be presen ......
shell语法(五项)
1.命令格式
2.通配符
3.重定向
4.管道
5.shell中的引用
6.自动补齐命令行
系统管理维护
ls
pwd
cd
date
passwd
su
clear
man
who
w
uname
uptime
last
dmesg
free
ps
top
文件管理编辑
mkdir
more
cat
diff
grep
rm
touch
ln
file
cp
find
split
mv
压缩解压
zi ......
1,显著影响系统性能的4种资源
(1),CPU时间
(2),内存
(3),硬盘I/O
(4),网络I/O
2,分析CPU使用情况
使用vmstat采集CPU的性能瓶颈
[root@local]# vmstat 2
procs -----------memory---------- ---swap-- -----io-- ......
最近对Linux的线程接口进行了些总结,也参考了网络上兄弟们的一些资料,自己同时也写了些程序进行测试,先把参考的
资料列出来吧
http://blog.mcuol.com/User/liuzhilii521/Article/12738_1.htm
下面是我的一些理解:
pthread_key_create(pthread_key_t *key,void (*destructor)(void*))
destructor这个回调函数在线程 ......