test.c

来自「基于arm的嵌入式扫描仪和打印机的驱动程序!」· C语言 代码 · 共 54 行

C
54
字号
/* *      Buttos Example for Matrix IV * *      Copyright (C) 2004 capbily - friendly-arm *	capbily@hotmail.com */#include <stdio.h>#include <stdlib.h>#include <unistd.h>#include <sys/types.h>#include <sys/stat.h>#include <fcntl.h>#include <errno.h>#include "weida_printer.h"int main(void){	int weida_fd, ret,length;	char *data="hello,welcome to embedded world!";	char  buff[100];	weida_fd = open("/dev/weida_printer", O_WRONLY);	if (weida_fd < 0) {		perror("open device buttons");		exit(1);	}	//printf("data len: %d\n, string is %s\n",strlen(data), data);	        ret = write(weida_fd, data, strlen(data));	if (ret != strlen(data))	{	perror("print worng\n");        }	scanf("%s",&buff);	length=strlen(buff);	buff[length]='\0';	ret = write(weida_fd, buff, strlen(buff));	if (ret != strlen(buff))	{	perror("print worng\n");        }	/*ioctl(weida_fd, WEIDA_IOCSFONTSPACE, 1);	printf("1\n");	ioctl(weida_fd, WEIDA_IOCSLINESPACE, 1);	printf("2\n");	sleep(1);	ret = write(weida_fd, data, strlen(data));	printf("3\n");*/	if (ret != strlen(data)) 	{	perror("print worng\n");        }	close(weida_fd);	return 0;}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?