ALT Linux Community general discussions
 help / color / mirror / Atom feed
From: vx 8400 <vx8400@gmail.com>
To: ALT Linux Community general discussions <community@lists.altlinux.org>
Subject: Re: [Comm] принтер Canon LBP-1120 не работает на 4.0.X
Date: Thu, 11 Mar 2010 11:53:10 +0100
Message-ID: <89eb42f1003110253j4b6f4d70w932e24b119a762ad@mail.gmail.com> (raw)
In-Reply-To: <4B987216.5010905@rambler.ru>

[-- Attachment #1: Type: text/plain, Size: 658 bytes --]

11 марта 2010 г. 5:31  Kharitonov A. Dmitry пишет:
>
>> Чудным образом после перезагрузки машины capt-0.1 заработал.
>
> Этот драйвер весьма не доделанный. Он обращается только к устройству
> /dev/usb/lp0. Если принтер во время работы вздумывает встать как
> /dev/usb/lp1 (наблюдал сам) (например, при внутреннем сбросе по тайм ауту),
> то драйвер клинит. Таже история, если подключены 2 usb принтера.

Не проблема.
capt.c.patch в прицепе.

Проблема может быть в том, что capt не всегда правильно распознает и
обрабатывает
состояние принтера.
В моем случае пока работает нормально через cups (со слов очевидца).
Если будут сбои, буду отлаживать.

WBR,
Oleg.

[-- Attachment #2: capt.c.patch --]
[-- Type: text/x-patch, Size: 3602 bytes --]

--- orig/capt-0.1/capt.c	2004-08-16 22:22:57 +0400
+++ capt-0.1/capt.c	2010-03-11 13:45:56 +0300
@@ -33,11 +33,14 @@
 
 #include "capt.h"
 
+char* dev_printer = NULL;
+
 #define WAIT 8000
 
-#undef DEBUG
+/*#undef DEBUG*/
+
 #ifdef DEBUG
-#define DPRINTF(fmt, args...) printf(fmt, ## args)
+#define DPRINTF(fmt, args...) fprintf(stderr,fmt, ## args)
 #else
 #define DPRINTF(fmt, args...)
 #endif
@@ -269,6 +272,7 @@
 	unsigned char c1, c2;
 	unsigned char* c;	
 
+	fprintf(stderr,"In compress_bitmap\n");
 	ccbm = 0;
 	cbm[0] = malloc(65536);
 	cbm[1] = NULL;
@@ -278,9 +282,13 @@
 		errorexit();
 	}
 
+	fprintf(stderr,"bitmapf ...\n");
+
 	if (fgets(cbm[0],200,bitmapf)<=0) {
 		return 0;
 	}
+	fprintf(stderr,"fgets ( bitmapf ) succeeded\n");
+
 	if (strncmp(cbm[0],"P4",2)) {
 		fprintf(stderr,"Wrong file format.\n");
 		fprintf(stderr,"file position: %lx\n",ftell(bitmapf));
@@ -597,6 +605,7 @@
 }
 
 int print_page(int page) {
+		/**/
 	if (page == 0) {
 		write_command_packet(0xa1, 0xa1, 0, 2);
 
@@ -604,7 +613,7 @@
 			fprintf(stderr, "Invalid printer state, printer not connected ?\n");
 			return 0;		
 		}
-	}
+	} /**/
 
 	if (!waitforpaper()) {
 		fprintf(stderr, "Timeout out while waiting for paper.\n");
@@ -723,7 +732,7 @@
 	//int tfd;
 
 	bitmapf = stdin;
-	while ((c = getopt(argc,argv,"Rrt:l:sf:")) != -1) {
+	while ((c = getopt(argc,argv,"Rrt:l:sf:d:")) != -1) {
 		switch (c) {
 /*			case 'R': {
 				reset_only=1;
@@ -752,40 +761,50 @@
 					fprintf(stderr,"File not found on unreadable\n");
 					errorexit();
 				}
+				DPRINTF("DBG: %s: reading the bitmap from %s\n",argv[0],optarg);
+				break;
 			}
+		       case 'd':
+				  if (!optarg) {
+					  fprintf(stderr,"ERROR: printer device is not specified. Use -d /dev/usb/lpX option.\n");
+					  errorexit();
+				  }
+				  if (!(dev_printer = (char*)malloc(sizeof(char)*(strlen(optarg)+1)))) {
+					  fprintf(stderr,"ERROR: weird! can't get core to copy %d characters of the device name!\n",strlen(optarg)+1);
+					  errorexit();
+				  }
+				  strcpy (dev_printer,optarg);
+				  break;
 		}
 	}
 
-	fd = open("/dev/usb/lp0", O_RDWR | O_NONBLOCK);
-	//fd = open("/dev/lp0", O_RDWR);
-
-//	if (!reset_only) {
-		/* pages printing loop */
-/*      struct timeval ltv;
-      struct timeval ntv;*/
-      
-		while (1) {
-			/* temporary file to store our results */
-/*			strcpy(gname,"/tmp/lbp810-XXXXXX");
-			if ((tfd=mkstemp(gname))<0) {
-				fprintf(stderr,"Can't open a temporary file.\n");
+	if (!dev_printer) {
+		fprintf(stderr,"WARNING: using /dev/usb/lp0 by default\n");
+		dev_printer = "/dev/usb/lp0";
+	}
+	if ((fd = open(dev_printer, O_RDWR | O_NONBLOCK)) == -1) {
+		fprintf(stderr,"ERROR: %s: Can't open %s\n",argv[0],dev_printer);
 				errorexit();
 			}
-			cbmf = fdopen(tfd,"w+");*/
-			if (!compress_bitmap())
+	DPRINTF("%s: DBG: %s opened\n",argv[0], dev_printer);
+      
+	while (1) {
+		DPRINTF("DBG: %s: compress_bitmap() ...\n",argv[0]);
+		if (!compress_bitmap()) {
+			DPRINTF("DBG: %s: compress_bitmap() == 0; break;\n",argv[0]);
 				break;
+		}
+		DPRINTF("DBG: %s: simulate = %d\n",argv[0],simulate);
 			if (!simulate) {
+			DPRINTF("DBG: %s: print_page() ...\n",argv[0]);
 				if (!print_page( page )) {
-				   fprintf(stderr, "Error, cannot print this page.\n");
+			   fprintf(stderr, "ERROR: %s: cannot print this page.\n",argv[0]);
 				   errorexit();
 	            }
-	            //gettimeofday(&ltv, NULL);
+			DPRINTF("DBG: %s: print_page() succeeded\n",argv[0]);
 			}
-//			fclose(cbmf);
 			next_page(page++);
-//			unlink(gname);
 		}
-//	}
 
    fclose(bitmapf);
 

  reply	other threads:[~2010-03-11 10:53 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-07 15:52 vx 8400
2010-03-07 17:19 ` Denis Nazarov
2010-03-07 19:16   ` vx 8400
2010-03-09 22:49     ` Michael Shigorin
2010-03-09 23:42       ` vx 8400
2010-03-10  5:17         ` Денис Назаров
2010-03-10 12:28           ` vx 8400
2010-03-10 19:44             ` vx 8400
2010-03-11 18:57             ` [Comm] удалённо передёрнуть питание (was: принтер Canon LBP-1120 не работает на 4.0.X) Michael Shigorin
2010-03-11 19:25               ` [Comm] [JT] " vx 8400
2010-03-11 21:29                 ` [Comm] [JT] удалённо передёрнуть питание Michael Shigorin
2010-03-12 13:44                   ` vx 8400
2010-03-12 13:48                     ` Michael Shigorin
2010-03-12 13:57                       ` vx 8400
2010-03-12  9:40                 ` [Comm] " Michael Shigorin
2010-03-14  8:40                   ` Jurij Bogaevs'kyj
2010-03-20 12:37                     ` Jurij Bogaevs'kyj
2010-03-14 13:42               ` [Comm] удалённо передёрнуть питание (was: принтер Canon LBP-1120 не работает на 4.0.X) Sergey
2010-03-10 13:47         ` [Comm] принтер Canon LBP-1120 не работает на 4.0.X Michael Shigorin
2010-03-11  4:31         ` Kharitonov A. Dmitry
2010-03-11 10:53           ` vx 8400 [this message]
2010-03-11 11:01             ` vx 8400
2010-03-11 16:24               ` Kharitonov A. Dmitry
2010-03-11 18:58             ` Michael Shigorin
2010-03-11 19:13               ` vx 8400

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=89eb42f1003110253j4b6f4d70w932e24b119a762ad@mail.gmail.com \
    --to=vx8400@gmail.com \
    --cc=community@lists.altlinux.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

ALT Linux Community general discussions

This inbox may be cloned and mirrored by anyone:

	git clone --mirror http://lore.altlinux.org/community/0 community/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 community community/ http://lore.altlinux.org/community \
		mandrake-russian@linuxteam.iplabs.ru community@lists.altlinux.org community@lists.altlinux.ru community@lists.altlinux.com
	public-inbox-index community

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://lore.altlinux.org/org.altlinux.lists.community


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git