请选择 进入手机版 | 继续访问电脑版

智能创客,中国最大的极客空间,智能平台,免费教学,视频教程,手把手教你创造儿时梦想!

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
热搜: 活动 交友 discuz
查看: 12517|回复: 28

wiringpi教程5 读串口serialRead.c

  [复制链接]

110

主题

396

帖子

2329

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
2329
QQ
发表于 2014-2-11 12:02:29 | 显示全部楼层 |阅读模式
/*
* serialRead.c:
*    Example program to read bytes from the Serial line
*
*/

#include <stdio.h>
#include <string.h>
#include <errno.h>

#include <wiringSerial.h>

int main ()
{
  int fd ;
//看解释
//int serialOpen (char *device, int baud) ;
//This opens and initialises the serial device and sets the baud rate. It sets the port into “raw” mode //(character at a time and no translations), and sets the read timeout to 10 seconds. The return value is the file //descriptor or -1 for any error, in which case errno will be set as appropriate
// 没有接到设备就是-1 超时为10秒

  if ((fd = serialOpen ("/dev/ttyAMA0", 115200)) < 0)
  {
    fprintf (stderr, "Unable to open serial device: %s\n", strerror (errno)) ;
    return 1 ;
  }

// Loop, getting and printing characters

  for (;;)
  {
//
//int serialGetchar (int fd) ;

//Returns the next character available on the serial device. This call will block for up to 10 seconds if no data //is available (when it will return -1)

    putchar (serialGetchar (fd)) ;
    fflush (stdout) ;
  }
}

回复

使用道具 举报

0

主题

10

帖子

162

积分

注册会员

Rank: 2

积分
162
发表于 2015-1-21 22:26:51 | 显示全部楼层
好帖要顶,楼主的头像还是不错滴
回复 支持 反对

使用道具 举报

0

主题

5

帖子

38

积分

禁止发言

积分
38
发表于 2015-10-9 08:06:50 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
回复 支持 反对

使用道具 举报

0

主题

152

帖子

384

积分

禁止发言

积分
384
发表于 2015-10-31 15:18:42 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
回复 支持 反对

使用道具 举报

0

主题

152

帖子

384

积分

禁止发言

积分
384
发表于 2015-11-20 09:20:05 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
回复 支持 反对

使用道具 举报

0

主题

42

帖子

150

积分

注册会员

Rank: 2

积分
150
发表于 2015-12-29 00:59:20 | 显示全部楼层
顶.支持,路过!












回复 支持 反对

使用道具 举报

0

主题

0

帖子

1

积分

新手上路

Rank: 1

积分
1
发表于 2016-1-17 00:53:30 | 显示全部楼层
走淘宝虽然慢一些 客服很耐心讲解流程并指导作! 不错诚信商家
回复 支持 反对

使用道具 举报

0

主题

42

帖子

150

积分

注册会员

Rank: 2

积分
150
发表于 2016-1-22 00:33:17 | 显示全部楼层
支持一下吧












回复 支持 反对

使用道具 举报

0

主题

8

帖子

30

积分

新手上路

Rank: 1

积分
30
发表于 2016-2-4 20:30:38 | 显示全部楼层
辛苦辛苦,谢谢了~~
回复 支持 反对

使用道具 举报

0

主题

42

帖子

256

积分

中级会员

Rank: 3Rank: 3

积分
256
发表于 2016-2-9 23:04:23 | 显示全部楼层
看帖子的都发表一下看法












回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|小黑屋|手机版|智能创客 ( 桂ICP备14000828号

GMT+8, 2024-4-19 00:09 , Processed in 0.104627 second(s), 26 queries .

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表