本文整理汇总了Java中com.starmicronics.stario.StarIOPort类的典型用法代码示例。如果您正苦于以下问题:Java StarIOPort类的具体用法?Java StarIOPort怎么用?Java StarIOPort使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
StarIOPort类属于com.starmicronics.stario包,在下文中一共展示了StarIOPort类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getFirstPrinter
import com.starmicronics.stario.StarIOPort; //导入依赖的package包/类
/**
* Using the portNameSearch parameter, this method searches for the first printer that corresponds to the
* search
* @param portNameSearch the name of the printer to search (example BT: or TCP:xxx.xxx.xxx.xxx)
* @return
*/
public static String getFirstPrinter(String portNameSearch) {
String portName = "";
List<PortInfo> portList;
try {
portList = StarIOPort.searchPrinter(portNameSearch);
for (PortInfo portInfo : portList) {
portName = portInfo.getPortName();
break;
}
} catch (StarIOPortException e) {
e.printStackTrace();
}
return portName;
}
示例2: disconnect
import com.starmicronics.stario.StarIOPort; //导入依赖的package包/类
static synchronized void disconnect() {
if (mPopManager != null && mPopManager.port != null) {
try {
StarIOPort.releasePort(mPopManager.port);
} catch (StarIOPortException e) {
e.printStackTrace();
}
}
mPopManager = null;
}
示例3: searchPrinterEntry
import com.starmicronics.stario.StarIOPort; //导入依赖的package包/类
public static MPopEntries searchPrinterEntry() {
MPopEntries mPopEntries = new MPopEntries();
try {
ArrayList<PortInfo> ports = StarIOPort.searchPrinter("BT:");
for (PortInfo each: ports) {
mPopEntries.add(each.getPortName(), each.getMacAddress());
}
} catch (StarIOPortException e) {
e.printStackTrace();
}
return mPopEntries;
}
示例4: sendCommands
import com.starmicronics.stario.StarIOPort; //导入依赖的package包/类
static Result sendCommands(byte[] commands, StarIOPort port) {
Result result = Result.ErrorUnknown;
try {
if (port == null) {
result = Result.ErrorOpenPort;
return result;
}
// // When using an USB interface, you may need to send the following data.
// byte[] dummy = {0x00};
// port.writePort(dummy, 0, dummy.length);
StarPrinterStatus status;
result = Result.ErrorWritePort;
status = port.retreiveStatus();
if (status.rawLength == 0) {
throw new StarIOPortException("A printer is offline");
}
result = Result.ErrorWritePort;
port.writePort(commands, 0, commands.length);
result = Result.ErrorWritePort;
status = port.retreiveStatus();
if (status.rawLength == 0) {
throw new StarIOPortException("A printer is offline");
}
result = Result.Success;
}
catch (StarIOPortException e) {
// Nothing
}
return result;
}
示例5: getPort
import com.starmicronics.stario.StarIOPort; //导入依赖的package包/类
static StarIOPort getPort(String portName) throws StarIOPortException {
return getPort(portName, null, timeout, Pasteque.getAppContext());
}