alysogorov / Ricoh_Aficio_SP1XX_CUPS_driver

CUPS driver for Ricoh Aficio SP1XX printer(possibly works for SP2XX)
16 stars 3 forks source link

duplex, mediatype and dot count improvements #1

Closed ghost closed 8 years ago

ghost commented 8 years ago

hi alysogorov

i would like to contribute to your work here but i am not good at programming so i want to share the information i extracted;

duplex printing functionality :

from what i sniffed out from the original driver when duplex printing is selected the line "@PJL SET PURPOSE=MANUALDUPLEXEMPTYPAPER" is added after @PJL SET RESOLUTION line at each page;

and additionally when the page needs to be flipped
"@PJL SET MANUALDUPLEX=FLIPSIDE" is added before @PJL SET PAGESTATUS=START line. it is only used once, for instance after page 1,3,5 is printed it should be added to addPage function of page 2 only. and pages 4,6 are printed without this line.

i added this portion to ppd file for duplex settings for testing but it should be revised ppd_duplex.txt

note that cups will call your driver with Duplex=DuplexNoTumble parameter

also i would like attach mediaType portion of my edited ppd file according to the original ppd_mediatype.txt

also please check this modification for dot count calculation. https://build.opensuse.org/package/view_file/home:jejb1:Tumbleweed/RicohAficioSP1xx-2xx-PPD/0001-pstoricohddst-gdi-Implement-dot-counts.patch?expand=1 in this implementation he gets page size using a tool called identify and he extracts mean value then he multiplies height x width x mean to get total number of dots in the page. i think you are processing the page in parsePBMsize function and maybe you could count dots there if you could.

hope these are useful and please ask me if you need additional sniffing from windows driver

alysogorov commented 8 years ago

Hi serkazak!

Which printer do you have? i've ricoh sp 111 su.

I'm printing two sided pages just using print odd/even pages in "page setup" settings of print dialog. Everything works good. at first stage i print odd pages, then flip all printed pile, insert in the slot in proper way and print the file again but even pages only. How this hardware duplex works? i have to flip every single page manually? If it's so, this looks like a hell, isn't it? Yes, I can implement your ideas, but seems it won't add new features? For me, the "manual duplex" i use, is just simpler, isn't it?

It would be very useful if you put here your complete modified .ppd file, i'll check it on my printer and add to this distribution. I didn't dig .ppd file and do not know it's proper format. So it would be great if you provide correct .ppd file. Also my .ppd has not support of 1200 dpi. if you know how to add it, it will be very good, because driver must support it.

Seems You defined different mediatypes, kinda recycled, thin... but now the media type is hardcoded at line 252 as PLAINRECYCLE, can change there to parametric values, but do not know how windows driver names this parameters in page header, it must be sniffed under Windows.

Thanks for dot count idea. Personally I like the "faked count", but if some people like to have real count values, it could be added of course. Additionally, the faked count removes the dependence on this "identify" programm. Also dot counting can be implemented in Python without . Bit it could be slow.

Alex.

alysogorov commented 8 years ago

duplex printing functionality :

from what i sniffed out from the original driver when duplex printing is selected the line "@PJL SET PURPOSE=MANUALDUPLEXEMPTYPAPER" is added after @PJL SET RESOLUTION line at each page;

and additionally when the page needs to be flipped

"@PJL SET MANUALDUPLEX=FLIPSIDE" is added before @PJL SET PAGESTATUS=START line. it is only used once, for instance after page 1,3,5 is printed it should be added to addPage function of page 2 only. and pages 4,6 are printed without this line.

By the way. i do not understand how Windows driver sends pages to printer in Duplex mode. There are variants, let we have 4 pages: -driver sends 1,2,3,4 with page headers you mentioned, and printer accumulates even pages, to print them at stage 2. because of command @PJL SET MANUALDUPLEX=FLIPSIDE at page 2 header printer stops. User must flip paper and seems push some button on the printer? -driver sends 1,3,2,4, and because page 2 has mentioned command, printer stops. second variant looks reasonable because there is no accumulation of pages(needs memory).

Do i correctly understand how Duplex works here? -printer prints odd pages, then stops and shows something on indicator, kinda - Hey flip your pages!, and waits pushing of some button? alex.

ghost commented 8 years ago

i have sp100 but probably those models are similar, maybe the ones with scanner may have different options (media slot etc...)

about duplex if you refer to pages 18.19 of the manual here http://support.ricoh.com/bb_v1oi/pub_e/oi/0001044/0001044844/VM1018655/M1018655.pdf, it is actually the same thing you do manually, you send it once but when it finishes front sides, you put pages again in loading tray and press form feed button to continue. i use duplex printing a lot and i am missing that function.

i just double checked original driver to be sure, i did the following experiment : i prepared a 4 page document, pages 1 and 3 are empty, page 2 has some letters on it and page 4 has much more content. (jbig content is completely unreadable so i check the dotcount and the amount of image data). what i sniffed is the following first front sides (pages 1 and 3) are sent then manualduplex=flipside is issued and page 2 is sent and lastly page 4 is sent. therefore the ordering is 1,3,2,4 as you guessed. i do not know how cups orders pages in this case.

i also checked 1200 dpi option, i sniffed paperwidth=9922 (A4) which is 2 x 4961 (600 dpi case) but paperlength is the same (7016). in your driver in line 166 you have 14031 for that parameter. so the actual raster file sent to printer is 1200x600 pixels.

all of the media types are from the original driver. i copied their names from the driver window and sniffed their corresponding commands sent to printer so they should be correct. (different models may have additional or different types though). i actually do not use other types of paper but i think it is good to implement that instead of hardcoding.

i understood your motivation about dot count. identify command requires imagemagick package if i am not mistaken. i agree that implementing that in python might not be a good solution (i dont want to wait for that :) ). maybe you could check if that command is available, otherwise you could send fake dot count. also does it matter to trick dot count? for instance if i send dot count 9999999999999 does the printer think the toner is empty?

also here is my ppd file RICOH_Aficio_SP_100.ppd.txt it is definitely missing a lot of options

alysogorov commented 8 years ago

ahh. good info that your printer supports only 1200*600... still do not know if my does the same. I ll check it.

i already added your additions for ppd and now am implementing duplex mode. about media types.... in the current driver it is hardcoded as pjlLine("MEDIATYPE=PLAINRECYCLE") #kind of paper but look, you give - PLAINRECYCLED, is that correct? printer eats my option... just now i cannot test if he eats yours. may be our printers have slightly different names of media types? at least it must be checked. But how printer handles different kinds of paper? I do not know, it's my first home printer.

About dot count. I remember that in issues of madlynx driver was some mentioning, that big dot count can decrease a cartridge life... but i really doubt that such sensible parameter can be faked by external software. if ricoh guys are not fools, they must calculate dot count inside hardware. so may be values from driver are completely ignored :) that's why i doubt that all this mess with identify command is essential.

you can easy test if you cartridge died on 99999999999 dot count :) i won't, i do not like such risky things :)))) regards, alex.

ps. by the way, did you test my driver? is it operable for you SP100?

ghost commented 8 years ago

i checked sp100 sp111 sp111su user manuals they all specify Resolution 600 × 600 dpi (maximum: 1200 × 600 dpi) when 1200x600 is selected this command is sent : @ P J L S E T R E S O L U T I O N = 1 2 0 0

about plainrecycle there is a mistake it should be PLAINRECYCLE but it seems to be working somehow with madlynx driver (i replaced hardcoded value). however for instance if you set thin paper and feed 80gr paper the error indicator blinks and you need to press form feed button. (i think SU models have start button instead of this button). this does not prove media type function works but at least it is aware of what type of paper you insert.

alysogorov commented 8 years ago

Hi, serkazak. I've put the version with duplex mode. Try it. it is the last version of branch master. pls check if last odd page is printed(if it has not corresponding even page - i.e total number of pages in document is odd),... seems i saw this strange effect once, but could not repeat it during tests. regards, alex ps. only ppd and .py files changed. You have to delete printer and add it again with my ppd. Ppd is a clone of your's file

ghost commented 8 years ago

duplex works now. i tried with odd and even pages, it seems to be working as expected. in the original driver if you simply flip pages horizontally and feed them back it prints even pages from bottom to top (normally it prints from top to bottom) so that odd and even pages are printed along same direction. i was expecting that this 180 degree rotation operation is performed at printer firmware but apparently it is implemented in driver. can you flip even pages vertically for duplex mode, for instance using pstops command before line 407?

also i noticed that the driver tries to create a temporary directory at the current directory. i think you can use /tmp/ for that because it can cause permission problems.

alysogorov commented 8 years ago

Ok. I corrected the temporary path, making it optional inside the driver(still not uploaded). About rotation of even pages i have to think. There is one denial against it. The driver is low level software and now it correctly prints incoming document "as is", without modifications. Such special things as printing of few pages on one sheet, printing of odd/even pages, printing in reversed order are provided by cups. Question here - can cups do this job - flip even pages? may be some additions to ppd file needed.