mPrinter
Unofficial forum about mPrinter.

Home » Hacking mPrinter » Communication Protocol » CUPS driver for mPrinter
CUPS driver for mPrinter [message #16] Mon, 23 September 2013 17:39 Go to next message
badger is currently offline  badger
Messages: 71
Registered: September 2013
Location: Prague, CZ
Member
Administrator
=== Quick summary ===
The project git repository

https://github.com/Yanisin/mprinter


Some CUPS documentation and other reading useful for writing CUPS driver
http://www.cups.org/documentation.php/doc-1.7/raster-driver. html
http://www.cups.org/documentation.php/doc-1.7/spec-raster.ht ml

filter and backend programming:
http://www.cups.org/documentation.php/doc-1.6/api-filter.htm l

http://en.opensuse.org/SDB:Using_Your_Own_Backends_to_Print_ with_CUPS

CUPS raster API:
http://www.cups.org/documentation.php/doc-1.4/api-raster.htm l


[Updated on: Mon, 07 October 2013 17:56]

Report message to a moderator

Re: CUPS driver for mPrinter [message #17 is a reply to message #16] Thu, 26 September 2013 21:59 Go to previous messageGo to next message
badger is currently offline  badger
Messages: 71
Registered: September 2013
Location: Prague, CZ
Member
Administrator
I made a "first shoot" of the CUPS driver. So far only for those who are able to compile binary on their system.
Result is attached.


Re: CUPS driver for mPrinter [message #18 is a reply to message #17] Fri, 27 September 2013 15:55 Go to previous messageGo to next message
badger is currently offline  badger
Messages: 71
Registered: September 2013
Location: Prague, CZ
Member
Administrator
first CUPS test page.. not perfect yet..
http://jezevcinora.cz/gallery/gallery/mPrinter/130926/thumbs/130926_02.jpg

some image (original is here: http://jezevcinora.cz/gallery/gallery/auta_expedice/201 1/110508_Trhovky/thumbs/110508_32.jpg)
http://jezevcinora.cz/gallery/gallery/mPrinter/130926/thumbs/130926_03.jpg

... and some PDF (first I found when looking for something to print Very Happy )
http://jezevcinora.cz/gallery/gallery/mPrinter/130926/thumbs/130926_04.jpg

all images in better resolution here:
http://jezevcinora.cz/gallery/?g=gallery/mPrinter/130926


[Updated on: Fri, 27 September 2013 15:56]

Report message to a moderator

Re: CUPS driver for mPrinter [message #19 is a reply to message #18] Mon, 30 September 2013 16:45 Go to previous messageGo to next message
sirmio is currently offline  sirmio
Messages: 2
Registered: September 2013
Location: tx
Junior Member
This is great and the progress looks promising. I don't have my printer yet, but I'll start reading through the documentation. Do you have the project up on a repository somewhere?

Thanks for your work.
Re: CUPS driver for mPrinter [message #22 is a reply to message #18] Mon, 30 September 2013 23:51 Go to previous messageGo to next message
AnMartini is currently offline  AnMartini
Messages: 13
Registered: September 2013
Location: Bologna, Italy
Junior Member

Wow! This will be really useful, well done! I think I'm going to study how to use the CUPS driver on my MacBook Pro.

Andrea
Re: CUPS driver for mPrinter [message #23 is a reply to message #19] Tue, 01 October 2013 13:05 Go to previous messageGo to next message
badger is currently offline  badger
Messages: 71
Registered: September 2013
Location: Prague, CZ
Member
Administrator
No, not yet. But I plan to. Wink To be honest I don't have much experience with repositories, so it's not a "five minute job".


Re: CUPS driver for mPrinter [message #24 is a reply to message #22] Tue, 01 October 2013 13:57 Go to previous messageGo to next message
badger is currently offline  badger
Messages: 71
Registered: September 2013
Location: Prague, CZ
Member
Administrator
With the current version, you will need to be able to recompile the filter binary for your machine.
I'm considering to write some version that will have this filter as a bash script. But all this will most likely end with "not enouht time for that".


Re: CUPS driver for mPrinter [message #26 is a reply to message #24] Tue, 01 October 2013 16:08 Go to previous messageGo to next message
badger is currently offline  badger
Messages: 71
Registered: September 2013
Location: Prague, CZ
Member
Administrator
just created a github repository for this:
https://github.com/Yanisin/mprinter


Re: CUPS driver for mPrinter [message #27 is a reply to message #26] Tue, 01 October 2013 18:17 Go to previous messageGo to next message
notmypfhorte is currently offline  notmypfhorte
Messages: 7
Registered: September 2013
Location: Hull, UK
Junior Member

Another thought occurred; if might be possible to write a Google Cloud Print driver. It couldn't run directly on the printer without altering its software; but something could be written to run on another machine of the same local network that the mprinter is connected to.
Re: CUPS driver for mPrinter [message #33 is a reply to message #27] Fri, 04 October 2013 17:53 Go to previous messageGo to next message
badger is currently offline  badger
Messages: 71
Registered: September 2013
Location: Prague, CZ
Member
Administrator
next idea.. I try to rewrite the filter in the driver in python, it will easily allow the driver to run on my Asus WL500g router running openwrt. Smile
https://github.com/Yanisin/mprinter/tree/python_filter


Re: CUPS driver for mPrinter [message #35 is a reply to message #33] Mon, 07 October 2013 18:07 Go to previous messageGo to next message
badger is currently offline  badger
Messages: 71
Registered: September 2013
Location: Prague, CZ
Member
Administrator
Anybody trying to get the C version of CUPS driver working?
I'd like to hear some feedback.


[Updated on: Mon, 07 October 2013 18:08]

Report message to a moderator

Re: CUPS driver for mPrinter [message #39 is a reply to message #35] Fri, 11 October 2013 10:12 Go to previous messageGo to next message
badger is currently offline  badger
Messages: 71
Registered: September 2013
Location: Prague, CZ
Member
Administrator
I tried to create a CUPS driver with filter written in python and finally it seems to be doing something:

https://github.com/Yanisin/mprinter/tree/python_filter

First think I wrote in python, so.. please don't stone me for the coding standard. Smile


Re: CUPS driver for mPrinter [message #75 is a reply to message #39] Sat, 30 November 2013 20:48 Go to previous messageGo to next message
AnMartini is currently offline  AnMartini
Messages: 13
Registered: September 2013
Location: Bologna, Italy
Junior Member

Hi! I tried to compile the Makefile but it says: "make: Nothing to be done for `/Users/andrea/Downloads/cups_mprinter'."
How can I compile it to create the .ppd file?


Andrea
Re: CUPS driver for mPrinter [message #76 is a reply to message #75] Mon, 02 December 2013 09:51 Go to previous messageGo to next message
badger is currently offline  badger
Messages: 71
Registered: September 2013
Location: Prague, CZ
Member
Administrator
hm, strange and the ppd file isn't already there?

Can you try once more with the fresh checkout and write down all what is written on the console?

For me it looks like this:

$ git clone https://github.com/Yanisin/mprinter.git
Cloning into mprinter...
remote: Counting objects: 44, done.
remote: Compressing objects: 100% (35/35), done.
remote: Total 44 (delta 25), reused 24 (delta 9)
Unpacking objects: 100% (44/44), done.

$ cd mprinter/cups_mprinter
$ make
ppdc -d . mprinter.drv
gcc -c -o rastertomprinter.o `cups-config --cflags` -lcups rastertomprinter.c `cups-config --image --libs`
rastertomprinter.c: In function 'main':
rastertomprinter.c:76: warning: too few arguments for format
rastertomprinter.c:80: warning: pointer targets in passing argument 2 of 'cupsRasterReadPixels' differ in signedness
/usr/include/cups/raster.h:323: note: expected 'unsigned char *' but argument is of type 'char *'
rastertomprinter.c:98: warning: too many arguments for format
rastertomprinter.c:33: warning: unused variable 'c'
gcc -o rastertomprinter rastertomprinter.o `cups-config --image --libs`


Re: CUPS driver for mPrinter [message #77 is a reply to message #76] Tue, 03 December 2013 16:20 Go to previous messageGo to next message
AnMartini is currently offline  AnMartini
Messages: 13
Registered: September 2013
Location: Bologna, Italy
Junior Member

Ok, I tried again and this time it worked. I only had to change the CUPS filter folder in the makefile!
I tried to print something and it does work, good job!
Thank you for the support!


Andrea
Re: CUPS driver for mPrinter [message #78 is a reply to message #77] Tue, 03 December 2013 16:42 Go to previous messageGo to next message
badger is currently offline  badger
Messages: 71
Registered: September 2013
Location: Prague, CZ
Member
Administrator
Thanks, good to hear that it's reproducible on someone others machine.
I'll have a look at at it and at least disable the debugging. The current version writes "some debug info" in /tmp/cups_mprinter.log. ..and it appends to the file, so this file may evetually (as you print and print) grow quite large.


Re: CUPS driver for mPrinter [message #152 is a reply to message #78] Sun, 14 June 2015 21:20 Go to previous messageGo to next message
AnMartini is currently offline  AnMartini
Messages: 13
Registered: September 2013
Location: Bologna, Italy
Junior Member

Hi!
I was trying to reuse the CUPS driver, but I have a problem.
I downloaded the new version with the python filter, did all the step in the readme file but as I try to print something it says "filter" failed and it stops.

When I use the make command I get this output with warnings:
ppdc -d . mprinter.drv
ppdc -d . mprinter_python.drv
gcc -c -o rastertomprinter.o `cups-config --cflags` -lcups rastertomprinter.c `cups-config --image --libs`
clang: warning: -lcups: 'linker' input unused
clang: warning: -lcupsimage: 'linker' input unused
clang: warning: -lcups: 'linker' input unused
clang: warning: -weak_framework Kerberos: 'linker' input unused
clang: warning: -weak_framework GSS: 'linker' input unused
clang: warning: -lz: 'linker' input unused
clang: warning: -lpthread: 'linker' input unused
clang: warning: -lresolv: 'linker' input unused
clang: warning: -framework SystemConfiguration: 'linker' input unused
clang: warning: -framework CoreFoundation: 'linker' input unused
clang: warning: -framework Security: 'linker' input unused
clang: warning: -liconv: 'linker' input unused
clang: warning: -lz: 'linker' input unused
rastertomprinter.c:80:43: warning: passing 'char *' to parameter of type
      'unsigned char *' converts between pointers to integer types with
      different sign [-Wpointer-sign]
            if (cupsRasterReadPixels(ras, buffer, header.cupsBytesPerLine) == 0)
                                          ^~~~~~
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include/cups/raster.h:373:40: note: 
      passing argument to parameter 'p' here
                                             unsigned char *p, unsigned len);
                                                            ^
rastertomprinter.c:98:47: warning: data argument not used by format string
      [-Wformat-extra-args]
                    fprintf(debug_file, "\n", 0);
                                        ~~~~  ^
2 warnings generated.
gcc  -o rastertomprinter rastertomprinter.o `cups-config --image --libs`


Is someone still here to help? Smile


Andrea
Re: CUPS driver for mPrinter [message #153 is a reply to message #152] Mon, 15 June 2015 15:55 Go to previous messageGo to next message
badger is currently offline  badger
Messages: 71
Registered: September 2013
Location: Prague, CZ
Member
Administrator
Hi,
seems like only I came here from time to time to check if some spammer didn't mess it here completely.
Regarding your problem... I tend to say "you're on your own". Sad

It seems like your C compiler is "less forgiving" than mine in the time I wrote it. Anyway.. for the python version you don't need to compile the C version.

I'd say, do manually just "$ sudo cp rastertomprinter_python /usr/lib/cups/filter" and "$ ppdc -d . mprinter_python.drv" and then continue with step 3) from the README.txt.


Re: CUPS driver for mPrinter [message #154 is a reply to message #153] Tue, 16 June 2015 00:23 Go to previous messageGo to next message
AnMartini is currently offline  AnMartini
Messages: 13
Registered: September 2013
Location: Bologna, Italy
Junior Member

Hi badger.
Thank you for your time! I tried following your instructions but it still says "Filter failed" when I try to print something.
I'm currently using OS X 10.10.3 and I think it could be the Yosemite update that breaks your code, because as I said in my previous post with Mavericks it worked.

It's very sad how this project ended... I could really use a working thermal printer but it seems I have to study how CUPS works. It's also very sad that only a few backers contributed to this forum.
Anyway thank you again! Let me know if you came out with something new.


Andrea
Re: CUPS driver for mPrinter [message #155 is a reply to message #154] Tue, 16 June 2015 16:19 Go to previous messageGo to next message
badger is currently offline  badger
Messages: 71
Registered: September 2013
Location: Prague, CZ
Member
Administrator
I understand you, I would use some small printer as well. But obviously mpriter is not the way. As there are really few people that actually received their printer and most of those printers are quite buggy (like mine). I'd say everyone put it in the closet and do not care anymore.

To the topic..
The filter should write some logs to /tmp/cups_mprinter_py.log, you can add more of these using log_file.write("something"). eventually you can change the location of the file on line 30 of the rastertomprinter_python file. Maybe there is just problem that the /tmp/<something> can't be created.


Re: CUPS driver for mPrinter [message #156 is a reply to message #155] Wed, 17 June 2015 13:16 Go to previous message
AnMartini is currently offline  AnMartini
Messages: 13
Registered: September 2013
Location: Bologna, Italy
Junior Member

Good news! Very Happy
Thanks to your advice I checked the tmp folder and only found the c log. I tried to comment all the code with the log file in python code and now it works!
I don't know python but probably there is a problem opening the file..
EDIT
It also print pdf!
The only problem remain the faded print...


Andrea

[Updated on: Wed, 17 June 2015 13:28]

Report message to a moderator

Previous Topic: Replicating the print data format
Goto Forum:
  


Current Time: Mon Jul 24 12:34:01 CEST 2017

Total time taken to generate the page: 0.02469 seconds