-
大小: 34KB文件类型: .zip金币: 1下载: 0 次发布日期: 2021-06-06
- 语言: 其他
- 标签: linuxcan485
资源简介
通过linux串口usb-can发送指令控制电机,通过usb-485去编码器,usb-can有串口协议帧头0x00 0xe0帧尾0x55
代码片段和文件信息
#include “kbhit.h“
#include
#include
//#include
//#include
#include
//#include
static struct termios initial_settings new_settings;
static int peek_character = -1;
void init_keyboard()
{
tcgetattr(0&initial_settings);
new_settings = initial_settings;
new_settings.c_lflag &= ~ICANON;
new_settings.c_lflag &= ~ECHO;
new_settings.c_lflag &= ~ISIG;
new_settings.c_cc[VMIN] = 1;
new_settings.c_cc[VTIME] = 0;
tcsetattr(0 TCSANOW &new_settings);
}
void close_keyboard()
{
tcsetattr(0 TCSANOW &initial_settings);
}
int kbhit()
{
unsigned char ch;
int nread;
if (peek_character != -1) return 1;
new_settings.c_cc[VMIN]=0;
tcsetattr(0 TCSANOW &new_settings);
nread = read(0&ch1);
new_settings.c_cc[VMIN]=1;
tcsetattr(0 TCSANOW &new_settings);
if(nread == 1)
{
peek_character = ch;
return 1;
}
return 0;
}
int readch()
{
char ch;
if(peek_character != -1)
{
ch = peek_character;
peek_character = -1;
return ch;
}
read(0&ch1);
return ch;
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2018-03-28 20:12 power-drive\
文件 1028 2018-03-26 00:41 power-drive\kbhit.c
文件 127 2018-03-26 00:41 power-drive\kbhit.h
文件 3448 2018-03-26 00:41 power-drive\kbhit.o
文件 36009 2018-03-26 00:41 power-drive\main.c
文件 36056 2018-03-26 00:41 power-drive\main.o
文件 199 2018-03-26 00:41 power-drive\makefile
文件 35384 2018-03-26 00:41 power-drive\power-driven_machin
评论
共有 条评论