fintrace / tspl2-driver Goto Github PK
View Code? Open in Web Editor NEWJava client to communicate to label printers that support TSPL2 (by TSC)
License: Apache License 2.0
Java client to communicate to label printers that support TSPL2 (by TSC)
License: Apache License 2.0
Hello, I cannot find where is this function come from:
properties().getProperty("tsc.vendor.id")
please help, thanks
`package com.mycompany.app;
import org.fintrace.core.drivers.tspl.commands.device.Counter;
import org.fintrace.core.drivers.tspl.commands.device.CounterExpression;
import org.fintrace.core.drivers.tspl.commands.label.BarcodeAlignment;
import org.fintrace.core.drivers.tspl.commands.label.BarcodeRotation;
import org.fintrace.core.drivers.tspl.commands.label.DataMatrix;
import org.fintrace.core.drivers.tspl.commands.label.Text;
import org.fintrace.core.drivers.tspl.commands.label.TscLabel;
import org.fintrace.core.drivers.tspl.commands.system.ClearBuffer;
import org.fintrace.core.drivers.tspl.commands.system.Direction;
import org.fintrace.core.drivers.tspl.commands.system.Gap;
import org.fintrace.core.drivers.tspl.commands.system.Print;
import org.fintrace.core.drivers.tspl.commands.system.Size;
import lombok.extern.slf4j.Slf4j;
import org.fintrace.core.drivers.tspl.commands.status.TSPLStatusPollCommands;
import org.fintrace.core.drivers.tspl.connection.EthernetConnectionClient;
import org.fintrace.core.drivers.tspl.connection.USBConnectionClient;
import org.fintrace.core.drivers.tspl.connection.TSPLConnectionClient;
import org.fintrace.core.drivers.tspl.exceptions.ConnectionClientException;
import org.fintrace.core.drivers.tspl.listeners.ClientListener;
import org.fintrace.core.drivers.tspl.listeners.DataListener;
/**
*/
public class App
{
public static void main( String[] args )
{
// USB Client
TSPLConnectionClient tsplConnectionClient = new USBConnectionClient(
(short) Integer.parseInt(properties().getProperty("tsc.vendor.id"), 16),
(short) Integer.parseInt(properties().getProperty("tsc.product.id"), 16));
tsplConnectionClient.init();
tsplConnectionClient.connect();
TscLabel tscLabel = TscLabel.builder()
.element(Size.builder().labelWidth(4f).labelLength(3f).build())
.element(Gap.builder().labelDistance(0f).labelOffsetDistance(0f).build())
.element(Direction.builder().printPositionAsFeed(Boolean.TRUE).build())
.element(ClearBuffer.builder().build())
.element(DataMatrix.builder().xCoordinate(10).yCoordinate(110).width(400)
.height(400).content("DMATRIX EXAMPLE 1").build())
.element(DataMatrix.builder().xCoordinate(310).yCoordinate(110).width(400)
.height(400).moduleSize(6).content("DMATRIX EXAMPLE 2").build())
.element(DataMatrix.builder().xCoordinate(10).yCoordinate(310).width(400)
.height(400).moduleSize(8).nbRows(18).nbCols(18)
.content("DMATRIX EXAMPLE 3").build())
.element(Print.builder().nbLabels(1).nbCopies(1).build())
.build();
tsplConnectionClient.send(tscLabel);
tsplConnectionClient.disconnect();
tsplConnectionClient.shutdown();
System.out.print(tscLabel.getTsplCode());
}
}`
Hi man! I realy need a little example of simple maven project, just for print this label:
TSPLLabel tsplLabel = TSPLLabel.builder()
.element(Size.builder().labelWidth(4f).labelLength(3f).build())
.element(Gap.builder().labelDistance(0f).labelOffsetDistance(0f).build())
.element(Direction.builder().printPositionAsFeed(Boolean.TRUE).build())
.element(ClearBuffer.builder().build())
.element(DataMatrix.builder().xCoordinate(10).yCoordinate(110).width(400)
.height(400).content("DMATRIX EXAMPLE 1").build())
.element(DataMatrix.builder().xCoordinate(310).yCoordinate(110).width(400)
.height(400).moduleSize(6).content("DMATRIX EXAMPLE 2").build())
.element(DataMatrix.builder().xCoordinate(10).yCoordinate(310).width(400)
.height(400).moduleSize(8).nbRows(18).nbCols(18)
.content("DMATRIX EXAMPLE 3").build())
.element(Print.builder().nbLabels(1).nbCopies(1).build())
.build();
I have spend much time, but my TSC tspl2 printer do not print this at all.
Create please simple console program to print this your example.
Thanks!
Hello,
Is there any way so we can send file (image) to the printer and print it ?
As per the TSPL specification that would be possible.
Thanks
Hi, how to print pictures?
Hi, Barcode is not working.
ShoulD be with rotation 0 but is setting STRING (no_rotation)
BARCODE 380,220, "128",100,0,NO_ROTATION,1,1,0,"123456"
Or null if rotation is not set:
BARCODE 38,220, "128",50,0,null,2,2,1,"LEFT"
When i want to connect USB device it says;
SWT SessionManagerDBus: Failed to connect to org.gnome.SessionManager: Ba\u011flant\u0131 kapal\u0131
SWT SessionManagerDBus: Failed to connect to org.xfce.SessionManager: Ba\u011flant\u0131 kapal\u0131
[main] INFO org.fintrace.core.drivers.tspl.connection.USBConnectionClient - USB Service Implementation: usb4java
[main] INFO org.fintrace.core.drivers.tspl.connection.USBConnectionClient - Implementation version: 1.2.0
[main] INFO org.fintrace.core.drivers.tspl.connection.USBConnectionClient - Service API version: 1.0.2
[main] INFO org.fintrace.core.drivers.tspl.connection.USBConnectionClient - Interface Direction: 0, Interface Address: 2
[main] INFO org.fintrace.core.drivers.tspl.connection.USBConnectionClient - Interface Direction: -128, Interface Address: -126
My Code is;
TSPLConnectionClient tsplConnectionClient = new USBConnectionClient((short)0x20d1,(short)0x7008 );
tsplConnectionClient.init();
tsplConnectionClient.connect();
My usb-devices list
T: Bus=01 Lev=01 Prnt=01 Port=01 Cnt=02 Dev#= 2 Spd=12 MxCh= 0
D: Ver= 1.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS= 8 #Cfgs= 1
P: Vendor=20d1 ProdID=7008 Rev=01.00
S: Manufacturer=HPRT
S: Product=LPQ58
S: SerialNumber=LPQ58017220173
C: #Ifs= 1 Cfg#= 1 Atr=c0 MxPwr=10mA
I: If#=0x0 Alt= 0 #EPs= 2 Cls=07(print) Sub=01 Prot=02 Driver=(none)
Please help. Thanks a lot.
Hello, here is my main class. I can build the package but when I run I got the error. thanks
package com.mycompany.app;
import org.fintrace.core.drivers.tspl.commands.device.Counter;
import org.fintrace.core.drivers.tspl.commands.device.CounterExpression;
import org.fintrace.core.drivers.tspl.commands.label.BarcodeAlignment;
import org.fintrace.core.drivers.tspl.commands.label.BarcodeRotation;
import org.fintrace.core.drivers.tspl.commands.label.DataMatrix;
import org.fintrace.core.drivers.tspl.commands.label.Text;
import org.fintrace.core.drivers.tspl.commands.label.TscLabel;
import org.fintrace.core.drivers.tspl.commands.system.ClearBuffer;
import org.fintrace.core.drivers.tspl.commands.system.Direction;
import org.fintrace.core.drivers.tspl.commands.system.Gap;
import org.fintrace.core.drivers.tspl.commands.system.Print;
import org.fintrace.core.drivers.tspl.commands.system.Size;
public class App
{
public static void main( String[] args )
{
// USB Client
//TSPLConnectionClient tsplConnectionClient = new USBConnectionClient(
//(short) Integer.parseInt(properties().getProperty("tsc.vendor.id"), 16),
//(short) Integer.parseInt(properties().getProperty("tsc.product.id"), 16));
//tsplConnectionClient.init();
//tsplConnectionClient.connect();
TscLabel tscLabel = TscLabel.builder()
.element(Size.builder().labelWidth(4f).labelLength(3f).build())
.element(Gap.builder().labelDistance(0f).labelOffsetDistance(0f).build())
.element(Direction.builder().printPositionAsFeed(Boolean.TRUE).build())
.element(ClearBuffer.builder().build())
.element(DataMatrix.builder().xCoordinate(10).yCoordinate(110).width(400)
.height(400).content("DMATRIX EXAMPLE 1").build())
.element(DataMatrix.builder().xCoordinate(310).yCoordinate(110).width(400)
.height(400).moduleSize(6).content("DMATRIX EXAMPLE 2").build())
.element(DataMatrix.builder().xCoordinate(10).yCoordinate(310).width(400)
.height(400).moduleSize(8).nbRows(18).nbCols(18)
.content("DMATRIX EXAMPLE 3").build())
.element(Print.builder().nbLabels(1).nbCopies(1).build())
.build();
System.out.println(tscLabel);
//tsplConnectionClient.send(tscLabel);
//tsplConnectionClient.disconnect();
//tsplConnectionClient.shutdown();
}
}
Is I missing the dependency jar package?
I can print labels, but I could not query the situation.
TSPLConnectionClient tsplConnectionClient = new USBConnectionClient((short) 4611);
tsplConnectionClient.addDataListener(new DataListener() {..}
tsplConnectionClient.init();
tsplConnectionClient.connect();
tsplConnectionClient.send(TSPLStatusPollCommands.STATUS.getCommand() + LF);
The printer device has been authorized. MODE="0666"
What I'm doing wrong?
how to do it?can you make a sample?
When I'm trying connect to the usb label printer HPRT LPQ58, have an error in method connect().
TSPLConnectionClient tsplConnectionClient = new USBConnectionClient((short)8401, (short)28680); tsplConnectionClient.init(); tsplConnectionClient.connect();
java.lang.NullPointerException at org.fintrace.core.drivers.tspl.connection.USBConnectionClient.getWritePipe(USBConnectionClient.java:311) at org.fintrace.core.drivers.tspl.connection.USBConnectionClient.connect(USBConnectionClient.java:108)
Zadig is not helping.
What I'm doing wrong?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.