You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've been utilizing your Android thermal POS printing library for my projects, and I'm impressed with its functionality and ease of use.
I have a suggestion for a small enhancement that could greatly benefit users like myself. I've noticed that the current DeviceConnection class provides robust support for sending data (OutputStream) to the device. However, for certain use cases, having the ability to receive data (InputStream) from the device would be invaluable.
Here's a proposed modification to the DeviceConnection class:
`public abstract class DeviceConnection {
protected OutputStream outputStream;
protected InputStream inputStream; // New addition
protected byte[] data;
public DeviceConnection() {
this.outputStream = null;
this.inputStream = null; // Initialize inputStream
this.data = new byte[0];
}
// Existing methods...
/**
* Read data from the device.
*/
public byte[] read(int length) throws EscPosConnectionException {
if (!this.isConnected() || this.inputStream == null) {
throw new EscPosConnectionException("Unable to read data from device.");
}
try {
byte[] buffer = new byte[length];
int bytesRead = this.inputStream.read(buffer);
if (bytesRead == -1) {
throw new EscPosConnectionException("End of stream reached unexpectedly.");
}
return Arrays.copyOf(buffer, bytesRead);
} catch (IOException e) {
e.printStackTrace();
throw new EscPosConnectionException(e.getMessage());
}
}
// Other methods...
public abstract DeviceConnection connect() throws EscPosConnectionException;
public abstract DeviceConnection disconnect();
// Existing methods...
/**
* Check if InputStream is open.
*
* @return true if is connected
*/
public boolean isInputConnected() {
return this.inputStream != null;
}
/**
* Set InputStream for the device connection.
*/
public void setInputStream(InputStream inputStream) {
this.inputStream = inputStream;
}
}
`
The text was updated successfully, but these errors were encountered:
I've been utilizing your Android thermal POS printing library for my projects, and I'm impressed with its functionality and ease of use.
I have a suggestion for a small enhancement that could greatly benefit users like myself. I've noticed that the current DeviceConnection class provides robust support for sending data (OutputStream) to the device. However, for certain use cases, having the ability to receive data (InputStream) from the device would be invaluable.
Here's a proposed modification to the DeviceConnection class:
`public abstract class DeviceConnection {
protected OutputStream outputStream;
protected InputStream inputStream; // New addition
protected byte[] data;
}
`
The text was updated successfully, but these errors were encountered: