Chameleon: Emulate a USB printer to test CUPS |
||||||||
Issue descriptionDoc describing the test needed: https://docs.google.com/document/d/1nurkWvHI_4lF0TqlYE7EhWwd1-IKIyW8IpQPo7Scc6E/edit Refer to: https://www.kernel.org/doc/Documentation/usb/gadget_printer.txt http://elixir.free-electrons.com/linux/v4.2/source/drivers/usb/gadget/legacy/printer.c Before we decide how to test CUPS, we need to evaluate the capability of g_printer on Chameleon.
,
Nov 21 2017
> With the g_printer module, I went through the flow of adding nearby printers, and print a page. Wow, nice start Jimmy. Can you share a screenshot on the settings 'Add nearby printer' page? So, printing dialog was good too?
,
Nov 22 2017
Hi Kalin, I put the screenshots in this folder: https://drive.google.com/corp/drive/u/0/folders/18y0XXJHtgtgbmQISO0hXp-MIZPTj3Afn I just select random manufacturer and model. The printing dialog looks ok too. I will play with the example code to see what can be done on chameleon side. Thanks!
,
Nov 22 2017
The following revision refers to this bug: https://chromium.googlesource.com/chromiumos/platform/chameleon/+/577907b08b3e9fd8f576b246a13376051c21448c commit 577907b08b3e9fd8f576b246a13376051c21448c Author: Cheng-Yi Chiang <cychiang@chromium.org> Date: Wed Nov 22 10:11:54 2017 updatable: Update kernel and modules for g_printer We can use g_printer to emulate a USB printer. BUG= chromium:787414 TEST=modprobe g_printer. On DUT side, check there is a USB printer. Add that printer from chrome://settings -> printer -> Add nearby printer. Print a page. (Printed content received on Chameleon side not verified yet.) Change-Id: I56b8e0a130daa9fc4a32a939b031f303b7d7c09f Reviewed-on: https://chromium-review.googlesource.com/781107 Commit-Ready: Cheng-Yi Chiang <cychiang@chromium.org> Tested-by: Cheng-Yi Chiang <cychiang@chromium.org> Reviewed-by: Wai-Hong Tam <waihong@google.com> [modify] https://crrev.com/577907b08b3e9fd8f576b246a13376051c21448c/updatable/fpga_tio/modules.tgz [modify] https://crrev.com/577907b08b3e9fd8f576b246a13376051c21448c/updatable/fpga_tio/zImage
,
Nov 22 2017
Great, Thanks Jimmy for these screenshots. Looks real :-) Is it possible to change the name or the way the printer gadget driver advertises itself, so we something much shorter and simple name label? BTW, did you notice a notification coming up from bottom-right. I guess so, b/c there is a printer icon on the shelf line next to the Play icon. Sean, what is the condition not to go through the 'manufacturer and model' screen? I remember testing USB connected printer at desk, I did not have to go through that step. No?
,
Nov 22 2017
For a USB printer, the id needs to match one of our known USB ids. The HP ids are here: http://www.gstatic.com/chromeos_printing/metadata_v2/usb-03f0.json
,
Nov 23 2017
Re#5: Hi Kalin, I modified iManufacturer so the name is shorter. There is no pop-op notification when I modprobe g_printer though. I need to go to chrome://settings to install it manually. Hi Sean, Thank you for the list. That is really helpful. Without that list, if I just randomly select a vendor and product, the printing job will fail (as attached messages) 2017-11-23T20:56:12.301761+08:00 NOTICE cupsd[26410]: [Job 13] PID 3 (/usr/libexec/cups/filter/foomatic-rip) stopped with status 9. 2017-11-23T20:56:20.303739+08:00 NOTICE cupsd[26410]: [Job 13] PID 4 (/usr/libexec/cups/backend/usb) exited with no errors. 2017-11-23T20:56:20.303827+08:00 ERR cupsd[26410]: [Job 13] Job stopped due to filter errors; please consult the error_log file for detail If I specify the vendor and product on Chameleon side, printing job will not get this error. Reading data on Chameleon side is important too. If I don't read data on Chameleon side, printing job will stuck in the 100% and does not give me a successful message. https://chromium-review.googlesource.com/#/c/chromiumos/platform/chameleon/+/781107/ https://chromium-review.googlesource.com/#/c/chromiumos/platform/chameleon/+/787514/ https://chromium-review.googlesource.com/#/c/chromiumos/platform/chameleon/+/787515/ are the needed Cls on Chameleon. I have listed all the steps in the commit messages of https://chromium-review.googlesource.com/#/c/chromiumos/platform/chameleon/+/787515/. If you want to see the demo, Kalin or Waihong might be able to help you. I also attach the binary that printer gadget received (read1.bin). It is consistent for printing certain file to certain model. I am not sure how to parse the binary, but checking the consistency is a good start for testing. On the other hand, I also tested how to emulate the bad status on printer: The example code provides three options: printer -not_selected printer -paper_out printer -error However, it seems that none of these bad status has any effect. The recorded binary was the same. We will need to look into the protocol to see how to emulate a printer in bad state. That might be P2 though.
,
Nov 23 2017
,
Nov 23 2017
,
Nov 27 2017
I see you wrote in the commit msg instructions "there will be successful messages pop out". This is great! Once the chameleon changes are in, I'll setup a DUT+chameleon host at desk.
,
Nov 28 2017
Yes, there will be a successful message about printing job, but not new nearyby printer. I am merging the needed changes. But, integrating that to chameleon daemon will take more times. Thanks!
,
Nov 28 2017
The following revision refers to this bug: https://chromium.googlesource.com/linux-fpga-chameleon/+/81daceb5b817da6229ca830f954ec8cebca2bafb commit 81daceb5b817da6229ca830f954ec8cebca2bafb Author: Cheng-Yi Chiang <cychiang@chromium.org> Date: Tue Nov 21 12:17:27 2017 ARM: socfpga: Enable g_printer Enable g_printer to emulate a USB printer. BUG= chromium:787414 TEST=modprobe g_printer Change-Id: Ie6de999cc5b7817f42da1451de3362b17ea14cea [modify] https://crrev.com/81daceb5b817da6229ca830f954ec8cebca2bafb/arch/arm/configs/socfpga_defconfig
,
Nov 30 2017
The following revision refers to this bug: https://chromium.googlesource.com/chromiumos/platform/chameleon/+/cab0c9b55a0720dd78b51446f0d4dd5a33a4fc01 commit cab0c9b55a0720dd78b51446f0d4dd5a33a4fc01 Author: Cheng-Yi Chiang <cychiang@chromium.org> Date: Thu Nov 30 15:09:39 2017 Add printer example code This is the example code from gadget printer documentation. https://www.kernel.org/doc/Documentation/usb/gadget_printer.txt BUG= chromium:787414 TEST=make && make remote-install $CHAMELEON_IP. Check there is printer binary on Chameleon. Change-Id: I7f4c5c8344a5cf99f605a3352e75f002ab6f8184 Reviewed-on: https://chromium-review.googlesource.com/787514 Commit-Ready: Cheng-Yi Chiang <cychiang@chromium.org> Tested-by: Cheng-Yi Chiang <cychiang@chromium.org> Reviewed-by: Wai-Hong Tam <waihong@google.com> [modify] https://crrev.com/cab0c9b55a0720dd78b51446f0d4dd5a33a4fc01/Makefile [add] https://crrev.com/cab0c9b55a0720dd78b51446f0d4dd5a33a4fc01/src/printer.c
,
Nov 30 2017
The following revision refers to this bug: https://chromium.googlesource.com/chromiumos/platform/chameleon/+/c9db1d0e8a5042044a755009ceacec28a8d00e62 commit c9db1d0e8a5042044a755009ceacec28a8d00e62 Author: Cheng-Yi Chiang <cychiang@chromium.org> Date: Thu Nov 30 15:09:40 2017 printer: Fix the device path On chameleon, the printer device created by g_printer is at /dev/printer0. Fix the path in printer.c. The full usage scenario: 1.. On Chameleon, emulate a printer. Connect middle USB port on Chameleon to Cros device. On Chameleon console: $ modprobe g_printer idVendor=0x03f0 idProduct=0x0004 iManufacturer=Chameleon Select idProduct from http://www.gstatic.com/chromeos_printing/metadata_v2/usb-03f0.json idVendor 0x03f0 is HP. Here we choose the first model with idProduct=0x0004. 2. On Cros deivce, check the device is detected with specified properties. $ lsusb -t, check Bus 001 Device 009: ID 03f0:0004 Hewlett-Packard DeskJet 895c Device Descriptor: bLength 18 bDescriptorType 1 bcdUSB 2.00 bDeviceClass 0 (Defined at Interface level) bDeviceSubClass 0 bDeviceProtocol 0 bMaxPacketSize0 64 idVendor 0x03f0 Hewlett-Packard idProduct 0x0004 DeskJet 895c bcdDevice 4.02 iManufacturer 1 Chameleon iProduct 2 Printer Gadget 3. On Cros device, install this printer. chrome://settings -> Advanced -> Printering -> Add printer -> -> Add manually -> Add nearby printers -> Select "Chameleon Printer Gadget (USB) Printer Gadget. 4. Download a PDF sample file: http://che.org.il/wp-content/uploads/2016/12/pdf-sample.pdf 5. On Chameleon, read in data from Cros device to /tmp/read1.bin $ printer -read_data > /tmp/read1.bin 6. On Cros device: print the PDF file Ctrl + P -> Select destination to be Chameleon Printer Gadget -> Print. The printing job should be finished in 1~2 seconds. There will be successful messages pop out. 7. On Chameleon, stop printer process in 5. Get /tmp/read1.bin 8. Repeat 5 and 6 and 7, the recorded binary should be the same. root@socfpga:~# md5sum /tmp/read1.bin a5ceb7aba2283143b29387e9a7a799ed /tmp/read1.bin root@socfpga:~# md5sum /tmp/read2.bin a5ceb7aba2283143b29387e9a7a799ed /tmp/read2.bin BUG= chromium:787414 TEST=Follow the test scenario as above. Change-Id: I42b45384597eaa7088cbe8a10da9f4386b8c99ec Reviewed-on: https://chromium-review.googlesource.com/787515 Commit-Ready: Cheng-Yi Chiang <cychiang@chromium.org> Tested-by: Cheng-Yi Chiang <cychiang@chromium.org> Reviewed-by: Sean Kau <skau@chromium.org> Reviewed-by: Wai-Hong Tam <waihong@google.com> [modify] https://crrev.com/c9db1d0e8a5042044a755009ceacec28a8d00e62/src/printer.c
,
Dec 1 2017
I followed the steps in +/787515 to verify printer can be set and jobs executed After installing chameleon (make remote-install ...), I updated the chameleon, but seems was not supposed to, as g_printer gadget module could not load? So I installed again(on top). It worked and the instructions were good and WAI. I had one printing error the first time I printed but every time after that it succeeded. A condition for the print job to proceed and succees(and not hang at 100%) is to execute 'printer -read_data'. md5 sum check string is same every time when same document printed. I think it is good base level verification for chameleon side golden file comparison.
,
Dec 2 2017
What I see also, is the printer does not need to be checked on FUND NEARBY PRINTERS popup. It automatically is added to the printers list on settings page, after being auto-discovered in the Print dialog's Local destinations printers list, and selecting it to print with, so directly send a print job.
,
Dec 2 2017
If the advertised USB ids match a known printer we let users select it in the print dialog without performing setup.
,
Mar 7 2018
Finally got time to finish the draft. remote: https://chromium-review.googlesource.com/#/c/chromiumos/platform/chameleon/+/952730 WIP printer: Add USB printer controller and configs remote: https://chromium-review.googlesource.com/#/c/chromiumos/platform/chameleon/+/952731 WIP system_tools: Add util to run subprocess and direct output to file remote: https://chromium-review.googlesource.com/#/c/chromiumos/platform/chameleon/+/952732 WIP printer: Add a device controller for USB printer remote: https://chromium-review.googlesource.com/#/c/chromiumos/platform/chameleon/+/952733 WIP printer: Expose printer to user I will clean them up and post for review. Hopefully we can finish the integration with autotest side in March.
,
Mar 13 2018
,
Mar 17 2018
Hi Kalin and Tom, the patch series ending at https://chromium-review.googlesource.com/#/c/chromiumos/platform/chameleon/+/952733/ are up for review. The control is simple so I let autotest access printer directly. Hi Kalin, with the patch series, you should be able to access printer directly through chameleon.printer in the autotest. Please let me know if you find any issue. Thanks!
,
Apr 3 2018
Is there anything else for these changes to get fully reviewed and checked in?
,
Apr 9 2018
Hi Kalin, I will fix the comments and make them merged. Sorry for the late response. Thanks!
,
Apr 9 2018
Thanks Jimmy, for looking into this. I look forward to be using chameleon.printer.
,
Apr 20 2018
The following revision refers to this bug: https://chromium.googlesource.com/chromiumos/platform/chameleon/+/9ee40e3e9f91489b8c9e88be44ac323bf5d3ae14 commit 9ee40e3e9f91489b8c9e88be44ac323bf5d3ae14 Author: Cheng-Yi Chiang <cychiang@chromium.org> Date: Fri Apr 20 07:32:49 2018 printer: Add USB printer controller and configs Add a class to hold config data for USB printer gadget driver. Add a class to control USB printer gadget driver. BUG= chromium:787414 TEST=use with later CL Change-Id: Ifcd6acf87a323be23cf4353f9b15bafd407ebba5 Reviewed-on: https://chromium-review.googlesource.com/952730 Commit-Ready: Cheng-Yi Chiang <cychiang@chromium.org> Tested-by: Cheng-Yi Chiang <cychiang@chromium.org> Reviewed-by: Wai-Hong Tam <waihong@google.com> Reviewed-by: Kalin Stoyanov <kalin@chromium.org> [add] https://crrev.com/9ee40e3e9f91489b8c9e88be44ac323bf5d3ae14/chameleond/utils/usb_printer_control.py [add] https://crrev.com/9ee40e3e9f91489b8c9e88be44ac323bf5d3ae14/chameleond/utils/usb_printer_configs.py
,
Apr 20 2018
The following revision refers to this bug: https://chromium.googlesource.com/chromiumos/platform/chameleon/+/534022cd4d2a3381fbdad52d33264f177a83207d commit 534022cd4d2a3381fbdad52d33264f177a83207d Author: Cheng-Yi Chiang <cychiang@chromium.org> Date: Fri Apr 20 07:32:50 2018 system_tools: Add util to run subprocess and direct output to file The printer binary outputs its data to stdout. We need a utility function to direct subprocess's stdout and stderr to a file. BUG= chromium:787414 Change-Id: Ia205592f873ee1060365f1f6daf9aa54c5f1653b Reviewed-on: https://chromium-review.googlesource.com/952731 Commit-Ready: Cheng-Yi Chiang <cychiang@chromium.org> Tested-by: Cheng-Yi Chiang <cychiang@chromium.org> Reviewed-by: Cheng-Yi Chiang <cychiang@chromium.org> [modify] https://crrev.com/534022cd4d2a3381fbdad52d33264f177a83207d/chameleond/utils/system_tools.py
,
Apr 20 2018
The following revision refers to this bug: https://chromium.googlesource.com/chromiumos/platform/chameleon/+/bbf9c9b231b453251d09c4454a8a6e2cf2c47928 commit bbf9c9b231b453251d09c4454a8a6e2cf2c47928 Author: Cheng-Yi Chiang <cychiang@chromium.org> Date: Fri Apr 20 07:32:51 2018 printer: Add a device controller for USB printer The control is simple so it does not need to be a flow. This device will be managed by device manager. Expose functions for printer: Reset Plug Unplug IsPlugged SetPrinterModel StartCapturingPrinterData StopCapturingPrinterData User will be able to access printer directly through proxy.printer after it is exposed by fpga_tio in the next CL. BUG= chromium:787414 TEST=use with the next CL. Change-Id: Ic01a8ad8382efe26179fbc5805aa0ff08f55c7ca Reviewed-on: https://chromium-review.googlesource.com/952732 Commit-Ready: Cheng-Yi Chiang <cychiang@chromium.org> Tested-by: Cheng-Yi Chiang <cychiang@chromium.org> Reviewed-by: Cheng-Yi Chiang <cychiang@chromium.org> [add] https://crrev.com/bbf9c9b231b453251d09c4454a8a6e2cf2c47928/chameleond/devices/usb_printer_device.py
,
Apr 20 2018
The following revision refers to this bug: https://chromium.googlesource.com/chromiumos/platform/chameleon/+/08eab5f8b7788353bbab2b699c15926fa9a3d7e2 commit 08eab5f8b7788353bbab2b699c15926fa9a3d7e2 Author: Cheng-Yi Chiang <cychiang@chromium.org> Date: Fri Apr 20 07:32:52 2018 printer: Expose printer to user through proxy User can use printer directly after getting chameleon proxy p. e.g. p.printer.Plug() p.printer.SetPrinterModel(1008, 17, 'hp officejet g55') p.printer.StartCapturingPrinterData() p.printer.StopCapturingPrinterData() p.printer.Reset() p.Reset() BUG= chromium:787414 TEST=Use test_server to set printer model and add printer in chrome://settings. Print an example PDF file and check the md5sum is always the same for a printer model. Change-Id: Ibdb886cfa1859c924d6781ec8fd2c56daf1a1897 Reviewed-on: https://chromium-review.googlesource.com/952733 Commit-Ready: Cheng-Yi Chiang <cychiang@chromium.org> Tested-by: Cheng-Yi Chiang <cychiang@chromium.org> Reviewed-by: Cheng-Yi Chiang <cychiang@chromium.org> Reviewed-by: Wai-Hong Tam <waihong@google.com> Reviewed-by: Kalin Stoyanov <kalin@chromium.org> [modify] https://crrev.com/08eab5f8b7788353bbab2b699c15926fa9a3d7e2/chameleond/utils/ids.py [modify] https://crrev.com/08eab5f8b7788353bbab2b699c15926fa9a3d7e2/chameleond/drivers/fpga_tio.py
,
Apr 23 2018
The code change on Chameleon side is done. We can track autotest side change separately. Thanks!
,
Apr 23 2018
Thanks a lot. I'll spend some time this week on the test side.
,
Jun 1 2018
The following revision refers to this bug: https://chromium.googlesource.com/chromiumos/third_party/autotest/+/1ea07aa29eb0eb59cac934d85600f4d8b303d1b5 commit 1ea07aa29eb0eb59cac934d85600f4d8b303d1b5 Author: Kalin Stoyanov <kalin@chromium.org> Date: Fri Jun 01 20:27:21 2018 Add e2e printing chameleon test UI driven test to print a sample pdf document. BUG= chromium:787414 TEST=Tested against local and lab environmemnt, Change-Id: I5a240bfb5653bd684b1975dcde4119b51e78bc6d Reviewed-on: https://chromium-review.googlesource.com/1074333 Commit-Ready: Kalin Stoyanov <kalin@chromium.org> Tested-by: Kalin Stoyanov <kalin@chromium.org> Reviewed-by: Kalin Stoyanov <kalin@chromium.org> [add] https://crrev.com/1ea07aa29eb0eb59cac934d85600f4d8b303d1b5/client/site_tests/platform_PrintJob/to_print.pdf [add] https://crrev.com/1ea07aa29eb0eb59cac934d85600f4d8b303d1b5/client/site_tests/platform_PrintJob/platform_PrintJob.py [add] https://crrev.com/1ea07aa29eb0eb59cac934d85600f4d8b303d1b5/client/site_tests/platform_PrintJob/control [modify] https://crrev.com/1ea07aa29eb0eb59cac934d85600f4d8b303d1b5/client/cros/chameleon/chameleon.py [add] https://crrev.com/1ea07aa29eb0eb59cac934d85600f4d8b303d1b5/client/cros/input_playback/keyboard_ctrl+p
,
Jun 25 2018
Test is running and looks good - https://stainless.corp.google.com/search?exclude_retried=true&exclude_non_production=true&exclude_acts=true&exclude_non_release=true&exclude_au=true&suite=chameleon_peripherals&exclude_not_run=true&row=build&col=board&view=matrix&days=15 |
||||||||
►
Sign in to add a comment |
||||||||
Comment 1 by cychiang@chromium.org
, Nov 21 2017