On Tue, Feb 19, 2008 at 9:48 AM, Daniel Strobl <[EMAIL PROTECTED]> wrote:
> Thank You for the reply, the printer is USB-native, so it hat an 
> USB-interface. We already use javax.comm fpr parallel and serial connections 
> with success.

The printer having a USB plug does NOT mean it is "USB-native".

>  But the Problem is solved. I just talked to Star and they told me that TSP 
> 143 is not natively supporting ESC-POS. Therefore javax.usb was talking to 
> the printer, but the printer simply ignored my messages

Ok then, good luck.

>
>
>
>
>  -----Ursprüngliche Nachricht-----
>  Von: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Im Auftrag von Dan Streetman
>  Gesendet: Dienstag, 19. Februar 2008 15:37
>  An: Daniel Strobl
>  Cc: [email protected]
>  Betreff: Re: [javax-usb-devel] Star POS linux USB
>
>  Is this printer really a RS232 device that has a USB<->RS232 converter
>  inside it or attached to it?  If so, you should use javax.comm to talk
>  to it, not javax.usb.  What device node do you tell cups to print on?
>
>  On Feb 19, 2008 3:12 AM, Daniel Strobl <[EMAIL PROTECTED]> wrote:
>  > Hello,
>  >
>  > I need to translate a printer driver from parallel to USB. I have a Star 
> TSP
>  > 143, which supports ESCPOS. I have been using RXTX to talk to the printer
>  > over /dev/lp0.
>  >
>  > My code already retrieves the status of the printer, which tells me if it 
> is
>  > out of paper and forth.
>  >
>  > But I am not able to get the printer to print. Therefore I have sniffed the
>  > USB port once when printing with CUPS. And once when talking to it via
>  > javax.usb.
>  >
>  > The difference between CUPS and javax.usb is the interrupt-events when
>  > printing with CUPS. It seems to me that the kernel usblp-Modules does use
>  > interrupts to send data to the printer.
>  >
>  > Is the a way to tell javax.usb to use interrupts or am I doing something
>  > wrong in general?
>  >
>  >
>  > The Code:
>  >
>  > public class USBTest implements UsbPipeListener, UsbDeviceListener {
>  >
>  >                 public static final byte PRN_CLASS = 0x07;
>  >                 public static final byte PRN_SUBCLASS_BOOT_INTERFACE = 
> 0x01;
>  >                 public static final byte PROTOCOL_PRN = 0x02;
>  >
>  >                 public static void main(String argv[]) throws
>  > UnsupportedEncodingException, UsbDisconnectedException, UsbException,
>  > UsbNotActiveException, UsbNotOpenException, IllegalArgumentException,
>  > InterruptedException
>  >                 {
>  >                                UsbHub virtualRootUsbHub =
>  > ShowTopology.getVirtualRootUsbHub();
>  >                                List<InterfaceWithDeviceBag>  usbInterfaces 
> =
>  > FindUsbInterface.getUsbInterfacesWithInterfaceClass(virtualRootUsbHub,
>  > PRN_CLASS);
>  >                                for (InterfaceWithDeviceBag
>  > bag:usbInterfaces) {
>  >                                                UsbInterface usbInterface =
>  > bag.interf;
>  >
>  >                                                UsbInterfaceDescriptor desc 
> =
>  > usbInterface.getUsbInterfaceDescriptor();
>  >
>  >                                                if
>  > (PRN_SUBCLASS_BOOT_INTERFACE == desc.bInterfaceSubClass() && PROTOCOL_PRN 
> ==
>  > desc.bInterfaceProtocol()) {
>  >
>  > System.err.println("Drucker gefunden:
>  > "+bag.device.getManufacturerString()+bag.device.getProductString());
>  >                                                }
>  >                                                testPrint(bag.interf,
>  > bag.device);
>  >                                }
>  >                 }
>  >
>  >                 public static void testPrint(UsbInterface usbInterface,
>  > UsbDevice usbDevice) throws UsbNotActiveException, UsbNotOpenException,
>  > IllegalArgumentException, UsbDisconnectedException, UsbException,
>  > InterruptedException
>  >                 {
>  >                                UnicodeTranslator trans=new
>  > UnicodeTranslatorInt();
>  >                                usbDevice.addUsbDeviceListener(new
>  > USBTest());
>  >
>  >                                try {
>  >                                                usbInterface.claim(new
>  > UsbInterfacePolicy() {
>  >                                                                public
>  > boolean forceClaim(UsbInterface usbinterface) {
>  >
>  >   return true;
>  >                                                                }
>  >                                                });
>  >                                } catch ( UsbException uE ) {
>  >                                                System.out.println("Could 
> not
>  > claim interface to USB printer (remove module usblp)!!! : " +
>  > uE.getMessage());
>  >                                                return;
>  >                                }
>  >
>  >                                List usbEndpoints =
>  > usbInterface.getUsbEndpoints();
>  >
>  >                                UsbEndpoint usbEndpoint_in = null;
>  >                                UsbEndpoint usbEndpoint_out = null;
>  >
>  >                                for (int i=0; i<usbEndpoints.size(); i++) {
>  >                                                UsbEndpoint usbEndpoint_tmp 
> =
>  > (UsbEndpoint)usbEndpoints.get(i);
>  >
>  >
>  >
>  > if(UsbConst.ENDPOINT_DIRECTION_IN == usbEndpoint_tmp.getDirection())
>  >
>  > usbEndpoint_in=usbEndpoint_tmp;
>  >                                                else
>  > if(UsbConst.ENDPOINT_DIRECTION_OUT == usbEndpoint_tmp.getDirection())
>  >
>  > usbEndpoint_out=usbEndpoint_tmp;
>  >
>  >                                                System.err.println("endpoint
>  > no "+i);
>  >
>  >                                }
>  >                                if(usbEndpoint_in==null){
>  >                                                System.err.println("No USB 
> IN
>  > Endpoint");
>  >                                                return;
>  >                                }
>  >                                if(usbEndpoint_out==null){
>  >                                                System.err.println("No USB
>  > OUT Endpoint");
>  >                                                return;
>  >                                }
>  >
>  >
>  >                                UsbPipe usbPipe_out =
>  > usbEndpoint_out.getUsbPipe();
>  >                                UsbPipe usbPipe_in =
>  > usbEndpoint_in.getUsbPipe();
>  >
>  >                                try {
>  >                                                usbPipe_out.open();
>  >                                                usbPipe_in.open();
>  >                                                System.err.println("hatkein
>  > papier?:"+isPrinterError(usbPipe_in));
>  >
>  >
>  > usbPipe_in.addUsbPipeListener(new USBTest());
>  >
>  > //usbPipe_out.addUsbPipeListener(new USBTest());
>  >                                } catch ( UsbException uE ) {
>  >
>  >                                                System.out.println("Could 
> not
>  > open out endpoint to communicate with USB Printer : " + uE.getMessage());
>  >                                                try { 
> usbInterface.release();
>  > }
>  >                                                catch ( UsbException uE2 ) {
>  >                                                }
>  >                                                return;
>  >                                }
>  >
>  >                                 // INIT
>  >                                 UsbIrp irp=usbPipe_out.createUsbIrp();
>  >
>  > irp.setData(joinArray(StarComConstants.INIT_PRINTER,new
>  > byte[]{0x1b,'U','0'}));
>  >                                 usbPipe_out.syncSubmit(irp);
>  >
>  >                                System.err.println("after init");
>  >                                 byte[] bytesToRead = new byte[64];
>  >                                 UsbIrp irpRead = usbPipe_in.createUsbIrp();
>  >                                irpRead.setData(bytesToRead);
>  >                                usbPipe_in.asyncSubmit(irpRead);
>  >                                irpRead.waitUntilComplete(1000);
>  >                                for(int i=0;i<10;i++){
>  >
>  > System.err.println(bytesToRead[i]);
>  >                                }
>  >
>  >                                // PAPER
>  >                                 irp=usbPipe_out.createUsbIrp();
>  >
>  >  
> irp.setData(joinArray(StarComConstants.SELECT_PRINTER,StarComConstants.SET_
>  > PAPERWIDTH_80MM));
>  >                                 usbPipe_out.syncSubmit(irp);
>  >
>  >
>  >                                System.err.println("after set paper");
>  >                                bytesToRead = new byte[64];
>  >                                irpRead = usbPipe_in.createUsbIrp();
>  >                                irpRead.setData(bytesToRead);
>  >                                usbPipe_in.asyncSubmit(irpRead);
>  >                                irpRead.waitUntilComplete(1000);
>  >                                for(int i=0;i<10;i++){
>  >
>  > System.err.println(bytesToRead[i]);
>  >                                }
>  >
>  >
>  >                                // drucke was !!
>  >                              irp=usbPipe_out.createUsbIrp();
>  >                                 irp.setData(joinArray(
>  >                                           joinArray(
>  >
>  >                                   
> joinArray(StarComConstants.IGNORE_SEQ_CMD,
>  >   ESCPOS.CHAR_FONT_3), ESCPOS.CHAR_SIZE_3),"please
>  > print\n\n\n\n\n\n\n\n\n\n".getBytes())
>  >                                );
>  >
>  >                                 usbPipe_out.syncSubmit(irp);
>  >
>  >                                 System.err.println("after drucke du sau");
>  >                                 bytesToRead = new byte[64];
>  >                                 IrpRead = usbPipe_in.createUsbIrp();
>  >                                 irpRead.setData(bytesToRead);
>  >                                usbPipe_in.asyncSubmit(irpRead);
>  >                                irpRead.waitUntilComplete(1000);
>  >                                for(int i=0;i<10;i++){
>  >
>  > System.err.println(bytesToRead[i]);
>  >                                }
>  >
>  >                                Thread.sleep(1000);
>  >
>  >                                try {
>  >                                                usbPipe_out.close();
>  >                                                usbPipe_in.close();
>  >                                                usbInterface.release();
>  >                                } catch ( UsbException uE ) {
>  >                                                uE.printStackTrace();
>  >                                }
>  >
>  >                 }
>  >
>  >                 private static boolean isPrinterError(UsbPipe pipe) throws
>  > IllegalArgumentException, UsbDisconnectedException, UsbException{
>  >                                 UsbControlIrp getUsageIrp =
>  > pipe.createUsbControlIrp((byte)(UsbConst.REQUESTTYPE_DIRECTION_IN |
>  > UsbConst.REQUESTTYPE_TYPE_STANDARD |
>  > UsbConst.REQUESTTYPE_RECIPIENT_INTERFACE)
>  >                                                                , 
> (byte)0x01,
>  > (short)0,(short)0 );
>  >
>  >                                byte[] data = new byte[256];
>  >                                getUsageIrp.setData(data);
>  >
>  >                                pipe.syncSubmit(getUsageIrp);
>  >
>  >                                if(getUsageIrp.getActualLength()>=3){
>  >
>  > if(getUsageIrp.getData()[2]!=0){
>  >                                                                return true;
>  >                                                }
>  >                                }
>  >                                if(getUsageIrp.getActualLength()>=6){
>  >
>  > if(getUsageIrp.getData()[2]!=0){
>  >                                                                return true;
>  >                                                }
>  >                                }
>  >                                return false;
>  >                 }
>  >
>  >                 private static byte[] joinArray(byte[] a1,byte[] a2){
>  >                                byte[] r=new byte[a1.length+a2.length];
>  >                                int i=0;
>  >                                for(i=0;i<a1.length;i++){
>  >                                                r[i]=a1[i];
>  >                                }
>  >                                for(int j=0;j<a2.length;j++){
>  >                                                r[i+j]=a2[j];
>  >                                }
>  >                                return r;
>  >                 }
>  >
>  >                 public void dataEventOccurred(UsbPipeDataEvent
>  > usbpipedataevent) {
>  >                                System.err.println("data
>  > "+usbpipedataevent.getData());
>  >                 }
>  >                 public void errorEventOccurred(UsbPipeErrorEvent
>  > usbpipeerrorevent) {
>  >                                System.err.println("error
>  > "+usbpipeerrorevent.getUsbPipe().getUsbEndpoint().getDirection());
>  >                 }
>  >                 public void dataEventOccurred(UsbDeviceDataEvent
>  > usbdevicedataevent) {
>  >                                System.err.println("dataevent device");
>  >                 }
>  >                 public void errorEventOccurred(UsbDeviceErrorEvent
>  > usbdeviceerrorevent) {
>  >                                System.err.println("errorevent device");
>  >                 }
>  >                 public void usbDeviceDetached(UsbDeviceEvent 
> usbdeviceevent)
>  > {
>  >                                System.err.println("device detached 
> device");
>  >                 }
>  > }
>  >
>  >
>  > Sniff CUPS:
>  >
>  > …
>  > f7eb5ec0 297629823 C Bi:007:01 0 9 = 23060000 00000000 00 f7eb5ec0 
> 297629864
>  > S Bi:007:01 -115 8192 < f7eb5ec0 297630823 C Bi:007:01 0 9 = 23060000
>  > 00000000 00 f7eb5ec0 297630863 S Bi:007:01 -115 8192 < f7eb5ec0 297631825 C
>  > Bi:007:01 0 9 = 23060000 00000000 00 f7eb5ec0 297631867 S Bi:007:01 -115
>  > 8192 < f7eb5ec0 297632822 C Bi:007:01 0 9 = 23060000 00000000 00 f7eb5ec0
>  > 297632862 S Bi:007:01 -115 8192 < f7eb5ec0 297633823 C Bi:007:01 0 9 =
>  > 23060000 00000000 00 f7eb5ec0 297633864 S Bi:007:01 -115 8192 < f7eb5ec0
>  > 297634822 C Bi:007:01 0 9 = 23060000 00000000 00 f7eb5ec0 297634864 S
>  > Bi:007:01 -115 8192 < f7eb5ec0 297635823 C Bi:007:01 0 9 = 23060000 
> 00000000
>  > 00 f7eb5ec0 297635864 S Bi:007:01 -115 8192 < f7eb5ec0 297636823 C 
> Bi:007:01
>  > 0 9 = 23060000 00000000 00 f7eb5ec0 297637290 S Bi:007:01 -115 8192 <
>  > df8cd240 297637370 S Bo:007:02 -115 8192 = 1b401b1e 41001b2a 72521b2a
>  > 72411b2a 72513000 1b2a7250 30001b2a 72543200 f7eb5ec0 297637824 C Bi:007:01
>  > 0 9 = 23060000 00000000 00 df8cd240 297733849 C Bo:007:02 0 8192 > f7eb5ec0
>  > 297734012 S Bi:007:01 -115 8192 < df8cd240 297734134 S Bo:007:02 -115 8192 
> =
>  > 20625000 c0000000 00000000 00000000 00000000 00000000 00000000 00000000
>  > f7eb5ec0 297734841 C Bi:007:01 0 9 = 23060000 00000000 00 df8cd240 
> 297771843
>  > C Bo:007:02 0 8192 > f7eb5ec0 297771918 S Bi:007:01 -115 8192 < df8cd240
>  > 297772040 S Bo:007:02 -115 8192 = 44440000 00000000 00000dde dfffffdf
>  > ffffffff ffffffff fffffefe ec000000 f7eb5ec0 297772841 C Bi:007:01 0 9 =
>  > 23060000 00000000 00 df8cd240 297809844 C Bo:007:02 0 8192 > f7eb5ec0
>  > 297809925 S Bi:007:01 -115 8192 < df8cd240 297810045 S Bo:007:02 -115 8192 
> =
>  > c0000600 00000000 00000000 00000480 00000000 00000000 04800000 00000000
>  > f7eb5ec0 297810840 C Bi:007:01 0 9 = 23060000 00000000 00 df8cd240 
> 297847843
>  > C Bo:007:02 0 8192 > f7eb5ec0 297847916 S Bi:007:01 -115 8192 < df8cd240
>  > 297848028 S Bo:007:02 -115 8192 = 00000000 00000000 00000000 00000000
>  > 00000000 00000000 00000000 00000000 f7eb5ec0 297848839 C Bi:007:01 0 9 =
>  > 23060000 00000000 00 df8cd240 297885843 C Bo:007:02 0 8192 > f7eb5ec0
>  > 297885873 S Bi:007:01 -115 8192 < df8cd240 297885929 S Bo:007:02 -115 8192 
> =
>  > 10000000 00000000 00000007 9ee10e49 ee072e3b 7edc0000 00000000 0000002a
>  > f7eb5ec0 297886840 C Bi:007:01 0 9 = 23060000 00000000 00 df8cd240 
> 297923842
>  > C Bo:007:02 0 8192 > f7eb5ec0 297923872 S Bi:007:01 -115 8192 < df8cd240
>  > 297923929 S Bo:007:02 -115 8192 = 00000000 00000000 00000000 00000000
>  > 00000000 00000000 000000d0 00000030 f7eb5ec0 297924839 C Bi:007:01 0 9 =
>  > 23060000 00000000 00 df8cd240 297961809 C Bo:007:02 0 8192 > f7eb5ec0
>  > 297961839 S Bi:007:01 -115 8192 < df8cd240 297961896 S Bo:007:02 -115 8192 
> =
>  > 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
>  > f7eb5ec0 297962840 C Bi:007:01 0 9 = 23060000 00000000 00 df8cd240 
> 297999829
>  > C Bo:007:02 0 8192 > f7eb5ec0 297999899 S Bi:007:01 -115 8192 < df8cd240
>  > 297999954 S Bo:007:02 -115 8192 = 00000000 00000000 00000000 00000000
>  > 00000000 00000000 3ffffff0 20625000 f7eb5ec0 298000825 C Bi:007:01 0 9 =
>  > 23060000 00000000 00 df8cd240 298037847 C Bo:007:02 0 8192 > f7eb5ec0
>  > 298037915 S Bi:007:01 -115 8192 < df8cd240 298037975 S Bo:007:02 -115 1930 
> =
>  > 00000000 00000044 40000000 00000000 02220000 00000000 00001030 00000000
>  > f7eb5ec0 298038842 C Bi:007:01 0 9 = 23060000 00000000 00 df8cd240 
> 298046804
>  > C Bo:007:02 0 1930 > f7eb5ec0 298046834 S Bi:007:01 -115 8192 < f7eb5ec0
>  > 298047840 C Bi:007:01 -2 0
>  >
>  > Sniff my program:
>  >
>  > cde0c340 416027332 S Ci:001:00 s 80 08 0000 0000 0001 1 < cde0c340 
> 416027350
>  > C Ci:001:00 0 1 = 01 cde0c340 416028088 S Ci:004:00 s 80 08 0000 0000 0001 
> 1
>  > < cde0c340 416029341 C Ci:004:00 0 1 = 01 cde0c340 416029441 S Ci:007:00 s
>  > 80 08 0000 0000 0001 1 < cde0c340 416030336 C Ci:007:00 0 1 = 01 cde0cec0
>  > 420587767 S Ci:001:00 s 80 06 0300 0000 0100 256 < cde0cec0 420587772 C
>  > Ci:001:00 0 4 = 04030904 cde0cec0 420588010 S Ci:001:00 s 80 06 0303 0409
>  > 0100 256 < cde0cec0 420588014 C Ci:001:00 0 57 = 38034c00 69006e00 75007800
>  > 20003200 2e003600 2e003100 38002d00 34002d00 cde0c3c0 420588624 S Ci:004:00
>  > s 80 06 0300 0000 0100 256 < cde0c3c0 420591317 C Ci:004:00 0 4 = 04030904
>  > cde0c3c0 420592017 S Ci:004:00 s 80 06 0301 0409 0100 256 < cde0c3c0
>  > 420593316 C Ci:004:00 0 50 = 06033300 4d002e03 33004d00 20004500 58002000
>  > 49004900 20005500 53004200 e33aba40 420642687 S Ci:007:00 s 80 06 0300 0000
>  > 0100 256 < e33aba40 420645317 C Ci:007:00 0 4 = 04030904 e33aba40 420649041
>  > S Ci:007:00 s 80 06 0301 0409 0100 256 < e33aba40 420650315 C Ci:007:00 0 
> 10
>  > = 0a035300 54004100 5200 e33aba40 420652871 S Ci:007:00 s 80 06 0302 0409
>  > 0100 256 < e33aba40 420654315 C Ci:007:00 0 24 = 18035300 74006100 72002000
>  > 54005300 50003100 34003300 f7eb5ec0 420659650 S Co:007:00 s 01 0b 0000 0000
>  > 0000 0 f7eb5ec0 420660317 C Co:007:00 0 0 f7eb5ec0 420663332 S Bo:007:02
>  > -115 5 = 1b401b55 30 f7eb5ec0 420664317 C Bo:007:02 0 5 > f7eb5ec0 
> 420670248
>  > S Bi:007:01 -115 64 < f7eb5ec0 420671318 C Bi:007:01 0 9 = 23060000 
> 00000000
>  > 00 f7eb5ec0 420675113 S Bo:007:02 -115 7 = 1b3d011b 1e4100 f7eb5ec0
>  > 420675316 C Bo:007:02 0 7 > f7eb5ec0 420681094 S Bi:007:01 -115 64 <
>  > f7eb5ec0 420681315 C Bi:007:01 0 9 = 23060000 00000000 00 f7eb5ec0 
> 420685515
>  > S Bo:007:02 -115 24 = 1b421b4d 311d2131 66736473 64660a0a 0a0a0a0a 0a0a0a0a
>  > f7eb5ec0 420686315 C Bo:007:02 0 24 > f7eb5ec0 420689250 S Bi:007:01 -115 
> 64
>  > < f7eb5ec0 420690316 C Bi:007:01 0 9 = 23060000 00000000 00 df9c09c0
>  > 421751372 S Co:007:00 s 01 0b 0000 0000 0000 0 df9c09c0 421753315 C
>  > Co:007:00 0 0
>  >
>  >
>  > -------------------------------------------------------------------------
>  > This SF.net email is sponsored by: Microsoft
>  > Defy all challenges. Microsoft(R) Visual Studio 2008.
>  > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
>  > _______________________________________________
>  > javax-usb-devel mailing list
>  > [email protected]
>  > https://lists.sourceforge.net/lists/listinfo/javax-usb-devel
>  >
>  >
>
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
javax-usb-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/javax-usb-devel

Reply via email to