本文整理匯總了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());
}