From 996f12b0a580ff8a55607cf1f41a964a7697d5a4 Mon Sep 17 00:00:00 2001 From: aarnaude Date: Wed, 8 Mar 2017 18:01:59 +0100 Subject: [PATCH] controle en mode bit image + tests d'envoi de differentes datas --- Makefile | 5 ++++- bit | Bin 0 -> 9888 bytes bit_image.c | 189 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ test_imprimante_v4.c | 109 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------ v4 | Bin 0 -> 15136 bytes 5 files changed, 296 insertions(+), 7 deletions(-) create mode 100755 bit create mode 100644 bit_image.c create mode 100755 v4 diff --git a/Makefile b/Makefile index 7707760..b212916 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,8 @@ CC = gcc CFLAGS = -Wall -Wextra +bit : + $(CC) $(CFLAGS) bit_image.c -o bit + imprimante : - $(CC) $(CFLAGS) test_imprimante_v4.c -o imprimante + $(CC) $(CFLAGS) test_imprimante_v4.c -o v4 diff --git a/bit b/bit new file mode 100755 index 0000000..84ec0ed Binary files /dev/null and b/bit differ diff --git a/bit_image.c b/bit_image.c new file mode 100644 index 0000000..a43a481 --- /dev/null +++ b/bit_image.c @@ -0,0 +1,189 @@ +/* code contrôle de l'imprimante + * + * EPSON LQ 570 + + * P406 + * Buffer size = 8kB + * + */ + + +#include +#include +#include +#include +#include +#include +#include +#include + +/************** + * Constantes * + * ************/ + +#define SPEED B9600 +#define PATH "/dev/usb/lp0" +#define N_TEST 3 + +/********************** + * Commandes usuelles * + * ********************/ + +unsigned int N_COLUMN=12; +unsigned char ESC=0x1B; +unsigned char AT = 0x40;//@ +unsigned char CR = 0x0D; +unsigned char LF = 0x0A; +unsigned char FF = 0x0C; +unsigned char OPAR = 0x28;//( +unsigned char NUL = 0; +unsigned char UN = 1; + +/********************************* + * Fonctions communication série * + *********************************/ + +struct termios saveterm; + +int init_serial(char *device,int speed) { + struct termios new; + int fd=open(device,O_RDWR|O_NOCTTY); + if(fd<0){perror(device); exit(-1);} + tcgetattr(fd,&saveterm); + bzero(&new,sizeof(new)); + new.c_cflag=CLOCAL|CREAD|speed|CS8; + new.c_iflag=0; + new.c_oflag=0; + new.c_lflag=0; // set input mode (non-canonical, no echo,...) + new.c_cc[VTIME]=0; // inter-character timer unused + new.c_cc[VMIN]=1; // blocking read until 1 char received + tcflush(fd, TCIFLUSH); + tcsetattr(fd,TCSANOW,&new); + return fd; +} + +void close_serial(int fd) { + tcsetattr(fd,TCSANOW,&saveterm); + close(fd); +} + +/********************************************* + * Fonction d'initialisation de l'imprimante * + *********************************************/ + +void init_impr(int fd) +{ + write(fd, &ESC, 1); //ESC + write(fd, &AT, 1); //@ : ESC @ permet d'initialiser l'imprimante +} + +/***************************************** + * Fonctions de controle de l'imprimante * + *****************************************/ + +void bit_image(int fd){ + //P29 + unsigned char STAR = 0x2A; + unsigned char PLUS = 0x2B; + unsigned int QH = 48; + unsigned int data1 = 0xA0; + unsigned int data2 = 0x3A; + unsigned int data3 = 0x9F; + unsigned int data4 = 0xCD; + + unsigned char G = 0x47; + unsigned int j = 0; + unsigned int test = 0; + + //P176 + //Entering Graphic mode + write(fd,&ESC,1); + write(fd,&OPAR,1); + write(fd,&G,1); + write(fd,&UN,1); + write(fd,&NUL,1); + write(fd,&UN,1); + + // Set line spacing with ESC + 48 + write(fd,&ESC,1); + write(fd,&PLUS,1); + write(fd,&QH,1); + + //Go to starting line + write(fd,&CR,1); + write(fd,&LF,1); + + // ESC * for each line of dots P184 + for(test=0;test @@ -19,6 +18,7 @@ #define SPEED B9600 #define PATH "/dev/usb/lp0" +#define LINE_LENGTH 16 unsigned char ESC=0x1B; unsigned char AT = 0x40;//@ @@ -274,7 +274,7 @@ void multipoint_print_mode(int fd){ write(fd,&ESC,1); write(fd,&t,1); write(fd,&UN,1); - + data=0x69; for(i=0;i