資源簡介
Linux下串口數據發送程序,已調試通過。
代碼片段和文件信息
/*******************************************************
*?File?Name:?send.c
*?Description:?send?data?to?serial_Port
*?Date:
*******************************************************/
/******************頭文件定義******************/
#include?
#include?
#include?
#include?
#include?
#include?
#include?
#include?
#define?BUFFER_SIZE?500
/*******************************************/
int?fd;?/*定義設備文件描述符*/
int?open_serial(int?k)
{
if(k==0)?/*串口選擇*/
{
fd?=?open(“/dev/ttyS0“O_RDWR|O_NOCTTY);?/*讀寫方式打開串口*/
perror(“open?/dev/ttyS0“);
}
else
{
fd?=?open(“/dev/ttyS1“O_RDWR|O_NOCTTY);
perror(“open?/dev/ttyS1“);
}
if(fd?==?-1)?/*打開失敗*/
return?-1;
else
return?0;
}
/********************************************************************/
int?main(int?argc?char?*argv[?]?)
{
char?buff[BUFFER
- 上一篇:將卷積運算轉換成矩陣相乘
- 下一篇:塔防游戲源碼
評論
共有 條評論