## Mtink

Mtink is a Status Monitor for EPSON ink jet printer.
With mtink you will be able to display the remaining ink quantity and the state of your printer.
Operation as check nozzle, clean nozzle and align head are also implemented.
A few printers as the Stylus Color 480 and Stylus Color 580 require a peace of software in order to exchange the cartridges. Mtink knows about the commands needed for this and supports these printers.

### Content

Requirements
Mtink and the EPSON communication protocols
How mtink works
Internationalization
The command line options
The main window
The configuration window
Head alignment
The mini window
Bugs
See also
To do

### Requirements

Mtink needs the openMotif, Motif or Lesstif library. In order to be compiled you must make sure that the X development packages and one of the above mentioned tool kits are installed (runtime and development environment).
Mtink needs a bi-directional communication with the printer.

#### Linux

If you use the parallel port you must make sure that the kernel or module (parport*) are correctly configured. On the Kernel 2.2 family the "CONFIG_PRINTER_READBACK" parameter (file /usr/src/linux/.config) must be set to 'y'.
The USB printer port module is buggy for older 2.2 and 2.4 kernels. If you use the USB port you must get a newer kernel or modify the file /usr/src/drivers/usb/printer.c.
These modifications are not complicated. You have to modify the following lines:

    static ssize_t usblp_read(struct file *file, char *buffer, size_t count, loff_t *ppos)
    {
        struct usblp *usblp = file->private_data;
    ....
        if ((usblp->readcount += count) == usblp->readurb.actual_length)
            usb_submit_urb(&usblp->readurb);
        return count;
    }

to:

    static ssize_t usblp_read(struct file *file, char *buffer, size_t count, loff_t *ppos)
    {
        struct usblp *usblp = file->private_data;
    ....
        if ((usblp->readcount += count) == usblp->readurb.actual_length) {
              usblp->readcount = 0;
              usblp->readurb.dev = usblp->dev;
              usb_submit_urb(&usblp->readurb);
              return count;
        }
    }

The modifications are in red and bold letters.

#### Solaris

I don't own a Sparc station which allows a bi-directional communication with the attached printer, so I am not able to test mtink under Sparc Solaris.
Newer workstation are equipped with an ecpp compliant port and will allow a bi-directional communication. If you own such a workstation and an EPSON ink jet printer, inform me about the results.

### Mtink and the EPSON communication protocols

A new communication protocol was created by EPSON as the Stylus Color 740 and Stylus Scan appears on the market. This protocol (D4) is based on the IEEE 1284.4 1.5 draft and allows a communication about different logical channels. The major advantage is that a program can query or send special command about the control channel even if the printer is busy (printing).
This allows also to share a port for different devices (printer and scanner).
The implementation of the D4 protocol seems to be very incomplete for older printer and is also not free of bugs for
newer printer as the Stylus Photo 890 (my own EPSON printer).
The D4 protocol requires that the printer knows at least a few part of the EJL (Epson Job Language) language. The most important Commands are the Exit from D4 mode command and is known by all printers which support the D4 communication protocol and
the Get ID command which tells the printer that a few information (model, designation, supported language) are returned.
The Get ID command is apparently not supported by the Stylus Scan 2500 and probably the Stylus Scan 2000 or by the Stylus Cxxx
family which needs the D4 pendant of Get ID.
The old way to get information about the printer state is to use the EPSON REMOTE commands. These commands are
also implemented on new printers.
Mtink knows about the different protocols, but the author doesn't know exactly the capabilities for each printer delivered by
EPSON. Due to this lack of knowledge, some printer will not do what mtink expects, however you can easily make the
required modifications.
The printer capability description is situated at the begin of the file model.c. The most important fields are the protocol
field and the id field. The protocol field must contain one of the next word:

- PROT_OLD The printer doesn't know anything about the D4 protocol.
- PROT_NEW The printer has a minimal implementation of the D4 protocol, Exit from D4 mode is needed.
- PROT_D4 The printer supports the D4 protocol in the major aspects.

If the device doesn't answer to the get ID command (EJL and D4 versions) you will probably have problems if these commands are send to the printer. Querying the printer will be disabled id the id field contain False instead of True

    /*   name               colors prot      state exch.  e.sep  cl sep reset             id   */
       { "Stylus C20SX",         4,PROT_D4,  True, False, False, True,  PROT_D4,          True, 3, 15, 2, 9, NULL },
       { "Stylus Color",         4,PROT_OLD, True, False, False, False, PROT_OLD,         True, 1,  7, 0, 0, NULL },
       { "Stylus Photo 750",     6,PROT_NEW, True, False, False, False, PROT_NEW,         True, 3, 15, 0, 0, NULL },
       { "Stylus Scan 2500",     4,PROT_D4,  True, False, False, False, PROT_OLD|PROT_D4, False,3, 15, 0, 0, NULL },

In the data extracted from the model.c file you can see that the Stylus Scan 2500 don't deliver information about it identity but need the D4 protocol. The Stylus Photo 750 is one of the first generation of D4 able printer, the communication will only be OK if the Exit from D4 command is prepended to the needed REMO TE command. The Stylus Color is a very old printer and don't know anything about the D4 protocol. Finally the Stylus C20SX needs the D4 protocol (the old Get ID don't work).
Correction of the mentioned fields will allow you to get mtink working with your printer. Please inform me about success and change of the file model.c.
See also the gimp-print documentation about the commands:
http://gimp-print.sourceforge.net

### How mtink works

At the first time you call mtink, you will be asked for the device file and the printer. After these question the printer knowledge data are loaded and if the id field set to True, mtink will try to detect if you inputs are correct and load the data for an other printer if your choice was not correct. Finally the configurations (printer model and port) are put into the file $HOME/.mtink.
If you call mtink again the configuration file is read and a check for the attached printer will occur if the printer is declared as
"id able".
Deleting the file $HOME/.mtink will reset mtink to the first .
Mtink is separated in two parts which communicate via a shared memory. This allows to perform refresh for the X-part of the program and avoid miss functions of the printer code due to the X-environment (timer, interrupts,...).
The X-part is not build as common X programs. Mtink contain different XEvents loop in order to make the job easier. Each sub window has a own loop and the called callback function return only if the loop of the sub mask return. This allows return of
values to the caller. Calling of the printer interface uses a similar mimic.

### Internationalization

Mtink can be internationalized in a very easy way. Actually mtink knows English, French, Italian, German and a few words of Turkish. You can add your language if you edit the file Mtink.res and copy them to your home directory as EpsonUtil.
The resource name for your language are derived from the variable LANG, LC_ALL and LC_MESSAGE. If for example the environment variable LANG contain fr_FR, mtink expects to found the resources which begin with as EpsonUtil.Fr (first letter capitalized, and second letter as found in the environment variable).
If the searched resource is not found, the default will be English.
Example:

    !!! default font for English and European languages
    EpsonUtil*title_LB.fontList:    *-helvetica-*-r-normal--14-*-*-*-*-*-iso8859-1
    EpsonUtil*fontList:       *-helvetica-medium-r-normal-*-12-*-*-*-*-*-iso8859-1
    !!! set the font required for turkish
    EpsonUtil.Tr*title_LB.fontList: *-helvetica-*-r-normal--14-*-*-*-*-*-iso8859-9
    EpsonUtil.Tr*fontList:    *-helvetica-medium-r-normal-*-12-*-*-*-*-*-iso8859-9
    ....
    !!! The default (english)
    EpsonUtil*previous_PB.labelString:    Previous
    !!! and the texts for german, french, italian and turkish
    EpsonUtil.De*previous_PB.labelString: Zurück
    EpsonUtil.Fr*previous_PB.labelString: précédent
    EpsonUtil.It*previous_PB.labelString: Informazioni
    EpsonUtil.Tr*previous_PB.labelString: Geri

If want to provide translation, send me back your work. Please insert also in the about your name, email address, url as you want.

### The command line options

Passing option to mtink is normally not necessary. If mtink is to be displayed on a different computer as the computer where the printer is attached you will have to state the display name e.g. mtink -display computerName:0 .
It is not necessary in this case that a X server is working on the printer server.
You may also start mtink via ssh or rsh if available:
ssh serverName /home/jj/mtink/mtink -display workStationName:0
You can also tell which language is to be used
ssh serverName LANG=fr /home/jj/mtink/mtink -display workStationName:0
will set mtink for output with french texts.
Please take in account that all browser will not work as expected.
The automatic printer detection can be disabled by launching mtink with the option -noAutoDetect.

Mtink support also more printer on the same time. The option -config <configuration number> allow to read / save the configuration datas from / to different files.
If <configuration number> is 0 or no -config <configuration number> is given, the file ~/.mtinkrc is used. If <configuration number> is not 0 the file name will be appended with ".<configuration number>".

### The main window

At the top of the windows you will see the printer which was detected or given at configuration time, here the Stylus Scan 2500.
The remaining ink quantity is displayed as well as in graphic form as a text. The number of displayed scales
depends on the printer.
The printer state may contain a few information about the internal state of the printer e.g. printing (the printer is busy).
The buttons below the State line allow the choice of the work to be performed, the last button is not active if the printer doesn't support (require) the cartridge exchange function.
The buttons at the bottom allows to see a few information about mtink (about) or to leave mtink (exit). The Help button allows you to see this document.

### The configuration window

You can choose which browser is to be used in order to display the html help file and tell mtink that an automatic detection at launching is to be performed (default).
Choosing a browser:
You can type the browser name into the input field or push the [ ... ] pushbutton and select the browser via the file selection box which will be popped up.
Mtink knows about the command line options required by a few browser (Netscape, Mozilla and Galeon) and start them accordingly. Other browser as Konqueror, Gnome-help-browser or Opera don't need special options and can also be used.
Some browser will not work if the corresponding desktop is not used. The better choice is in this case a browser as Netscape, Mozilla, Galeon or opera which are not dependent from a particular desktop as KDE (an OS above the OS which has at this time a very great bug, there are no blue screens).
Automatic detection:
The check button allow automatic detection can be toggled. In the automatic detection mode, mtink will try to identify the attached printer. If your printer is an older model as the Stylus Color 400 / 600, ... and the printer was not recognized after the first attempt, mtink will try to send a code which will cause printing of a few characters. A further advantage of disabling the automatic detection is that the start will be a little bit faster but if you attach an other EPSON printer to your computer you may get problems.
After you have modified the settings you must save them. The data are written in the file $HOME/.mtinkrc.

### <name="Align">Head alignment

Mtink allows to align the head.This feature is dependent of the printer model and the window appearance may differ a little bit from model to model.
Some printer as the Stylus Color 480 and 580 require separate alignment for the color and black head. Accordingly the main window will show toggle buttons for selecting of the head. Another difference is that the number of sample print is different (8 or 15). The number of passes may also differ from printer model to printer model.
I can't guaranty that the code send to the printer is always good. If you use this, this is at your own risk.

mtink alignment first window | mtink alignment wait window
mtink alignment setup window | mtink alignment last window

The second and third windows shown above will be displayed up to three times (depend on printer model).

### The mini window

This window will only be displayed if the server mtinkd is running or the rc file .mtinkrc contain the path "/var/mtink/...".

This little window will be displayed with a green (All is OK), orange (Ink quantity less as 10 %) or red background (Printer not available or ink quantity less a 5 %).
Pressing on the window with the left mouse button popup/popdown the Mtink main Window.
This window can be positionned on the screen while pressing the right pushbutton and the moving the mouse.
The last position is writting to the file ~/.mtinksess[.configuration number> if mtink is closed via the ALT + F4 key combination or by closing the window via the window manager menu for the mtink main window.

### Bugs

Probably a lot.

### See also

Index
mtinkd the server for D4 able printers
minkc the chooser for owner of more EPSON printers
ttink a tty based status monitor

### To do

- Better documentation.
- Translation of the documentation.
- Test with more printers.
- ....

### Author

Jean-Jacques Sarton
jj.sarton@t-online.de
Xwtools Home Page