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

Linux下串口编程之二:读串口和写串口

1,打开串口
      /**打开串口,dev 串口设备名, mode 打开方式,**/
     int opendev(char *dev,mode_t mode)
    {
          int fd;
          fd = open(dev, mode);
          if (-1 == fd){   
                perror("Can't Open Serial Port");
                return -1; 
          }
          else{
                 fcntl(fd, F_SETFL, FNDELAY);
                 return fd;
          }
     }
2,写串口
    #define FALSE  -1
    #define TRUE   0
    #define NET_PORT 19988
    #define MAX_BUF_SIZE 4096
    struct net2net_buf{
           int len;
           char buf[MAX_BUF_SIZE];
     };
     #define RSDEV_NAME "/dev/ttyS1"
     int main(void)
     {
            int rsfd = 0;
            int nwrite;
            char input_buf[64];
            rsfd = opendev(RSDEV_NAME,O_RDWR | O_NOCTTY |


相关文档:

Linux GCC make文件的写法 总结版

目录结构为:
inc/hello.h
src/hello.c
main/main.c
Makefile
文件内容为:
hello.h:
void hello(char name[]);

hello.c:
#include <stdio.h>
void hello(char name[])
{
printf("Hello %s!\n", name);
}

main.c:
#include <stdio.h>
#include "hello.h"
// The second hello.h should ......

linux下mysql编译安装方法备忘

# tar -zxvf mysql-5.0.45.tar.gz -C /usr/src/
# cd /usr/src/mysql-5.0.45
# ./configure --prefix=/usr/local/mysql --with-charset=gbk
--localstatedir=/usr/local/mysql/data
# make
# make install
# groupadd mysql
# useradd mysql -g mysql
# cd /usr/local/mysql/bin
# ./mysql_install_db --user=mys ......

linux命令


< type="text/javascript"><!--
google_ad_client = "pub-3936520987820628";
//250x250, 创建于 07-12-28
google_ad_slot = "5080959190";
google_ad_width = 250;
google_ad_height = 250;
//-->
< src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javasc ......

Linux下串口编程之一:基础设置函数

1,串口操作需要的头文件
  #include   <stdio.h>   /* 标准输入输出定义 */
  #include   <stdlib.h>   /* 标准函数库定义 */
  #include   <unistd.h>   /* Unix 标准函数定义 */
  #include   <sys/types.h> 
  #include   <sys/stat.h> 
  #incl ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号