文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>arm板 释放ttyS0作为通信串口(关闭调试串口)(..

arm板 释放ttyS0作为通信串口(关闭调试串口)(..

时间:2010-07-02  来源:xiaoshou330

释放ttyS0作为通信串口

#include <sys/ioctl.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <fcntl.h>
#include <termios.h>
#include <errno.h>
void CloseConsole(void) {

int fp;
struct termios options;
printf("change1\n");
fp = open("/dev/tty1",O_RDONLY); // 改变console
ioctl(fp,TIOCCONS);
close(fp);

fp = open("/dev/tts/0",O_RDWR|O_NOCTTY|O_NDELAY); //打开串口0读写
if(fp == -1) exit(0);
tcgetattr(fp,&options);
cfsetispeed(&options,B115200);
cfsetospeed(&options,B115200);
options.c_cflag |= (CLOCAL|CREAD);
tcsetattr(fp,TCSANOW,&options);
write(fp,"hello world!\n123",15);
close(fp);                       //关闭串口0

fp = open("/dev/tty0",O_RDONLY); //恢复console 到串口0
ioctl(fp,TIOCCONS);
close(fp);
printf("change2\n");
}

关于关闭SHELL对串口的占用,使之能做普通的串口通信和拨号

1、步骤:
在内核编译过程中执行make menuconfig
Character devices --->
Serial drivers --->

S3C2410 serial port support
[ ] Console on S3C2410 serial port 【注】去掉这项即可,不必修改busybox/init.c了
< > 8250/16550 and compatible serial support (EXPERIMENTAL)
2、备注:
这样就不能用ttyS0口来登录ARM开发板了,你可以选择用TELNET的方式来登录。
做法:telnet 192.168.0.12(你的开发板的IP地址)
         输入:“root”用户名就可以进入你的开发板了
3、OK..

相关阅读 更多 +
排行榜 更多 +
<img preview="http://pic.pdowncc.com/uploadimg/ico/2025/0523/1747993424374100.png" width="32" height="32" src="http://pic.pdowncc.com/uploadimg/ico/2025/0523/1747993424374100.png" alt="弓箭勇者最新版" />

<img preview="http://pic.pdowncc.com/uploadimg/ico/2025/0523/1747993424374100.png" width="32" height="32" src="http://pic.pdowncc.com/uploadimg/ico/2025/0523/1747993424374100.png" alt="弓箭勇者最新版" />

飞行射击 下载
<img preview="http://pic.pdowncc.com/uploadimg/ico/2025/0523/1747993424374100.png" width="32" height="32" src="http://pic.pdowncc.com/uploadimg/ico/2025/0523/1747993424374100.png" alt="弓箭勇者最新版" />

<img preview="http://pic.pdowncc.com/uploadimg/ico/2025/0523/1747993424374100.png" width="32" height="32" src="http://pic.pdowncc.com/uploadimg/ico/2025/0523/1747993424374100.png" alt="弓箭勇者最新版" />

飞行射击 下载
<img preview="http://pic.pdowncc.com/uploadimg/ico/2025/0523/1747993424374100.png" width="32" height="32" src="http://pic.pdowncc.com/uploadimg/ico/2025/0523/1747993424374100.png" alt="弓箭勇者最新版" />

<img preview="http://pic.pdowncc.com/uploadimg/ico/2025/0523/1747993424374100.png" width="32" height="32" src="http://pic.pdowncc.com/uploadimg/ico/2025/0523/1747993424374100.png" alt="弓箭勇者最新版" />

飞行射击 下载