Android Question how to Auto-cut thermal receipt in a printer Bluetooth? (Solved)

f0raster0

Well-Known Member
Licensed User
Longtime User
Hi, my new printer Bluetooth just arrived this morning
it works great using the codes here and here

question: Does anyone know how to setup the autocut (autocut the paper)?
this is the printer, I thought it should be automatic

thanks
 
Solution
B4X:
...
Sub Printer_Connected (Success As Boolean)
    If Success Then
        Printer.Initialize2(BTConnection.OutputStream,"windows-1252") 'important to print f.e. German/French chars
        PrintBuffer=Chr(27)&"t"&Chr(16)&"Hello" 'Set codepage 1252
        Printer.WriteLine(PrintBuffer)
        PrintBuffer=Chr(29) & Chr(86) & Chr(48)
        Printer.WriteLine(PrintBuffer) '<-------- YOU FORGET THIS
        Printer.Flush 'limpia la impresora
        Msgbox("Printed!","")
        Printer.Close
        BTConnection.Disconnect 'disable this if you like
    Else
.....

f0raster0

Well-Known Member
Licensed User
Longtime User
yes, using your code:
B4X:
Sub POS_onBind()
    ' You can now use the BDxxx Methods. The Service is connected.
    Log($"POS_onBind()"$)
    'pos.BDconnectBtPort("00:00:00:00:00","BDconnectBtPort")
    pos.BDconnectBtPort("DC:0D:30:06:98:71","BDconnectBtPort")
   
End Sub
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Ok. I´ll try to teach you how you can "translate" the code in the Exampleapp they provided:

In the app you can for example start to print a barcode-test....
This is the code
B4X:
    private void printBarcode(){
        MainActivity.binder.writeDataByYouself(new UiExecute() {
            @Override
            public void onsucess() {

            }

            @Override
            public void onfailed() {

            }
        }, new ProcessData() {
            @Override
            public List<byte[]> processDataBeforeSend() {
                ArrayList<byte[]> list=new ArrayList<byte[]>();
                //first you have to set the width and heigt ,
                // you can also use dot or inch as a unit method, specific conversion reference programming manual
                list.add(DataForSendToPrinterTSC.sizeBymm(60,30));
                //set the gap
                list.add(DataForSendToPrinterTSC.gapBymm(0,0));
                //clear cach
                list.add(DataForSendToPrinterTSC.cls());
                //print barcode
                list.add(DataForSendToPrinterTSC.barCode(60,50,"128",100,1,0,2,2,"abcdef12345"));
                //print
                list.add(DataForSendToPrinterTSC.print(1));

                return list;
            }
        });
    }

As MainActivity you can see your activity you are running a instance of my lib.
The "binder" is the one you got in the Event
B4X:
POS_onBind()
. Okk you dont GET it... Just the info that the binder is now available.

writeDataByYouself is the same named Method in my library.

Inside the code are two callbacks defined. One for successfull and unsuccefull result, one for handling of the commands. Here i ned to return the comand list to the library behind....

The interesting part is

B4X:
                //first you have to set the width and heigt ,
                // you can also use dot or inch as a unit method, specific conversion reference programming manual
                list.add(DataForSendToPrinterTSC.sizeBymm(60,30));
                //set the gap
                list.add(DataForSendToPrinterTSC.gapBymm(0,0));
                //clear cach
                list.add(DataForSendToPrinterTSC.cls());
                //print barcode
                list.add(DataForSendToPrinterTSC.barCode(60,50,"128",100,1,0,2,2,"abcdef12345"));
                //print
                list.add(DataForSendToPrinterTSC.print(1));

Here a list of commands are gnerwated and returned to the lib behind... This is what you need to do in b4a.

This is the code you need in b4a for this

B4X:
    Dim list As List
    list.Initialize
    list.add(pos.sizeBymm(60,30))
    '//set the gap
    list.add(pos.gapBymm(0,0))
    '//clear cach
    list.add(pos.cls())
    '//print barcode
    list.add(pos.barCode(60,50,"128",100,1,0,2,2,"abcdef12345"))
    '//print
    list.add(pos.print(1))
    pos.writeDataByYouself(list,"Barcode")

After this code the lib send the commands to the printer and it will end in raising either a successful or failed event with the given tag, In this case "Barcode"

The last item added to the list causes a problem here. I needed to extend the lib. Find the new lib attached.
 
Last edited:
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Another example
B4X:
    private void printContent() {
        MainActivity.binder.writeDataByYouself(new UiExecute() {
            @Override
            public void onsucess() {
                showSnackbar("print ok !");

            }

            @Override
            public void onfailed() {
                showSnackbar("print not ok !");

            }
        }, new ProcessData() {
            @Override
            public List<byte[]> processDataBeforeSend() {

                ArrayList<byte[]> list=new ArrayList<byte[]>();
                //default is gbk,if you don't set the charset
                DataForSendToPrinterTSC.setCharsetName("gbk");
                byte[] data= DataForSendToPrinterTSC.sizeBymm(60,30);
                list.add(data);
                //set the gap
                list.add(DataForSendToPrinterTSC.gapBymm(0,0));
                // clear the cache
                list.add(DataForSendToPrinterTSC.cls());
                //barcode command,parama:int x: x print start point;int y:y print start point;
                //string font,text font type ;int rotation,angle of rotation ;
                //int x_multiplication,Font x directional magnification
                //int y_multiplication,Font y directional magnification
                //string content,print cont
                byte[] data1 = DataForSendToPrinterTSC
                        .text(10, 10, "1", 0, 1, 1,
                                "abc123");
                list.add(data1);
                //print line,int x;int y;int width,width of the line ;int height,height of the line
                list.add(DataForSendToPrinterTSC.bar(20,
                        40, 200, 3));
                //print barcode
                list.add(DataForSendToPrinterTSC.barCode(
                        60, 50, "128", 100, 1, 0, 2, 2,
                        "abcdef12345"));
                //print
                list.add(DataForSendToPrinterTSC.print(1));
                showSnackbar("content");

                return list;
            }
        });

    }

B4A

B4X:
    Dim list As List
    list.Initialize
  '//default Is gbk,If you don't set the charset
  pos.CharsetName = "gbk"
  list.Add(pos.sizeBymm(60,30))
  list.add(pos.gapBymm(0,0))
  '// clear the cache
  list.add(pos.cls())
  '//barcode command,parama:int x: x print start point;int y:y print start point;
  '//string font,text font Type ;int rotation,angle of rotation ;
  '//int x_multiplication,Font x directional magnification
  '//int y_multiplication,Font y directional magnification
  '//string content,print cont
  list.Add(pos.text(10, 10, "1", 0, 1, 1,"abc123"))
  '//print line,int x;int y;int width,width of the line ;int height,height of the line
  list.add(pos.bar(20,40, 200, 3))
  '//print barcode
  list.add(pos.barCode(60, 50, "128", 100, 1, 0, 2, 2,"abcdef12345"))
  '//print
    list.add(pos.print(1))
    pos.writeDataByYouself(list,"Text")

No warranty if it works :D
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Maybe, to come back to you initial post, use it like this

B4X:
    Dim list As List
    list.Initialize
  '//default Is gbk,If you don't set the charset
  pos.CharsetName = "gbk"
  list.Add(pos.sizeBymm(60,30))
  list.add(pos.gapBymm(0,0))
  '// clear the cache
  list.add(pos.cls())
  '//barcode command,parama:int x: x print start point;int y:y print start point;
  '//string font,text font Type ;int rotation,angle of rotation ;
  '//int x_multiplication,Font x directional magnification
  '//int y_multiplication,Font y directional magnification
  '//string content,print cont
  list.Add(pos.text(10, 10, "1", 0, 1, 1,"abc123"))
  '//print line,int x;int y;int width,width of the line ;int height,height of the line
  list.add(pos.bar(20,40, 200, 3))
  '//print barcode
    list.add(pos.barCode(60, 50, "128", 100, 1, 0, 2, 2,"abcdef12345"))
    list.add(pos.feed(20)) ' Added feed
    list.add(pos.cut)        ' Added CUT
   
  '//print
    list.add(pos.print(1))
    pos.writeDataByYouself(list,"Text")
 
Upvote 0

f0raster0

Well-Known Member
Licensed User
Longtime User
@DonManfred

I'm getting this:


B4X:
Logger connected to:  BMXC K107
--------- beginning of system
--------- beginning of main
** Service (starter) Create **
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
main_activity_create (B4A line: 55)
pos.writeDataByYouself(list,"Text")
java.lang.NullPointerException: Attempt to invoke interface method 'void net.posprinter.posprinterface.IMyBinder.writeDataByYouself(net.posprinter.posprinterface.UiExecute, net.posprinter.posprinterface.ProcessData)' on a null object reference
    at de.donmanfred.POSPrinterwrapper.writeDataByYouself(POSPrinterwrapper.java:443)
    at b4a.example.main._activity_create(main.java:400)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:179)
    at b4a.example.main.afterFirstLayout(main.java:102)
    at b4a.example.main.access$000(main.java:17)
    at b4a.example.main$WaitForLayout.run(main.java:80)
    at android.os.Handler.handleCallback(Handler.java:815)
    at android.os.Handler.dispatchMessage(Handler.java:104)
    at android.os.Looper.loop(Looper.java:194)
    at android.app.ActivityThread.main(ActivityThread.java:5631)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:959)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:754)
 
Upvote 0

f0raster0

Well-Known Member
Licensed User
Longtime User
B4X:
Logger connected to:  BMXC K107
--------- beginning of system
--------- beginning of main
** Service (starter) Create **
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
binder connected
POS_onBind()
POS_onSuccess(BDconnectBtPort)
POS_onSuccess(Text)
** Activity (main) Pause, UserClosed = false **
** Activity (main) Create, isFirst = false **
** Activity (main) Resume **
binder connected
POS_onBind()
POS_onFailed(BDconnectBtPort)
POS_onFailed(Text)
** Activity (main) Pause, UserClosed = false **


printing..not cut yet
 

Attachments

  • 20171004_020949-1.jpg
    20171004_020949-1.jpg
    99.7 KB · Views: 601
Last edited:
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
I rechecked the example project. The 3rd party jar contains three different "Sets of Commands" (all bytearrays).
What i wrapped was the TSC Set.
Then there is a set for Pos80 too (with a lot of new methods like in the TSC one). The Pos80-Set has Commands to switch the printing model.

Hold on; i´m writing a helper for the POS80 Commands too.
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
All TSC Commands are moved to a new helper class.
All Pop80 Commands in a new 2nd helperclass

Note the new references....
B4X:
Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.
    Dim pos As POSPrinter
    Dim tsc As TSChelper
    Dim pos80 As POS80helper
End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    'Activity.LoadLayout("Layout1")
    pos.Initialize("POS")
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub
Sub POS_onBind()
    ' You can now use the BDxxx Methods. The Service is connected.
    Log($"POS_onBind()"$)
    pos.BDconnectBtPort("DC:0D:30:06:98:71","BDconnectBtPort")
   
End Sub
Sub POS_onFailed(tag As Object)   
    Log($"POS_onFailed(${tag})"$)
End Sub
Sub POS_onSuccess(tag As Object)
    Log($"POS_onSuccess(${tag})"$)
    Dim list As List
    list.Initialize
    list.add(tsc.sizeBymm(60,30))
    '//set the gap
    list.add(tsc.gapBymm(0,0))
    '//clear cach
    list.add(tsc.cls())
    '//print barcode
    list.add(tsc.barCode(60,50,"128",100,1,0,2,2,"abcdef12345"))
    '//print
    list.add(tsc.print(1))
    pos.writeDataByYouself(list,"Barcode")
   
    Dim list As List
    list.Initialize
  '//default Is gbk,If you don't set the charset
  tsc.CharsetName = "gbk"
  list.Add(tsc.sizeBymm(60,30))
  list.add(tsc.gapBymm(0,0))
  '// clear the cache
  list.add(tsc.cls())
  '//barcode command,parama:int x: x print start point;int y:y print start point;
  '//string font,text font Type ;int rotation,angle of rotation ;
  '//int x_multiplication,Font x directional magnification
  '//int y_multiplication,Font y directional magnification
  '//string content,print cont
  list.Add(tsc.text(10, 10, "1", 0, 1, 1,"abc123"))
  '//print line,int x;int y;int width,width of the line ;int height,height of the line
  list.add(tsc.bar(20,40, 200, 3))
  '//print barcode
    list.add(tsc.barCode(60, 50, "128", 100, 1, 0, 2, 2,"abcdef12345"))
    list.add(tsc.feed(20))
    list.add(tsc.cut)
   
  '//print
    list.add(tsc.print(1))
    pos.writeDataByYouself(list,"Text")

   
End Sub
Sub POS_onUnBind()   
    ' Service Disconnected....
    ' DO NOT use the DBxxx-Methods....
    Log($"POS_onUnBind()"$)
End Sub


PosPrintSDK

Author:
Version:
0.2
  • POS80helper
    • Functions:
      • CancelChineseCharModel As Byte()
      • cancelUserDefinedCharacters (n As Int) As Byte()
      • canclePrintDataByPagemodel As Byte()
      • creatCashboxContorlPulse (m As Int, t1 As Int, t2 As Int) As Byte()
      • definedDownLoadBmp (bitmap As android.graphics.Bitmap, bmpType As net.posprinter.utils.BitmapToByteData.BmpType) As Byte()
      • definedFlashBmp (list As java.util.List, n As Int, bmpType As net.posprinter.utils.BitmapToByteData.BmpType) As Byte()
      • definedUserDefinedChineseChar (c2 As Int, b As Byte()) As Byte()
      • defineuserDefinedCharacters (c1 As Int, c2 As Int, b As Byte()) As Byte()
      • executeMacrodeCommand (r As Int, t As Int, m As Int) As Byte()
      • executePrintDataSaveByTransformToHex As Byte()
      • horizontalPositioning As Byte()
      • initializePrinter As Byte()
      • openCashboxRealtime (m As Int, t As Int) As Byte()
      • openOrCloseAutoReturnPrintState (n As Int) As Byte()
      • POSallowOrForbidPressButton (n As Int) As Byte()
      • printAndBackStandardmodel As Byte()
      • PrintAndCarriageReturn As Byte()
      • printAndFeed (n As Int) As Byte()
      • printAndFeedForward (n As Int) As Byte()
      • printAndFeedLine As Byte()
      • printBarcode (m As Int, content As String) As Byte()
      • printBarcode2 (m As Int, n As Int, content As String) As Byte()
      • printBmpInFLASH (n As Int, m As Int) As Byte()
      • printByPagemodel As Byte()
      • printDownLoadBmp (m As Int) As Byte()
      • printerOrderBuzzingAndWarningLight (m As Int, t As Int, n As Int) As Byte()
      • printerOrderBuzzingHint (n As Int, t As Int) As Byte()
      • printQRcode (n As Int, errLevel As Int, code As String) As Byte()
      • printRasterBmp (m As Int, bitmap As android.graphics.Bitmap, bmpType As net.posprinter.utils.BitmapToByteData.BmpType, alignType As net.posprinter.utils.BitmapToByteData.AlignType, pagewidth As Int) As Byte()
      • PrintsTheMaxiCodeSymbolDataInTheSymbolStorageArea As Byte()
      • PrintsThePDF417SymbolDataInTheSymbolStorageArea As Byte()
      • PrintsTheQRCodeSymbolDataInTheSymbolStorageArea As Byte()
      • requestRealtimeForPrint (n As Int) As Byte()
      • returnState (n As Int) As Byte()
      • selectAlignment (n As Int) As Byte()
      • selectBmpModel (m As Int, nL As Int, nH As Int, b As Byte()) As Byte()
      • selectCharacterCodePage (n As Int) As Byte()
      • selectCharacterSize (n As Int) As Byte()
      • selectChineseCharModel As Byte()
      • selectCutPagerModerAndCutPager (m As Int) As Byte()
      • selectFont (n As Int) As Byte()
      • selectHRICharacterPrintPosition (n As Int) As Byte()
      • selectHRIFont (n As Int) As Byte()
      • selectInternationalCharacterSets (n As Int) As Byte()
      • selectOrCancelBoldModel (n As Int) As Byte()
      • selectOrCancelChineseCharDoubleWH (n As Int) As Byte()
      • selectOrCancelChineseCharUnderLineModel (n As Int) As Byte()
      • selectOrCancelCW90 (n As Int) As Byte()
      • selectOrCancelDoubelPrintModel (n As Int) As Byte()
      • selectOrCancelInvertPrintModel (n As Int) As Byte()
      • selectOrCancelUnderlineModel (n As Int) As Byte()
      • selectOrCancleCustomChar (n As Int) As Byte()
      • selectPageModel As Byte()
      • selectPrintDirectionUnderPageModel (n As Int) As Byte()
      • selectPrinter (n As Int) As Byte()
      • selectPrintModel (n As Int) As Byte()
      • selectPrintTransducerOutPutPageOutSignal (n As Int) As Byte()
      • selectPrintTransducerStopPrint (n As Int) As Byte()
      • selectStandardModel As Byte()
      • sendRealtimestatus (n As Int) As Byte()
      • setAbsolutePositionUnderPageModel (nL As Int, nH As Int) As Byte()
      • setAbsolutePrintPosition (m As Int, n As Int) As Byte()
      • setBarcodeHeight (n As Int) As Byte()
      • setBarcodeWidth (n As Int) As Byte()
      • setCharRightSpace (n As Int) As Byte()
      • setDefultLineSpacing As Byte()
      • setLeftSpace (nL As Int, nH As Int) As Byte()
      • setLineSpaceing (n As Int) As Byte()
      • setPrintAreaUnderPageModel (xL As Int, xH As Int, yL As Int, yH As Int, dxL As Int, dxH As Int, dyL As Int, dyH As Int) As Byte()
      • setRelativeHorizontalPrintPosition (nL As Int, nH As Int) As Byte()
      • SetsTheErrorCorrectionLevelForPDF417 (m As Int, n As Int) As Byte()
      • SetsTheModuleWidthOfPDF417 (n As Int) As Byte()
      • SetsTheNumberOfColumnsOfTheDataAreaForPDF417 (n As Int) As Byte()
      • SetsTheNumberOfRowsOfTheDataAreaForPDF417 (n As Int) As Byte()
      • SetsTheSizeOfTheQRCodeSymbolModule (n As Int) As Byte()
      • setVerticalRelativePositionUnderPageModel (nL As Int, nH As Int) As Byte()
      • SpecifiesTheModeForMaxiCodeSymbol (n As Int) As Byte()
  • POSPrinter
    • Events:
      • onBind()
      • onFailed (tag As Object)
      • onSuccess (tag As Object)
      • onUnBind()
    • Fields:
      • binder As net.posprinter.posprinterface.IMyBinder
      • ISCONNECT As Boolean
    • Functions:
      • BDacceptdatafromprinter
      • BDcheckLinkedState (tag As Object)
      • BDclearBuffer
      • BDconnectBtPort (arg0 As String, tag As Object)
      • BDconnectNetPort (arg0 As String, arg1 As Int, tag As Object)
      • BDconnectUsbPort (arg1 As String, tag As Object)
      • BDdisconnectCurrentPort (tag As Object)
      • Initialize (EventName As String)
      • readBuffer As net.posprinter.utils.RoundQueue
      • write (data As Byte(), tag As Object)
      • writeDataByYouself (commands As List, tag As Object)
    • Properties:
      • AlignTypeCenter As net.posprinter.utils.BitmapToByteData.AlignType [read only]
      • AlignTypeLeft As net.posprinter.utils.BitmapToByteData.AlignType [read only]
      • AlignTypeRight As net.posprinter.utils.BitmapToByteData.AlignType [read only]
      • BmpTypeDithering As net.posprinter.utils.BitmapToByteData.BmpType [read only]
      • BmpTypethreshold As net.posprinter.utils.BitmapToByteData.BmpType [read only]
  • TSChelper
    • Functions:
      • autoDetect (x As Int, y As Int) As Byte()
      • backFeed (n As Int) As Byte()
      • bar (x As Int, y As Int, width As Int, heigth As Int) As Byte()
      • barCode (x As Int, y As Int, codeType As String, heigth As Int, human As Int, rotation As Int, narrow As Int, wide As Int, content As String) As Byte()
      • bitmap (x As Int, y As Int, mode As Int, bitmap As android.graphics.Bitmap, bmpType As net.posprinter.utils.BitmapToByteData.BmpType) As Byte()
      • blineBydot (m As Int, n As Int) As Byte()
      • blineByinch (m As Double, n As Double) As Byte()
      • blineBymm (m As Double, n As Double) As Byte()
      • blineDetect (x As Int, y As Int) As Byte()
      • block (x As Int, y As Int, width As Int, height As Int, font As String, rotation As Int, x_multiplication As Int, y_multiplication As Int, space As Int, alignment As Int, content As String) As Byte()
      • box (x As Int, y As Int, x_end As Int, y_end As Int, thickness As Int) As Byte()
      • checkPrinterStateByPort4000 As Byte()
      • checkPrinterStateByPort9100 As Byte()
      • cls As Byte()
      • codeBlockFMode (x As Int, y As Int, rotation As Int, row_height As Int, module_width As Int, content As String) As Byte()
      • codePage (n As String) As Byte()
      • country (n As String) As Byte()
      • cut As Byte()
      • delay (ms As Int) As Byte()
      • density (n As Int) As Byte()
      • direction (n As Int) As Byte()
      • disPlay (s As String) As Byte()
      • dmatrix (x As Int, y As Int, width As Int, height As Int, expression As String, content As String) As Byte()
      • dmatrix3 (x As Int, y As Int, width As Int, height As Int, xm As Int, row As Int, col As Int, expression As String, content As String) As Byte()
      • downLoad (filename As String) As Byte()
      • downLoad2 (filename As String, bitmap As String) As Byte()
      • downLoad3 (filename As String, filepath As String) As Byte()
      • downLoad4 (filename As String, size As Int, content As String) As Byte()
      • ellipse (x As Int, y As Int, width As Int, height As Int, thickness As Int) As Byte()
      • eop As Byte()
      • erase (x As Int, y As Int, width As Int, height As Int) As Byte()
      • feed (n As Int) As Byte()
      • files As Byte()
      • formFeed As Byte()
      • gapBydot (m As Int, n As Int) As Byte()
      • gapByinch (m As Double, n As Double) As Byte()
      • gapBymm (m As Double, n As Double) As Byte()
      • gapDetect (x As Int, y As Int) As Byte()
      • home As Byte()
      • initialPrinter As Byte()
      • kill (filename As String) As Byte()
      • limitFeedBydot (n As Int) As Byte()
      • limitFeedByinch (n As Double) As Byte()
      • limitFeedBymm (n As Double) As Byte()
      • move As Byte()
      • offSetBydot (m As Int) As Byte()
      • offSetByinch (m As Double) As Byte()
      • offSetBymm (m As Double) As Byte()
      • pdf417 (x As Int, y As Int, width As Int, height As Int, rotate As Int, option As String, content As String) As Byte()
      • print (m As Int) As Byte()
      • print2 (m As Int, n As Int) As Byte()
      • putBmp (x As Int, y As Int, filename As String, bpp As Int, contrast As Int) As Byte()
      • qrCode (x As Int, y As Int, eccLevel As String, cellWidth As Int, mode As String, rotation As Int, model As String, mask As String, content As String) As Byte()
      • reference (x As Int, y As Int) As Byte()
      • reverse (x As Int, y As Int, width As Int, height As Int) As Byte()
      • run (filename As String) As Byte()
      • selfTest As Byte()
      • selfTest2 (page As String) As Byte()
      • shift (n As Int) As Byte()
      • sizeBydot (m As Int, n As Int) As Byte()
      • sizeByinch (m As Double, n As Double) As Byte()
      • sizeBymm (m As Double, n As Double) As Byte()
      • sound (level As Int, interval As Int) As Byte()
      • speed (n As Double) As Byte()
      • text (x As Int, y As Int, font As String, rotation As Int, x_multiplication As Int, y_multiplication As Int, content As String) As Byte()
    • Properties:
      • CharsetName As String [write only]
 

Attachments

  • PosPrintSDKV0.2-TRIAL.zip
    83.3 KB · Views: 384
Upvote 0

f0raster0

Well-Known Member
Licensed User
Longtime User
tested.. we're sure it is printing :) see pic attached..
Logger connected to: BMXC K107
--------- beginning of system
--------- beginning of main
** Service (starter) Create **
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
binder connected
POS_onBind()
POS_onSuccess(BDconnectBtPort)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
POS_onSuccess(Text)
POS_onSuccess(Barcode)
** Activity (main) Pause, UserClosed = false **
 

Attachments

  • 20171004_185203.jpg
    20171004_185203.jpg
    165.3 KB · Views: 392
  • 20171004_185340.jpg
    20171004_185340.jpg
    82.1 KB · Views: 525
Upvote 0

f0raster0

Well-Known Member
Licensed User
Longtime User
In the meantime that @DonManfred's printer arrive..or I can make the new library work..

I'd like to go back to the original code and do a try..
Notes:
-Using the code-demo the printer is printing OK,
-Using this App (posprinterdriver) the printer is cutting the paper

B4X:
#Region Module Attributes
    #FullScreen: False
    #IncludeTitle: True
    #ApplicationLabel: Bluetooth POS Printing
    #VersionCode: 1
    #VersionName:
    #SupportedOrientations: portrait
    #CanInstallToExternalStorage: False
#End Region

Sub Process_Globals
    Dim PrintBuffer As String

    Dim BtAdmin As BluetoothAdmin
    Dim BTConnection As Serial
    Dim Printer As TextWriter
End Sub

Sub Globals

End Sub

Sub Activity_Create(FirstTime As Boolean)
    If FirstTime Then
        BtAdmin.Initialize("BlueTooth")
        BTConnection.Initialize("Printer")
        Dim PairedDevices As Map
        PairedDevices = BTConnection.GetPairedDevices
        Dim l As List
        Dim DeviceName, MacAddress As String
        l.Initialize
        For i = 0 To PairedDevices.Size - 1 'Check all devices
            l.Add(PairedDevices.GetKeyAt(i))
            DeviceName=PairedDevices.Getkeyat(i)
            MacAddress=PairedDevices.GetValueAt(i)
            Log(DeviceName & " -> " & MacAddress)
            If DeviceName.Contains("Printer001") Then 'Insert the BT-Name of the printer or use the MAC address
                Exit
            End If
        Next
        BTConnection.Connect(MacAddress)
    End If
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause

End Sub

Sub Printer_Connected (Success As Boolean)
    If Success Then
        Printer.Initialize2(BTConnection.OutputStream,"windows-1252") 'important to print f.e. German/French chars
        PrintBuffer=Chr(27)&"t"&Chr(16)&"Hello" 'Set codepage 1252
        Printer.WriteLine(PrintBuffer)
        PrintBuffer=Chr(29) & Chr(86) & Chr(48)
        Printer.Flush 'limpia la impresora
        Msgbox("Printed!","")
        Printer.Close
        BTConnection.Disconnect 'disable this if you like
    Else
        Msgbox("No printer found...","Print error")
    End If
End Sub

do you tried ?

How should I send this Chr(29) & Chr(86) & Chr(48) command to the printer?
The right way to send those commands..

Edit: I have the English manual now, attached..
 

Attachments

  • Manual-XP-80-pag31.jpg
    Manual-XP-80-pag31.jpg
    95.4 KB · Views: 434
  • 80XX Programmer_Manual(latest version).pdf
    274.5 KB · Views: 403
Last edited:
Upvote 0

MarcoRome

Expert
Licensed User
Longtime User
B4X:
...
Sub Printer_Connected (Success As Boolean)
    If Success Then
        Printer.Initialize2(BTConnection.OutputStream,"windows-1252") 'important to print f.e. German/French chars
        PrintBuffer=Chr(27)&"t"&Chr(16)&"Hello" 'Set codepage 1252
        Printer.WriteLine(PrintBuffer)
        PrintBuffer=Chr(29) & Chr(86) & Chr(48)
        Printer.WriteLine(PrintBuffer) '<-------- YOU FORGET THIS
        Printer.Flush 'limpia la impresora
        Msgbox("Printed!","")
        Printer.Close
        BTConnection.Disconnect 'disable this if you like
    Else
.....
 
Upvote 0
Solution

f0raster0

Well-Known Member
Licensed User
Longtime User
B4X:
...
Sub Printer_Connected (Success As Boolean)
    If Success Then
        Printer.Initialize2(BTConnection.OutputStream,"windows-1252") 'important to print f.e. German/French chars
        PrintBuffer=Chr(27)&"t"&Chr(16)&"Hello" 'Set codepage 1252
        Printer.WriteLine(PrintBuffer)
        PrintBuffer=Chr(29) & Chr(86) & Chr(48)
        Printer.WriteLine(PrintBuffer) '<-------- YOU FORGET THIS
        Printer.Flush 'limpia la impresora
        Msgbox("Printed!","")
        Printer.Close
        BTConnection.Disconnect 'disable this if you like
    Else
.....

working great!!
 
Upvote 0
Top