Changes between Version 32 and Version 33 of Docs/825gen2/Dev/Networking/NetworkPrintingCUPS


Ignore:
Timestamp:
02/21/24 15:19:08 (9 months ago)
Author:
Don Wilson
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Docs/825gen2/Dev/Networking/NetworkPrintingCUPS

    v32 v33  
    66
    77For web configuration and monitoring select "Yes" for "Web Access", "Main", "Conf", and "Log". Press ENTER to save changes.
     8
     9
     10== CUPS management web pages ==
     11
     12
     13The cups management pages should appear at http://<ip_address_of_indicator>:631
     14
     15It is showing "Not found" but it is shows "CUPS v2.4.2" so it seems the cups web server is running but some page information is missing.
     16
     17Adding "/admin" to the url shows the administration page, but it is missing style information.
     18
     19After some research it seems the Yocto recipe "cups-doc" is needed to provide the static page information such as index.html and cups.css. This was added in the 825 image build 2024-01-16. This fixed the problem.
     20
     21[[Image(cups_mainpage.png)]]
     22
     23
     24Check a Windows PC that is already configured to use the desired network printer.
     25
     26[[Image(windows_printer_properties.png)]]
     27
     28This shows the IP address of the printer.
     29
     30Click "Administration" on the 825 CUPS page.
     31
     32[[Image(cups_admin.png)]]
     33
     34Click "Add Printer."
     35
     36[[Image(cups_sign_in.png)]]
     37
     38Type the username and password. Click "Sign in".
     39
     40[[Image(cups_add_printer1.png)]]
     41[[Image(cups_add_printer2.png)]]
     42[[Image(cups_add_printer3.png)]]
     43
     44Select the printer that looks correct in the list and click "Continue".
     45
     46[[Image(cups_add_printer_name.png)]]
     47
     48Make sure the IP address shown matches. The name and description may be changed if desired. Click "Continue".
     49
     50[[Image(cups_add_printer_model.png)]]
     51
     52Select the "Model:" "driverless" and click "Add Printer".
     53
     54[[Image(cups_set_printer_options.png)]]
     55
     56Click "Set Default Options."
     57
     58[[Image(cups_set_default_options_success.png)]]
     59
     60The page should change to show "default options have been set successfully."
     61
     62[[Image(cups_printer_info.png)]]
     63
     64Select the maintenance drop down.
     65
     66[[Image(cups_maintenance_dropdown.png)]]
     67
     68Select "Print Test Page."
     69
     70[[Image(cups_unable_to_print_test_page.png)]]
     71
     72This feature does not currently work. Will investigate further.
     73
     74Maybe printer test page is also part of cups-doc recipe.
     75{{{
     76card825gen2:~$ cat /home/admin/test.txt
     77test 123
     78}}}
     79
     80{{{
     81card825gen2:~$ lp -d "Canon_iR-ADV_4545_4551_III_UFR_II" /home/admin/test.txt
     82request id is Canon_iR-ADV_4545_4551_III_UFR_II-31 (1 file(s))
     83}}}
     84
     85Page printed with top line "test 123" successfully
     86
     87[[Image(cups_jobs1.png)]]
     88
     89{{{
     90card825gen2:~$ lp -d "Canon_iR-ADV_4545_4551_III_UFR_II" /usr/images/startup.png
     91request id is Canon_iR-ADV_4545_4551_III_UFR_II-32 (1 file(s))
     92}}}
     93
     94The PNG file did not print.
     95
     96{{{
     97card825gen2:~$ lp -d "Canon_iR-ADV_4545_4551_III_UFR_II" /usr/images/cardinal_logo.bmp
     98request id is Canon_iR-ADV_4545_4551_III_UFR_II-33 (1 file(s))
     99}}}
     100
     101The cardinal_logo did print.
     102
     103Maybe png files do not work, but bmp files do.
     104
     105[[Image(cups_jobs2.png)]]
     106
     107
     108Printing from application code.
     109
     110{{{
     111#include <stdio.h>
     112#include <cairo.h>
     113#include <cairo-ps.h>
     114#include <cups/cups.h>
     115
     116#include "cairobmp.h"
     117
     118#define WIDTH 480
     119#define HEIGHT 500
     120
     121int main(int argc, char **argv) {
     122
     123        int n;
     124
     125        char tmpFilepath[] = "/tmp/tktprtXXXXXX";
     126
     127//  mkstemp(tmpFilepath);
     128        strcpy(tmpFilepath, "/tmp/tkt.bmp"); // TODO Easier name just for testing
     129        printf("tmpFilename [%s]\n", tmpFilepath);
     130
     131        cairo_surface_t *surface = cairo_image_surface_create(CAIRO_FORMAT_A1, WIDTH, HEIGHT);
     132        printf("after surface create %d\n", cairo_surface_get_type(surface));
     133        cairo_t *context = cairo_create(surface);
     134
     135        LoadBMPToSurface("/usr/images/cardinal_logo.bmp", surface, 0, 0);
     136
     137        // draw some text
     138        cairo_select_font_face(context, "Arial Black", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
     139        cairo_set_font_size(context, 30);
     140        int x = 20;
     141        int y = 140;
     142        cairo_move_to(context, x, y);
     143        cairo_show_text(context, "Item 1"); // the text we got as a parameter
     144        y += 30;
     145        cairo_move_to(context, x, y);
     146        cairo_show_text(context, "Item 2"); // the text we got as a parameter
     147        y += 30;
     148        cairo_move_to(context, x, y);
     149        cairo_show_text(context, "Item 3"); // the text we got as a parameter
     150
     151        // draw a dotted box
     152        const double pattern[] = { 15.0, 10.0 };
     153        cairo_set_dash(context, pattern, 2, 0);
     154        cairo_set_line_width(context, 5);
     155        cairo_rectangle(context, 5, 105, 400, 300);
     156        cairo_stroke(context);
     157
     158        // finish up
     159        cairo_show_page(context);
     160        cairo_destroy(context);
     161        cairo_surface_flush(surface);
     162
     163        CairoSurfaceToBMP(surface, tmpFilepath);
     164
     165        cairo_surface_destroy(surface);
     166
     167        const char *printerName = "STARSK1_311";
     168        n = cupsPrintFile(printerName, tmpFilepath, "825 ticket", 0, NULL);
     169        // return value is job ID
     170        printf("cupsPrintFile result %d\n", n);
     171
     172        //unlink(tmpFilepath); // TODO This is commented to allow testing - after testing is done uncomment so after print the tmp file will be deleted
     173
     174        return 0;
     175}
     176}}}
     177
     178== Technical information ==
    8179
    9180From a terminal type **/usr/sbin/lpinfo -v** to show printers that are detected on the network in additional to local USB printers.
     
    66237}}}
    67238
    68 == CUPS management web pages ==
    69 
    70 
    71 The cups management pages should appear at http://<ip_address_of_indicator>:631
    72 
    73 It is showing "Not found" but it is shows "CUPS v2.4.2" so it seems the cups web server is running but some page information is missing.
    74 
    75 Adding "/admin" to the url shows the administration page, but it is missing style information.
    76 
    77 After some research it seems the Yocto recipe "cups-doc" is needed to provide the static page information such as index.html and cups.css. This was added in the 825 image build 2024-01-16. This fixed the problem.
    78 
    79 [[Image(cups_mainpage.png)]]
    80 
    81 
    82 Check a Windows PC that is already configured to use the desired network printer.
    83 
    84 [[Image(windows_printer_properties.png)]]
    85 
    86 This shows the IP address of the printer.
    87 
    88 Click "Administration" on the 825 CUPS page.
    89 
    90 [[Image(cups_admin.png)]]
    91 
    92 Click "Add Printer."
    93 
    94 [[Image(cups_sign_in.png)]]
    95 
    96 Type the username and password. Click "Sign in".
    97 
    98 [[Image(cups_add_printer1.png)]]
    99 [[Image(cups_add_printer2.png)]]
    100 [[Image(cups_add_printer3.png)]]
    101 
    102 Select the printer that looks correct in the list and click "Continue".
    103 
    104 [[Image(cups_add_printer_name.png)]]
    105 
    106 Make sure the IP address shown matches. The name and description may be changed if desired. Click "Continue".
    107 
    108 [[Image(cups_add_printer_model.png)]]
    109 
    110 Select the "Model:" "driverless" and click "Add Printer".
    111 
    112 [[Image(cups_set_printer_options.png)]]
    113 
    114 Click "Set Default Options."
    115 
    116 [[Image(cups_set_default_options_success.png)]]
    117 
    118 The page should change to show "default options have been set successfully."
    119 
    120 [[Image(cups_printer_info.png)]]
    121 
    122 Select the maintenance drop down.
    123 
    124 [[Image(cups_maintenance_dropdown.png)]]
    125 
    126 Select "Print Test Page."
    127 
    128 [[Image(cups_unable_to_print_test_page.png)]]
    129 
    130 This feature does not currently work. Will investigate further.
    131 
    132 Maybe printer test page is also part of cups-doc recipe.
    133 {{{
    134 card825gen2:~$ cat /home/admin/test.txt
    135 test 123
    136 }}}
    137 
    138 {{{
    139 card825gen2:~$ lp -d "Canon_iR-ADV_4545_4551_III_UFR_II" /home/admin/test.txt
    140 request id is Canon_iR-ADV_4545_4551_III_UFR_II-31 (1 file(s))
    141 }}}
    142 
    143 Page printed with top line "test 123" successfully
    144 
    145 [[Image(cups_jobs1.png)]]
    146 
    147 {{{
    148 card825gen2:~$ lp -d "Canon_iR-ADV_4545_4551_III_UFR_II" /usr/images/startup.png
    149 request id is Canon_iR-ADV_4545_4551_III_UFR_II-32 (1 file(s))
    150 }}}
    151 
    152 The PNG file did not print.
    153 
    154 {{{
    155 card825gen2:~$ lp -d "Canon_iR-ADV_4545_4551_III_UFR_II" /usr/images/cardinal_logo.bmp
    156 request id is Canon_iR-ADV_4545_4551_III_UFR_II-33 (1 file(s))
    157 }}}
    158 
    159 The cardinal_logo did print.
    160 
    161 Maybe png files do not work, but bmp files do.
    162 
    163 [[Image(cups_jobs2.png)]]
    164 
    165 
    166 Printing from application code.
    167 
    168 {{{
    169 #include <stdio.h>
    170 #include <cairo.h>
    171 #include <cairo-ps.h>
    172 #include <cups/cups.h>
    173 
    174 #include "cairobmp.h"
    175 
    176 #define WIDTH 480
    177 #define HEIGHT 500
    178 
    179 int main(int argc, char **argv) {
    180 
    181         int n;
    182 
    183         char tmpFilepath[] = "/tmp/tktprtXXXXXX";
    184 
    185 //  mkstemp(tmpFilepath);
    186         strcpy(tmpFilepath, "/tmp/tkt.bmp"); // TODO Easier name just for testing
    187         printf("tmpFilename [%s]\n", tmpFilepath);
    188 
    189         cairo_surface_t *surface = cairo_image_surface_create(CAIRO_FORMAT_A1, WIDTH, HEIGHT);
    190         printf("after surface create %d\n", cairo_surface_get_type(surface));
    191         cairo_t *context = cairo_create(surface);
    192 
    193         LoadBMPToSurface("/usr/images/cardinal_logo.bmp", surface, 0, 0);
    194 
    195         // draw some text
    196         cairo_select_font_face(context, "Arial Black", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
    197         cairo_set_font_size(context, 30);
    198         int x = 20;
    199         int y = 140;
    200         cairo_move_to(context, x, y);
    201         cairo_show_text(context, "Item 1"); // the text we got as a parameter
    202         y += 30;
    203         cairo_move_to(context, x, y);
    204         cairo_show_text(context, "Item 2"); // the text we got as a parameter
    205         y += 30;
    206         cairo_move_to(context, x, y);
    207         cairo_show_text(context, "Item 3"); // the text we got as a parameter
    208 
    209         // draw a dotted box
    210         const double pattern[] = { 15.0, 10.0 };
    211         cairo_set_dash(context, pattern, 2, 0);
    212         cairo_set_line_width(context, 5);
    213         cairo_rectangle(context, 5, 105, 400, 300);
    214         cairo_stroke(context);
    215 
    216         // finish up
    217         cairo_show_page(context);
    218         cairo_destroy(context);
    219         cairo_surface_flush(surface);
    220 
    221         CairoSurfaceToBMP(surface, tmpFilepath);
    222 
    223         cairo_surface_destroy(surface);
    224 
    225         const char *printerName = "STARSK1_311";
    226         n = cupsPrintFile(printerName, tmpFilepath, "825 ticket", 0, NULL);
    227         // return value is job ID
    228         printf("cupsPrintFile result %d\n", n);
    229 
    230         //unlink(tmpFilepath); // TODO This is commented to allow testing - after testing is done uncomment so after print the tmp file will be deleted
    231 
    232         return 0;
    233 }
    234 }}}
    235 
    236 Technical information:
    237239
    238240To allow access to the management pages on local network the cupsd.conf file must be edited.