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 am sending a command that typically returns answer slower than other commands. Interesting thing is that if i am in debug and i stop for 5 minutes before trying to read and then i read, the answer is returned as expected, but if i start reading in a loop immediately the answer never comes even if i wait for 10 or 15 minutes. If i put tread.sleep for 5 minutes before the read() again answer never comes. If i use SerialInputOutputManager for event-driven read again the answer never comes. I tried different baudrates but the result is the same. I downloaded the UsbSerialExample project and there the command takes some time and then return answer as expected. The expected answer is 908 bytes.
Here is the code i am using. If i send a command that returns answer faster there is no problem. Code example.txt
Update: The problem was that in my project there is sdk that internally uses UsbSerialForAndroid with the SerialInputOutputManager and every time i send command to the serial device the sdk reads the answer before i read it and when i try to read there is no answer anymore because the SerialInputOutoputManager already read it. The solution was to stop the sdk if i am going to send commands, but i wonder what if i need the sdk to be working along with my part of the code sending commands to other serial devices (the sdk works for card payment devices and my part of the code for fiscal printers). I was thinking maybe if such situation occurs i can use reflection to access the SerialInputOutputManager in the sdk and stop it before i send command and start it again when i read the answer for the sent command.
The SerialInputOutputManager class has to be instantiated with a concrete UsbSerialPort.
Probably the SDK simply tried all UsbSerialPort, so it received data before your app.
Maybe if i can somehow deny the access for the port where my device is connected for for everybody except for me and than only i will send commands and receive answers.
I am sending a command that typically returns answer slower than other commands. Interesting thing is that if i am in debug and i stop for 5 minutes before trying to read and then i read, the answer is returned as expected, but if i start reading in a loop immediately the answer never comes even if i wait for 10 or 15 minutes. If i put tread.sleep for 5 minutes before the read() again answer never comes. If i use SerialInputOutputManager for event-driven read again the answer never comes. I tried different baudrates but the result is the same. I downloaded the UsbSerialExample project and there the command takes some time and then return answer as expected. The expected answer is 908 bytes.
Here is the code i am using. If i send a command that returns answer faster there is no problem.
Code example.txt
` public byte[] SeekUSBDeviceAndSendCommand(boolean fiscal)
{
UsbManager manager = (UsbManager) App.currentActivity.getSystemService(Context.USB_SERVICE);
return null;
} `
The text was updated successfully, but these errors were encountered: