| | 8 | |
| | 9 | |
| | 10 | == CUPS management web pages == |
| | 11 | |
| | 12 | |
| | 13 | The cups management pages should appear at http://<ip_address_of_indicator>:631 |
| | 14 | |
| | 15 | 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. |
| | 16 | |
| | 17 | Adding "/admin" to the url shows the administration page, but it is missing style information. |
| | 18 | |
| | 19 | 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. |
| | 20 | |
| | 21 | [[Image(cups_mainpage.png)]] |
| | 22 | |
| | 23 | |
| | 24 | Check a Windows PC that is already configured to use the desired network printer. |
| | 25 | |
| | 26 | [[Image(windows_printer_properties.png)]] |
| | 27 | |
| | 28 | This shows the IP address of the printer. |
| | 29 | |
| | 30 | Click "Administration" on the 825 CUPS page. |
| | 31 | |
| | 32 | [[Image(cups_admin.png)]] |
| | 33 | |
| | 34 | Click "Add Printer." |
| | 35 | |
| | 36 | [[Image(cups_sign_in.png)]] |
| | 37 | |
| | 38 | Type 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 | |
| | 44 | Select the printer that looks correct in the list and click "Continue". |
| | 45 | |
| | 46 | [[Image(cups_add_printer_name.png)]] |
| | 47 | |
| | 48 | Make 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 | |
| | 52 | Select the "Model:" "driverless" and click "Add Printer". |
| | 53 | |
| | 54 | [[Image(cups_set_printer_options.png)]] |
| | 55 | |
| | 56 | Click "Set Default Options." |
| | 57 | |
| | 58 | [[Image(cups_set_default_options_success.png)]] |
| | 59 | |
| | 60 | The page should change to show "default options have been set successfully." |
| | 61 | |
| | 62 | [[Image(cups_printer_info.png)]] |
| | 63 | |
| | 64 | Select the maintenance drop down. |
| | 65 | |
| | 66 | [[Image(cups_maintenance_dropdown.png)]] |
| | 67 | |
| | 68 | Select "Print Test Page." |
| | 69 | |
| | 70 | [[Image(cups_unable_to_print_test_page.png)]] |
| | 71 | |
| | 72 | This feature does not currently work. Will investigate further. |
| | 73 | |
| | 74 | Maybe printer test page is also part of cups-doc recipe. |
| | 75 | {{{ |
| | 76 | card825gen2:~$ cat /home/admin/test.txt |
| | 77 | test 123 |
| | 78 | }}} |
| | 79 | |
| | 80 | {{{ |
| | 81 | card825gen2:~$ lp -d "Canon_iR-ADV_4545_4551_III_UFR_II" /home/admin/test.txt |
| | 82 | request id is Canon_iR-ADV_4545_4551_III_UFR_II-31 (1 file(s)) |
| | 83 | }}} |
| | 84 | |
| | 85 | Page printed with top line "test 123" successfully |
| | 86 | |
| | 87 | [[Image(cups_jobs1.png)]] |
| | 88 | |
| | 89 | {{{ |
| | 90 | card825gen2:~$ lp -d "Canon_iR-ADV_4545_4551_III_UFR_II" /usr/images/startup.png |
| | 91 | request id is Canon_iR-ADV_4545_4551_III_UFR_II-32 (1 file(s)) |
| | 92 | }}} |
| | 93 | |
| | 94 | The PNG file did not print. |
| | 95 | |
| | 96 | {{{ |
| | 97 | card825gen2:~$ lp -d "Canon_iR-ADV_4545_4551_III_UFR_II" /usr/images/cardinal_logo.bmp |
| | 98 | request id is Canon_iR-ADV_4545_4551_III_UFR_II-33 (1 file(s)) |
| | 99 | }}} |
| | 100 | |
| | 101 | The cardinal_logo did print. |
| | 102 | |
| | 103 | Maybe png files do not work, but bmp files do. |
| | 104 | |
| | 105 | [[Image(cups_jobs2.png)]] |
| | 106 | |
| | 107 | |
| | 108 | Printing 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 | |
| | 121 | int 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 == |
| 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: |