?? tstkey.c
字號:
#include <fcntl.h>
#include <sys/types.h>
#include <time.h>
#include <sys/ioctl.h>
#include <errno.h>
#include <sys/times.h>
#include <sys/select.h>
#include <string.h>
#include <termios.h>
int select_port(char *dev, char* baud)
{
int portfd;
if ((portfd = open(dev, O_RDWR | O_NDELAY)) < 0) {
exit(0);
}
if (portfd < 0) return(-1);
k_flush(portfd);
k_setparms(portfd, baud, "N", "8", "1");
return (portfd);
}
main()
{
int fd;
char tmp[80]="\x1B%B";
int num;
//fd = select_port("/dev/tty1a", "9600");
fd = select_port(NULL, "9600");
if(fd < 0)
{
perror("open port tty1a error");
exit(-1);
}
printf("tmp=%x%x%x\n", tmp[0], tmp[1], tmp[2]);
printf("tmp=%s\n", &tmp[1]);
tmp[2] = 'R';
if((num = write(fd, (char*)tmp, 3)) < 0)
{
perror("write tty1a error");
exit(-2);
}
printf("written %d bytes\n", num);
k_flush(fd);
tmp[2] = 'K';
if((num = write(fd, (char*)tmp, 3)) < 0)
{
perror("write tty1a error");
exit(-2);
}
printf("written %d bytes\n", num);
for(;;){
if( k_readchk(fd) > 0)
{
printf("ready for read......\n");
num = read(fd, tmp, 30);
if(num < 0)
{
perror("read error");
exit(-3);
}
printf("tmp=%s\n%d\n", tmp, num);
}
}
close_key(fd);
exit(0);
}
//saiwen added this line here.
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -