B4A Library ECS/POS printer USB print library

Discussion in 'Additional libraries, classes and official updates' started by hears, Dec 11, 2017.

  1. hears

    hears Active Member Licensed User

    i do not know java,and never use eclipse before, i study make libary 1 week,now have self library now )
    i have test this code many times, it is really hardly work for me,
    here cannot upload my eclipse project,it is too big,how to upload it ?
    if this library can help you ,i will send my eclips project .my java is poor,
    if i upload eclips project ,you can make this libary more better then me.

    i have test on my pos printer,work good now ,can print picture.string

    my print device use default ".connectusb" fuction, if you change print device need ".connectusb2" instead.

    and you need get your usb" VendorID , productID"
    how to get your print device ID ,here have picture .(do not forget add 0x before your IDs)

    the ".printdata"fuction ,you can send HEX code to printer. it is is printer control code.in PDF file have EPSON FAQ, in FAQ,the Turn "white/black reverse "command "1d 42", MUST change to under FORMAT SEND:
    "0x1d, 0x42, 0x01". (0x01 must put in end. and add 0x)

    In mainfest need add usb permition :
        <action android:name=
    "android.hardware.usb.action.USB_DEVICE_ATTACHED" />

    under is b4a sample code

    #Region  Project Attributes
    #ApplicationLabel: B4A Example
    #VersionCode: 1
    'SupportedOrientations possible values: unspecified, landscape or portrait.
        #SupportedOrientations: unspecified
    #CanInstallToExternalStorage: False
    #BridgeLogger: True
    #End Region

    #Region  Activity Attributes
    #FullScreen: False
    #IncludeTitle: True
    #End Region

    Sub Process_Globals
    'These global variables will be declared once when the application starts.
        'These variables can be accessed from all modules.

    End Sub

    Sub Globals
    Dim pt As  printdemo
    End Sub

    Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:

    End Sub

    Sub Activity_Resume

    End Sub

    Sub Activity_Pause (UserClosed As Boolean)

    End Sub

    Sub Button1_Click
    Dim vid As Int
    Dim pid As Int
    'HERE IS YOU DEVICE VendorID AND productID"
    End Sub

    Sub Button2_Click
    End Sub

    Sub Button3_Click
    Dim pic As Bitmap
    300,0))   '(PICTURE,PAPER WIDTH,0)
        pt.Printbeep 'VOICE BEEP
    End Sub

    Attached Files:

    Last edited: Dec 11, 2017
    jcohedman, Levit, f0raster0 and 4 others like this.
  2. scsjc

    scsjc Active Member Licensed User

    Hello, nice library
    is possible print to bluetooth printers with this library ?

  3. hears

    hears Active Member Licensed User

    bluetooth cannot,my printer only have wifi and usb
    ,next step will writ WIFI print
  4. scsjc

    scsjc Active Member Licensed User

    Thanks !
  5. hears

    hears Active Member Licensed User

    THIS IS EPSON HEX COMMAND FAQ,IT CAN SEND BY ".printdata" function

    Attached Files:

  6. hears

    hears Active Member Licensed User

  7. fifiddu70

    fifiddu70 Well-Known Member Licensed User

    i have this error when push button1:
    Logger connesso a: WIKO U FEEL
    --------- beginning of crash
    --------- beginning of main
    *** Service (starter) Create ***
    ** Service (starter) Start **
    ** Activity (main) Create, isFirst = true **
    ** Activity (main) Resume **

    main_button1_click (java line: 371)
    java.lang.ArrayIndexOutOfBoundsException: length=8; index=8
    at cn.com.zj.usbdemo.PrintDemo.connectusb2(PrintDemo.java:1353)
    at b4a.example.main._button1_click(main.java:371)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:191)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:175)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:171)
    at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:80)
    at android.view.View.performClick(View.java:5265)
    at android.view.View$PerformClick.run(View.java:21534)
    at android.os.Handler.handleCallback(Handler.java:815)
    at android.os.Handler.dispatchMessage(Handler.java:104)
    at android.os.Looper.loop(Looper.java:207)
    at android.app.ActivityThread.main(ActivityThread.java:5728)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:679)
  8. hears

    hears Active Member Licensed User

    you need get your usb info,after change this 2 value

    Dim vid As Int
    Dim pid As Int
    'HERE IS YOU DEVICE VendorID AND productID"
    need download andriod shell APP to get this,
  9. hears

    hears Active Member Licensed User

    this libary not work with all USB printer, only usb pos print
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice