Dan, Thanks for your replay. I think the point is in this part of code: try{ UsbIrp irp = usbPipe.createUsbIrp( ); FileInputStream inStream=new FileInputStream("/root/workspace/fwdl-java/test.txt"); byte[] buffer =new byte[maxPacketSize]; irp.setData(buffer); while ((iReadnum = inStream.read(buffer)) != -1) { usbPipe.syncSubmit(irp); irp.setComplete(false); } } catch (UsbException uE) { System.out.println("Unable to submit data buffer to HID mouse : " + uE.getMessage()); } catch(Exception e) { }
I have debug this code, no exception has been thrown out. And the "syncSubmit(irp)" function has no return value. The actual length of the irp data is correct, and there is no irp exception either. I changed the buffer size to 1024, but the result was the same. Every time about 77 bytes' data was printed out. The whole file is about 3k. I do not know "submit multiple times" is right or not? However, it seems to work, as I have printed two buffers content to one page(one buffer 64 bytes). I have tried to submit the whole file in one time , but the result was still the same. Maybe as you said, the problem is something with the protocol. On windows ,I treat the printer device as a file and write data into it, so I have no sense to care about the protocol. Any other advice from you? Ric Best Regards. -----Original Message----- From: Dan Streetman Sent: Wednesday, November 07, 2007 1:13 PM To: Xie, Ric Cc: javax-usb-devel@lists.sourceforge.net Subject: Re: [javax-usb-devel] Write to the printer! You didn't mention whether you know what your printer protocol is and know you are using it correctly, or if you are completely guessing about the protocol. If you don't know the protocol, I can't help you, as I think most printer protocols are rather complicated. However, I'll assume that you know your protocol and are using it correctly. I suggest to use larger buffers; with bulk you are not limited to the max packet size. Try 1k or more. Also, you may want to use async instead of sync. Finally, are you calling submit multiple times? You only said basically "it didn't work" but did not elaborate at all. Are you reading the entire file? Is there an exception? What is the return value from the submission (including the irp exception if any, the irp transferred length, etc)? You aren't checking any status from the submission. ------------------------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/ _______________________________________________ javax-usb-devel mailing list javax-usb-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/javax-usb-devel