Hi,
I am writing driver for fiscal device. Usually you send binary command and receive answer from the device. In the last versions of B4A it became extremely difficult to manage it and I need some help. In order to make the question simpler, I will draw some block diagram:
1. The Android Device sends command to the Fiscal Printer via Socket;
2. Give time of 50 miliseconds to the Fiscal Printer to receive the command and send you ACK signal;
3. The Fiscal Printer should respond in 60 - 300 miliseconds. It can send you answer or command "Wait" for another 60 - 300 miliseconds;
4. Step 3 can be repeated several times, it depends on the load of the printer and current status;
5. The Fiscal Device send you the answer of the command in Step 1;
6. The Android Device should wait until Step 5 is completed to continue again with Step 1.
Generally this is something like:
PrinterTX.Write(WriteBuffer)
Multi Wait for PrinterTX_NewData (Buffer() As Byte) ' Here you should get the complete answer, because the device sends it part by part
If I use Wait For, it just gets the first received data and the parent sub continue.
Shortly: Single send, multiple sequential answers, the parent procedure should continue only when the complete multipart answer was received.
In V4A (previous versons) I do it with my own Sleep procedure, which just sleeps and do not allow parent sub to continue.
Any ideas?
I am writing driver for fiscal device. Usually you send binary command and receive answer from the device. In the last versions of B4A it became extremely difficult to manage it and I need some help. In order to make the question simpler, I will draw some block diagram:
1. The Android Device sends command to the Fiscal Printer via Socket;
2. Give time of 50 miliseconds to the Fiscal Printer to receive the command and send you ACK signal;
3. The Fiscal Printer should respond in 60 - 300 miliseconds. It can send you answer or command "Wait" for another 60 - 300 miliseconds;
4. Step 3 can be repeated several times, it depends on the load of the printer and current status;
5. The Fiscal Device send you the answer of the command in Step 1;
6. The Android Device should wait until Step 5 is completed to continue again with Step 1.
Generally this is something like:
PrinterTX.Write(WriteBuffer)
Multi Wait for PrinterTX_NewData (Buffer() As Byte) ' Here you should get the complete answer, because the device sends it part by part
If I use Wait For, it just gets the first received data and the parent sub continue.
Shortly: Single send, multiple sequential answers, the parent procedure should continue only when the complete multipart answer was received.
In V4A (previous versons) I do it with my own Sleep procedure, which just sleeps and do not allow parent sub to continue.
Any ideas?