68、TSPL指令集(标签打印机)

0、开发者pdf、sdk等资料详见:

http://download.csdn.net/detail/kunyashaw/9376694

1、测试代码

包含文字打印、条形码打印、二维码打印

  1 package com.huofu.speechundecrypt;
  2
  3 import android.content.Context;
  4 import android.os.Bundle;
  5 import android.support.v7.app.AppCompatActivity;
  6 import android.view.View;
  7 import android.widget.Button;
  8
  9 import java.io.UnsupportedEncodingException;
 10
 11 public class MainActivity extends AppCompatActivity {
 12
 13     Context ctxt;
 14
 15     @Override
 16     protected void onCreate(Bundle savedInstanceState) {
 17         super.onCreate(savedInstanceState);
 18
 19         Button btn = new Button(getApplicationContext());
 20         btn.setText("press me");
 21         btn.setOnClickListener(new View.OnClickListener() {
 22             @Override
 23             public void onClick(View v) {
 24                 writeDeal();
 25             }
 26         });
 27
 28         setContentView(btn);
 29         ctxt = getApplicationContext();
 30     }
 31
 32
 33     public void writeDeal(){
 34         TscWifiActivity TscEthernetDll = new TscWifiActivity();
 35         TscEthernetDll.openport("192.168.1.200", 9100);//打开指定IP和端口号
 36
 37         //setup(int width, int height, int speed, int density, int sensor, int sensor_distance, int sensor_offset)
 38         //宽度、高度、速度、浓度
 39         //sensor为0:sensor_distance 垂直间距距离 sensor_offset垂直间距的偏移
 40         //sensor为1:sensor_distance 定义黑标高度和额外送出长度 sensor_offset黑标偏移量
 41         TscEthernetDll.setup(40, 30, 4, 4, 0, 5, 0);
 42
 43         TscEthernetDll.clearbuffer();
 44
 45         /*--------------------------标签打印机初始化--------------------------*/
 46         TscEthernetDll.sendcommand("SET TEAR ON\n");//是否将撕纸位置移动到撕纸处
 47         //TscEthernetDll.sendcommand("SET COUNTER @1 1\n");//设定计时器及增量
 48         TscEthernetDll.sendcommand("SHIFT 10\n");
 49
 50
 51         /*--------------------------打印文字--------------------------*/
 52         writeDelivery(TscEthernetDll, "", 1);//打印外送标签
 53         writePackagedInfo(TscEthernetDll,"",1);//打印打包标签
 54
 55
 56         /*--------------------------打印条形码--------------------------*/
 57         //barcode(int x, int y, String type, int height, int human_readable, int rotation, int narrow, int wide, String string)
 58         //x 水平坐标左上角起点 y垂直坐标左上角起点 type条形码类型 height条形码高度 human_readable(0 人眼不可识别 1人眼可识别) rotation条形码旋转角度
 59         //narrow 窄bar宽度 wide宽bar宽度 string为要显示的内容
 60         TscEthernetDll.barcode(100, 100, "128", 100, 1, 0, 3, 3, "123456789");
 61         TscEthernetDll.printlabel(1, 1);//打印出缓冲区的数据,第一个参数是打印的分数,第二个是没份打印的张数
 62         TscEthernetDll.clearbuffer();
 63
 64         /*--------------------------打印二维码--------------------------*/
 65         String cmd = "QRCODE 100,10,H,7,M,0,M1,S1,\"hello world\"\n";
 66         TscEthernetDll.sendcommand(cmd);
 67         TscEthernetDll.printlabel(1, 1);
 68         TscEthernetDll.clearbuffer();
 69
 70         TscEthernetDll.closeport();
 71     }
 72
 73     /**
 74      * 打印外送信息
 75      * @param TscEthernetDll
 76      * @param msg
 77      * @param font_size
 78      */
 79     public void writeDelivery(TscWifiActivity TscEthernetDll, String msg, int font_size) {
 80         try {
 81             //String originalText = "TEXT 550,50,\"TSS24.BF2\",180," + font_size + "," + font_size + ",\"" + msg + "\"\n";
 82             String originalText = "TEXT 260,210,\"TSS24.BF2\",180,1,1,\"万通中心店 午餐\"\n";
 83             TscEthernetDll.sendcommand((originalText.getBytes("gb2312")));
 84
 85             originalText = "TEXT 220,185,\"TSS24.BF2\",180,1,1,\"300 外送\"\n";
 86             TscEthernetDll.sendcommand((originalText.getBytes("gb2312")));
 87
 88             originalText = "TEXT 310,150,\"TSS24.BF2\",180,1,1,\"联系人:张**\"\n";
 89             TscEthernetDll.sendcommand((originalText.getBytes("gb2312")));
 90
 91             originalText = "TEXT 310,110,\"TSS24.BF2\",180,1,1,\"电话: 185 1342 ****\"\n";
 92             TscEthernetDll.sendcommand((originalText.getBytes("gb2312")));
 93
 94
 95             String address = "北京市**区 ****D座 25层 **科技有限公司";//10个汉字换一行
 96
 97             if (address.length() <= 10) {
 98                 originalText = "TEXT 310,80,\"TSS24.BF2\",180,1,1,\"地址:\"\""+address+"\"\n";
 99                 TscEthernetDll.sendcommand((originalText.getBytes("gb2312")));
100
101             } else {
102                 String tmpString = address.substring(0,9);
103                 String tmpString2 = address.substring(9,address.length());
104                 originalText = "TEXT 310,80,\"TSS24.BF2\",180,1,1,\"地址:\"\""+tmpString+"\"\n";
105                 TscEthernetDll.sendcommand((originalText.getBytes("gb2312")));
106
107                 String printText = "TEXT 310,50,\"TSS24.BF2\",180,1,1,\""+tmpString2+"\"\n";
108                 TscEthernetDll.sendcommand((printText.getBytes("gb2312")));
109             }
110
111             TscEthernetDll.printlabel(1, 1);//打印出缓冲区的数据,第一个参数是打印的分数,第二个是每份打印的张数
112             TscEthernetDll.clearbuffer();
113         } catch (UnsupportedEncodingException e) {
114             e.printStackTrace();
115         }
116     }
117
118
119     public static void writePackagedInfo(TscWifiActivity TscEthernetDll, String msg, int font_size) {
120         try {
121             //String originalText = "TEXT 550,50,\"TSS24.BF2\",180," + font_size + "," + font_size + ",\"" + msg + "\"\n";
122             String originalText = "TEXT 260,210,\"TSS24.BF2\",180,1,1,\"万通中心店 午餐\"\n";
123             TscEthernetDll.sendcommand((originalText.getBytes("gb2312")));
124
125             originalText = "TEXT 220,170,\"TSS24.BF2\",180,1,1,\"300 打包\"\n";
126             TscEthernetDll.sendcommand((originalText.getBytes("gb2312")));
127
128             originalText = "TEXT 315,130,\"TSS24.BF2\",180,1,1,\"应收:20.5元\"\n";
129             TscEthernetDll.sendcommand((originalText.getBytes("gb2312")));
130
131             originalText = "TEXT 170,130,\"TSS24.BF2\",180,1,1,\"实收: 30.5元\"\n";
132             TscEthernetDll.sendcommand((originalText.getBytes("gb2312")));
133
134             originalText = "TEXT 315,90,\"TSS24.BF2\",180,1,1,\"优惠: 10元\"\n";
135             TscEthernetDll.sendcommand((originalText.getBytes("gb2312")));
136
137
138             TscEthernetDll.printlabel(1, 1);//打印出缓冲区的数据,第一个参数是打印的分数,第二个是每份打印的张数
139             TscEthernetDll.clearbuffer();
140         } catch (UnsupportedEncodingException e) {
141             e.printStackTrace();
142         }
143     }
144 }

2、库

  1 package com.huofu.speechundecrypt;
  2
  3 import android.app.Activity;
  4 import android.content.Context;
  5 import android.os.Bundle;
  6 import android.os.StrictMode;
  7 import android.util.Log;
  8 import android.view.Menu;
  9 import android.view.View;
 10 import android.widget.Button;
 11 import android.widget.TextView;
 12
 13 import java.io.FileInputStream;
 14 import java.io.IOException;
 15 import java.io.InputStream;
 16 import java.io.OutputStream;
 17 import java.net.Socket;
 18
 19 /**
 20  * author: Created by zzl on 15/12/25.
 21  */
 22
 23 public class TscWifiActivity extends Activity {
 24     private static final String TAG = "THINBTCLIENT";
 25     private static final boolean D = true;
 26     private InputStream InStream = null;
 27     private OutputStream OutStream = null;
 28     private Socket socket = null;
 29     private String printerstatus = "";
 30     private int last_bytes = 0;
 31     private byte[] buffer = new byte[1024];
 32     private byte[] readBuf = new byte[1024];
 33     private Button connect = null;
 34     private Button closeport = null;
 35     private Button sendfile = null;
 36     private Button status = null;
 37     private TextView tv1 = null;
 38
 39     public TscWifiActivity() {
 40     }
 41
 42     public void onCreate(Bundle savedInstanceState) {
 43         super.onCreate(savedInstanceState);
 44         this.setContentView(2130903040);
 45         this.tv1 = (TextView) this.findViewById(2131165187);
 46         this.connect = (Button) this.findViewById(2131165184);
 47         this.connect.setOnClickListener(new View.OnClickListener() {
 48             public void onClick(View v) {
 49                 TscWifiActivity.this.openport("192.168.1.40", 9100);
 50                 TscWifiActivity.this.sendcommand("SIZE 3,1\n");
 51                 TscWifiActivity.this.sendcommand("PRINT 5\n");
 52             }
 53         });
 54         this.closeport = (Button) this.findViewById(2131165185);
 55         this.closeport.setOnClickListener(new View.OnClickListener() {
 56             public void onClick(View v) {
 57                 TscWifiActivity.this.closeport();
 58             }
 59         });
 60         this.sendfile = (Button) this.findViewById(2131165186);
 61         this.sendfile.setOnClickListener(new View.OnClickListener() {
 62             public void onClick(View v) {
 63                 TscWifiActivity.this.openport("192.168.1.58", 9100);
 64                 TscWifiActivity.this.downloadpcx("UL.PCX");
 65                 TscWifiActivity.this.downloadbmp("Triangle.bmp");
 66                 TscWifiActivity.this.downloadttf("ARIAL.TTF");
 67                 TscWifiActivity.this.setup(70, 110, 4, 4, 0, 0, 0);
 68                 TscWifiActivity.this.clearbuffer();
 69                 TscWifiActivity.this.sendcommand("SET TEAR ON\n");
 70                 TscWifiActivity.this.sendcommand("SET COUNTER @1 1\n");
 71                 TscWifiActivity.this.sendcommand("@1 = \"0001\"\n");
 72                 TscWifiActivity.this.sendcommand("TEXT 100,300,\"3\",0,1,1,@1\n");
 73                 TscWifiActivity.this.sendcommand("PUTPCX 100,300,\"UL.PCX\"\n");
 74                 TscWifiActivity.this.sendcommand("PUTBMP 100,520,\"Triangle.bmp\"\n");
 75                 TscWifiActivity.this.sendcommand("TEXT 100,760,\"ARIAL.TTF\",0,15,15,\"THIS IS ARIAL FONT\"\n");
 76                 TscWifiActivity.this.barcode(100, 100, "128", 100, 1, 0, 3, 3, "123456789");
 77                 TscWifiActivity.this.printerfont(100, 250, "3", 0, 1, 1, "987654321");
 78                 TscWifiActivity.this.printlabel(10, 1);
 79                 TscWifiActivity.this.sendfile("zpl.txt");
 80                 TscWifiActivity.this.closeport();
 81             }
 82         });
 83         this.status = (Button) this.findViewById(2131165188);
 84         this.status.setOnClickListener(new View.OnClickListener() {
 85             public void onClick(View v) {
 86                 String QQ = TscWifiActivity.this.batch();
 87                 TscWifiActivity.this.tv1.setText(QQ);
 88             }
 89         });
 90     }
 91
 92     public void onStart() {
 93         super.onStart();
 94         Log.e("THINBTCLIENT", "++ ON START ++");
 95     }
 96
 97     public void onResume() {
 98         super.onResume();
 99         Log.e("THINBTCLIENT", "+ ON RESUME +");
100         Log.e("THINBTCLIENT", "+ ABOUT TO ATTEMPT CLIENT CONNECT +");
101     }
102
103     public void onPause() {
104         super.onPause();
105         Log.e("THINBTCLIENT", "- ON PAUSE -");
106         if (this.OutStream != null) {
107             try {
108                 this.OutStream.flush();
109             } catch (IOException var3) {
110                 Log.e("THINBTCLIENT", "ON PAUSE: Couldn\‘t flush output stream.", var3);
111             }
112         }
113
114         try {
115             this.socket.close();
116         } catch (IOException var2) {
117             Log.e("THINBTCLIENT", "ON PAUSE: Unable to close socket.", var2);
118         }
119
120     }
121
122     public void onStop() {
123         super.onStop();
124         Log.e("THINBTCLIENT", "-- ON STOP --");
125     }
126
127     public void onDestroy() {
128         super.onDestroy();
129         Log.e("THINBTCLIENT", "--- ON DESTROY ---");
130     }
131
132     public boolean onCreateOptionsMenu(Menu menu) {
133         this.getMenuInflater().inflate(2131099648, menu);
134         return true;
135     }
136
137     public void openport(String ipaddress, int portnumber) {
138         StrictMode.setThreadPolicy((new StrictMode.ThreadPolicy.Builder()).detectDiskReads().detectDiskWrites().detectNetwork().penaltyLog().build());
139         StrictMode.setVmPolicy((new android.os.StrictMode.VmPolicy.Builder()).detectLeakedSqlLiteObjects().detectLeakedClosableObjects().penaltyLog().penaltyDeath().build());
140
141         try {
142             this.socket = new Socket(ipaddress, portnumber);
143             this.InStream = this.socket.getInputStream();
144             this.OutStream = this.socket.getOutputStream();
145         } catch (Exception var4) {
146             ;
147         }
148
149     }
150
151     public void sendcommand(String message) {
152         byte[] msgBuffer = message.getBytes();
153
154         try {
155             this.OutStream.write(msgBuffer);
156         } catch (IOException var4) {
157             var4.printStackTrace();
158         }
159
160     }
161
162     public void sendcommand(byte[] message) {
163         try {
164             this.OutStream.write(message);
165         } catch (IOException var3) {
166             var3.printStackTrace();
167         }
168
169     }
170
171     public String status() {
172         byte[] message = new byte[]{(byte) 27, (byte) 33, (byte) 63};
173
174         try {
175             this.OutStream.write(message);
176         } catch (IOException var4) {
177             Log.e("THINBTCLIENT", "ON RESUME: Exception during write.", var4);
178         }
179
180         try {
181             Thread.sleep(1000L);
182         } catch (InterruptedException var3) {
183             var3.printStackTrace();
184         }
185
186         int tim;
187         try {
188             while (this.InStream.available() > 0) {
189                 this.readBuf = new byte[1024];
190                 tim = this.InStream.read(this.readBuf);
191                 Log.e("","tim is "+tim);
192             }
193         } catch (IOException var5) {
194             var5.printStackTrace();
195         }
196
197         if (this.readBuf[0] == 2 && this.readBuf[5] == 3) {
198             for (tim = 0; tim <= 7; ++tim) {
199                 if (this.readBuf[tim] == 2 && this.readBuf[tim + 1] == 64 && this.readBuf[tim + 2] == 64 && this.readBuf[tim + 3] == 64 && this.readBuf[tim + 4] == 64 && this.readBuf[tim + 5] == 3) {
200                     this.printerstatus = "Ready";
201                     this.readBuf = new byte[1024];
202                     break;
203                 }
204
205                 if (this.readBuf[tim] == 2 && this.readBuf[tim + 1] == 69 && this.readBuf[tim + 2] == 64 && this.readBuf[tim + 3] == 64 && this.readBuf[tim + 4] == 96 && this.readBuf[tim + 5] == 3) {
206                     this.printerstatus = "Head Open";
207                     this.readBuf = new byte[1024];
208                     break;
209                 }
210
211                 if (this.readBuf[tim] == 2 && this.readBuf[tim + 1] == 64 && this.readBuf[tim + 2] == 64 && this.readBuf[tim + 3] == 64 && this.readBuf[tim + 4] == 96 && this.readBuf[tim + 5] == 3) {
212                     this.printerstatus = "Head Open";
213                     this.readBuf = new byte[1024];
214                     break;
215                 }
216
217                 if (this.readBuf[tim] == 2 && this.readBuf[tim + 1] == 69 && this.readBuf[tim + 2] == 64 && this.readBuf[tim + 3] == 64 && this.readBuf[tim + 4] == 72 && this.readBuf[tim + 5] == 3) {
218                     this.printerstatus = "Ribbon Jam";
219                     this.readBuf = new byte[1024];
220                     break;
221                 }
222
223                 if (this.readBuf[tim] == 2 && this.readBuf[tim + 1] == 69 && this.readBuf[tim + 2] == 64 && this.readBuf[tim + 3] == 64 && this.readBuf[tim + 4] == 68 && this.readBuf[tim + 5] == 3) {
224                     this.printerstatus = "Ribbon Empty";
225                     this.readBuf = new byte[1024];
226                     break;
227                 }
228
229                 if (this.readBuf[tim] == 2 && this.readBuf[tim + 1] == 69 && this.readBuf[tim + 2] == 64 && this.readBuf[tim + 3] == 64 && this.readBuf[tim + 4] == 65 && this.readBuf[tim + 5] == 3) {
230                     this.printerstatus = "No Paper";
231                     this.readBuf = new byte[1024];
232                     break;
233                 }
234
235                 if (this.readBuf[tim] == 2 && this.readBuf[tim + 1] == 69 && this.readBuf[tim + 2] == 64 && this.readBuf[tim + 3] == 64 && this.readBuf[tim + 4] == 66 && this.readBuf[tim + 5] == 3) {
236                     this.printerstatus = "Paper Jam";
237                     this.readBuf = new byte[1024];
238                     break;
239                 }
240
241                 if (this.readBuf[tim] == 2 && this.readBuf[tim + 1] == 69 && this.readBuf[tim + 2] == 64 && this.readBuf[tim + 3] == 64 && this.readBuf[tim + 4] == 65 && this.readBuf[tim + 5] == 3) {
242                     this.printerstatus = "Paper Empty";
243                     this.readBuf = new byte[1024];
244                     break;
245                 }
246
247                 if (this.readBuf[tim] == 2 && this.readBuf[tim + 1] == 67 && this.readBuf[tim + 2] == 64 && this.readBuf[tim + 3] == 64 && this.readBuf[tim + 4] == 64 && this.readBuf[tim + 5] == 3) {
248                     this.printerstatus = "Cutting";
249                     this.readBuf = new byte[1024];
250                     break;
251                 }
252
253                 if (this.readBuf[tim] == 2 && this.readBuf[tim + 1] == 75 && this.readBuf[tim + 2] == 64 && this.readBuf[tim + 3] == 64 && this.readBuf[tim + 4] == 64 && this.readBuf[tim + 5] == 3) {
254                     this.printerstatus = "Waiting to Press Print Key";
255                     this.readBuf = new byte[1024];
256                     break;
257                 }
258
259                 if (this.readBuf[tim] == 2 && this.readBuf[tim + 1] == 76 && this.readBuf[tim + 2] == 64 && this.readBuf[tim + 3] == 64 && this.readBuf[tim + 4] == 64 && this.readBuf[tim + 5] == 3) {
260                     this.printerstatus = "Waiting to Take Label";
261                     this.readBuf = new byte[1024];
262                     break;
263                 }
264
265                 if (this.readBuf[tim] == 2 && this.readBuf[tim + 1] == 80 && this.readBuf[tim + 2] == 64 && this.readBuf[tim + 3] == 64 && this.readBuf[tim + 4] == 64 && this.readBuf[tim + 5] == 3) {
266                     this.printerstatus = "Printing Batch";
267                     this.readBuf = new byte[1024];
268                     break;
269                 }
270
271                 if (this.readBuf[tim] == 2 && this.readBuf[tim + 1] == 96 && this.readBuf[tim + 2] == 64 && this.readBuf[tim + 3] == 64 && this.readBuf[tim + 4] == 64 && this.readBuf[tim + 5] == 3) {
272                     this.printerstatus = "Pause";
273                     this.readBuf = new byte[1024];
274                     break;
275                 }
276
277                 if (this.readBuf[tim] == 2 && this.readBuf[tim + 1] == 69 && this.readBuf[tim + 2] == 64 && this.readBuf[tim + 3] == 64 && this.readBuf[tim + 4] == 64 && this.readBuf[tim + 5] == 3) {
278                     this.printerstatus = "Pause";
279                     this.readBuf = new byte[1024];
280                     break;
281                 }
282             }
283         }
284
285         return this.printerstatus;
286     }
287
288     public String batch() {
289         boolean printvalue = false;
290         String printbatch = "";
291         String stringbatch = "0";
292         String message = "~HS";
293         this.readBuf = new byte[1024];
294         byte[] batcharray = new byte[]{(byte) 48, (byte) 48, (byte) 48, (byte) 48, (byte) 48, (byte) 48, (byte) 48, (byte) 48};
295         byte[] msgBuffer = message.getBytes();
296
297         try {
298             this.OutStream.write(msgBuffer);
299         } catch (IOException var9) {
300             Log.e("THINBTCLIENT", "ON RESUME: Exception during write.", var9);
301         }
302
303         try {
304             Thread.sleep(1000L);
305         } catch (InterruptedException var8) {
306             var8.printStackTrace();
307         }
308
309         int i;
310         try {
311             while (this.InStream.available() > 50) {
312                 this.readBuf = new byte[1024];
313                 i = this.InStream.read(this.readBuf);
314             }
315         } catch (IOException var10) {
316             var10.printStackTrace();
317         }
318
319         if (this.readBuf[0] == 2) {
320             System.arraycopy(this.readBuf, 55, batcharray, 0, 8);
321
322             for (i = 0; i <= 7; ++i) {
323                 if (batcharray[i] == 44) {
324                     batcharray = new byte[]{(byte) 57, (byte) 57, (byte) 57, (byte) 57, (byte) 57, (byte) 57, (byte) 57, (byte) 57};
325                 }
326             }
327
328             stringbatch = new String(batcharray);
329             int var11 = Integer.parseInt(stringbatch);
330             printbatch = Integer.toString(var11);
331             if (printbatch == "99999999") {
332                 printbatch = "";
333             }
334         }
335
336         return printbatch;
337     }
338
339     public void closeport() {
340         try {
341             this.socket.close();
342         } catch (IOException var2) {
343             var2.printStackTrace();
344         }
345
346     }
347
348     public void setup(int width, int height, int speed, int density, int sensor, int sensor_distance, int sensor_offset) {
349         String message = "";
350         String size = "SIZE " + width + " mm" + ", " + height + " mm";
351         String speed_value = "SPEED " + speed;
352         String density_value = "DENSITY " + density;
353         String sensor_value = "";
354         if (sensor == 0) {
355             sensor_value = "GAP " + sensor_distance + " mm" + ", " + sensor_offset + " mm";
356         } else if (sensor == 1) {
357             sensor_value = "BLINE " + sensor_distance + " mm" + ", " + sensor_offset + " mm";
358         }
359
360         message = size + "\n" + speed_value + "\n" + density_value + "\n" + sensor_value + "\n";
361         byte[] msgBuffer = message.getBytes();
362
363         try {
364             this.OutStream.write(msgBuffer);
365         } catch (IOException var15) {
366             var15.printStackTrace();
367         }
368
369     }
370
371     public void clearbuffer() {
372         String message = "CLS\n";
373         byte[] msgBuffer = message.getBytes();
374
375         try {
376             this.OutStream.write(msgBuffer);
377         } catch (IOException var4) {
378             var4.printStackTrace();
379         }
380
381     }
382
383     public void barcode(int x, int y, String type, int height, int human_readable, int rotation, int narrow, int wide, String string) {
384         String message = "";
385         String barcode = "BARCODE ";
386         String position = x + "," + y;
387         String mode = "\"" + type + "\"";
388         String height_value = "" + height;
389         String human_value = "" + human_readable;
390         String rota = "" + rotation;
391         String narrow_value = "" + narrow;
392         String wide_value = "" + wide;
393         String string_value = "\"" + string + "\"";
394         message = barcode + position + " ," + mode + " ," + height_value + " ," + human_value + " ," + rota + " ," + narrow_value + " ," + wide_value + " ," + string_value + "\n";
395         byte[] msgBuffer = message.getBytes();
396
397         try {
398             this.OutStream.write(msgBuffer);
399         } catch (IOException var22) {
400             var22.printStackTrace();
401         }
402
403     }
404
405     public void printerfont(int x, int y, String size, int rotation, int x_multiplication, int y_multiplication, String string) {
406         String message = "";
407         String text = "TEXT ";
408         String position = x + "," + y;
409         String size_value = "\"" + size + "\"";
410         String rota = "" + rotation;
411         String x_value = "" + x_multiplication;
412         String y_value = "" + y_multiplication;
413         String string_value = "\"" + string + "\"";
414         message = text + position + " ," + size_value + " ," + rota + " ," + x_value + " ," + y_value + " ," + string_value + "\n";
415         byte[] msgBuffer = message.getBytes();
416
417         try {
418             this.OutStream.write(msgBuffer);
419         } catch (IOException var18) {
420             var18.printStackTrace();
421         }
422
423     }
424
425     public void printlabel(int quantity, int copy) {
426         String message = "";
427         message = "PRINT " + quantity + ", " + copy + "\n";
428         byte[] msgBuffer = message.getBytes();
429
430         try {
431             this.OutStream.write(msgBuffer);
432         } catch (IOException var6) {
433             var6.printStackTrace();
434         }
435
436     }
437
438     public void formfeed() {
439         String message = "";
440         message = "FORMFEED\n";
441         byte[] msgBuffer = message.getBytes();
442
443         try {
444             this.OutStream.write(msgBuffer);
445         } catch (IOException var4) {
446             var4.printStackTrace();
447         }
448
449     }
450
451     public void nobackfeed() {
452         String message = "";
453         message = "SET TEAR OFF\n";
454         byte[] msgBuffer = message.getBytes();
455
456         try {
457             this.OutStream.write(msgBuffer);
458         } catch (IOException var4) {
459             var4.printStackTrace();
460         }
461
462     }
463
464     public void sendfile(String filename) {
465         try {
466             FileInputStream fis = new FileInputStream("/sdcard/Download/" + filename);
467             byte[] data = new byte[fis.available()];
468
469             while (fis.read(data) != -1) {
470                 ;
471             }
472
473             this.OutStream.write(data);
474             fis.close();
475         } catch (Exception var4) {
476             ;
477         }
478
479     }
480
481     public void downloadpcx(String filename) {
482         try {
483             FileInputStream fis = new FileInputStream("/sdcard/Download/" + filename);
484             byte[] data = new byte[fis.available()];
485             String download = "DOWNLOAD F,\"" + filename + "\"," + data.length + ",";
486             byte[] download_head = download.getBytes();
487
488             while (fis.read(data) != -1) {
489                 ;
490             }
491
492             this.OutStream.write(download_head);
493             this.OutStream.write(data);
494             fis.close();
495         } catch (Exception var6) {
496             ;
497         }
498
499     }
500
501     public void downloadbmp(String filename,Context ctxt) {
502         try {
503             //String name =  android.os.Environment.getExternalStorageState()+File.separator+filename;
504             //FileInputStream fis = new FileInputStream(name);//("/sdcard/Download/" + filename);
505             byte[] data = new FileUtils(ctxt).readSDFile(filename).getBytes("gb2312");//new byte[fis.available()];
506             String download = "DOWNLOAD F,\"" + filename + "\"," + data.length + ",";
507             byte[] download_head = download.getBytes();
508
509             this.OutStream.write(download_head);
510             this.OutStream.write(data);
511         } catch (Exception var6) {
512             Log.e("",""+var6.getMessage());
513         }
514
515     }
516
517     public void downloadbmp(String filename) {
518         try {
519             //String name =  android.os.Environment.getExternalStorageState()+File.separator+filename;
520             //FileInputStream fis = new FileInputStream(name);//("/sdcard/Download/" + filename);
521             byte[] data = new FileUtils(getApplicationContext()).readSDFile(filename).getBytes("gb2312");//new byte[fis.available()];
522             String download = "DOWNLOAD F,\"" + filename + "\"," + data.length + ",";
523             byte[] download_head = download.getBytes();
524
525             this.OutStream.write(download_head);
526             this.OutStream.write(data);
527         } catch (Exception var6) {
528             Log.e("",""+var6.getMessage());
529         }
530
531     }
532
533     public void downloadttf(String filename) {
534         try {
535             FileInputStream fis = new FileInputStream("/sdcard/Download/" + filename);
536             byte[] data = new byte[fis.available()];
537             String download = "DOWNLOAD F,\"" + filename + "\"," + data.length + ",";
538             byte[] download_head = download.getBytes();
539
540             while (fis.read(data) != -1) {
541                 ;
542             }
543
544             this.OutStream.write(download_head);
545             this.OutStream.write(data);
546             fis.close();
547         } catch (Exception var6) {
548             ;
549         }
550
551     }
552 }

3、打印效果

时间: 2024-10-25 22:31:08

68、TSPL指令集(标签打印机)的相关文章

004-JVM指令集(指令码、助记符、功能描述)

一.JVM指令助记符 1)操作数栈 变量到操作数栈:iload,iload_,lload,lload_,fload,fload_,dload,dload_,aload,aload_ 操作数栈到变量:istore,istore_,lstore,lstore_,fstore,fstore_,dstore,dstor_,astore,astore_ 常数到操作数栈:bipush,sipush,ldc,ldc_w,ldc2_w,aconst_null,iconst_ml,iconst_,lconst_,

汇编指令集

intel 官方指令集供参考 1 X86和X87汇编指令大全(有注释) 2 ---------- 一.数据传输指令 ---------------------------------------------------- 3 它们在存贮器和寄存器.寄存器和输入输出端口之间传送数据. 4 1. 通用数据传送指令. 5 MOV 传送字或字节. 6 MOVSX 先符号扩展,再传送. 7 MOVZX 先零扩展,再传送. 8 PUSH 把字压入堆栈. 9 POP 把字弹出堆栈. 10 PUSHA 把AX,

xcode armv6 armv7 armv7s arm64指令集

郝萌主倾心贡献,尊重作者的劳动成果,请勿转载. 如果文章对您有所帮助,欢迎给作者捐赠,支持郝萌主,捐赠数额随意,重在心意^_^ 我要捐赠: 点击捐赠 Cocos2d-X源码下载:点我传送 之前每个版本的ipa包打出来都才20M出头,后来不知道从哪个版本起打的包每次都将近40M,但是工程中也没有明显的增加很大第三方类或者图片.静态文件.于是就开始了各种瘦身计划:压缩图片,删除不必要静态库.做了一番改动后发现包只比原来小了1M多,收效甚微. 其实是armv6 armv7 armv7s arm64引起

xshell 输入w 命令后报错 68 column window is too narrow

报错信息: 68 column window is too narrow 报错原因: 有很多人喜欢用xshell都喜欢是半屏,出现这个的原因就是半屏状态下xshell窗口太小了,打开窗口尺寸到71就好了. 解决办法: 看见打开到71时已经不报错,这个格式是默认输出的格式, 你也可以 使用: w | cat 来进行文本的方式查看. END

ARM指令集、Thumb指令集、Thumb-2指令集

MCU使用什么指令集主要由内核决定的,比如Cortex-M3使用的是Thumb-2指令集 ARM指令集: 编代码全部是 32bits 的,每条指令能承载更多的信息,因此使用最少的指令完成功能, 所以在相同频率下运行速度也是最快的, 但也因为每条指令是32bits 的而占用了最多的程序空间. Thumb指令集: 编代码全部是 16bits 的,每条指令所能承载的信息少,因此它需要使用更多的指令才能完成功能, 因此运行速度慢, 但它也占用了最少的程序空间 Thumb-2指令集:在前面两者之间取了一个

x86指令集同频性能提升

x86近5000条指令,迄今为止最复杂的指令集.这里不研究CISC & RISC,也不考虑process制程变化,主要是看最近几代IA架构对于同频率下性能的提升. x86指令集nasm文档 http://www.nasm.us/doc/nasmdocb.html http://www.nasm.us/pub/nasm/releasebuilds/2.12.03rc1/doc/nasmdoc.txt skylake架构和haswell架构同频性能对比 : 同频+15%  (geekbench) H

otool介绍(转http://www.mc2lab.com/?p=68)

1. Otool简介 Otool可以提取并显示ios下目标文件的相关信息,包括头部,加载命令,各个段,共享库,动态库等等.它拥有大量的命令选项,是一个功能强大的分析工具,当然还可以做反汇编的工具使用. 2. Mach-o基本结构 Mach-o包含三个基本区域: 头部(header structure). 加载命令(load command). 段(segment).可以拥有多个段(segment),每个段可以拥有零个或多个区域(section).每一个段(segment)都拥有一段虚拟地址映射到

《深入Java虚拟机》笔记:指令集 (转)

<深入Java虚拟机>笔记:指令集 指令 含义 iconst_m1 把int型常量-1压入栈中 iconst_0 把int型常量压入栈中 fconst_1 把float型常量1压入栈中 lconst_2 把long型常量2压入栈中 dconst_3 把double型常量3压入栈中 bipush byte1 把byte1转换成int型压入栈中 sipush byte1,byte2 把byte1,byte2组成的short转换成int压入栈中 aconst_null 把空对象压入栈中 ldc in

Atitit..net&#160;clr&#160;il指令集&#160;以及指令分类&#160;&#160;与指令详细说明

Atitit..net clr il指令集 以及指令分类  与指令详细说明 1.1. .NET CLR 和 Java VM 都是堆叠式虚拟机器(Stack-Based VM), 1 1.2. 查看工具ILDASM1 1.3. 此程式执行时,关键的记忆体有三种,分別是:1 1.4. Il指令集2 1.4.1. Mov指令3 1.4.2.  跳转指令集合6 1.4.3.  算术 逻辑 与移位指令8 1.4.4. 类型转换9 1.4.5. Other  and oo指令10 2. 参考12 1.1.