Browse Source

Add flushing before sync to be sure the buffer is empty

tags/release-v1.2
Schoumi 2 years ago
parent
commit
1c5c369ebf

+ 1
- 0
app/src/main/java/fr/mobdev/lpcprog/fragment/FlashFragment.java View File

@@ -261,6 +261,7 @@ public class FlashFragment extends Fragment{
Button bt = v.findViewById(R.id.retry_isp_mode);
bt.setVisibility(View.VISIBLE);
flash_infoStr += getString(R.string.fail) + "\n";
flash_infoStr += getString(R.string.try_isp_again)+"\n";
flash_info.setText(flash_infoStr);
} else {
View v = getView();

+ 13
- 3
app/src/main/java/fr/mobdev/lpcprog/managers/IspManager.java View File

@@ -113,12 +113,13 @@ public class IspManager {
return true;
}

private void clearBuffer(int size) {
private int clearBuffer(int size) {
if (serialPort == null)
return;
return -1;

byte[] buf = new byte[size];
read(buf, size, 500);
int ret = read(buf, size, 1000);
return ret;
}

public String[] readUid() {
@@ -299,8 +300,16 @@ public class IspManager {
private boolean synchronize(int crystal_freq) {
if (serialPort == null)
return false;
int cpt = 0;
while(clearBuffer(1000) > 0 && cpt < 20)
{
cpt++;
}
serialPort.purge(D2xxManager.FT_PURGE_RX);
serialPort.purge(D2xxManager.FT_PURGE_TX);
if(cpt == 20) {
return false;
}
byte[] buf;
if (serialPort.write(SYNC_START) != SYNC_START.length) {
return false;
@@ -500,6 +509,7 @@ public class IspManager {

private int parseRetCode(byte[] data) {
String str = new String(data,0,2);
str.replace(" ","");
str = str.replace("\r", "");
str = str.replace("\n", "");
if (!str.matches("[0-9 -+]*")||str.isEmpty())

+ 1
- 0
app/src/main/res/values/strings.xml View File

@@ -88,6 +88,7 @@
<string name="download_binary">Download Binary</string>
<string name="informations">Informations</string>
<string name="no_device">No Device Pluggued, please plug one to be able to flash a binary on it.</string>
<string name="try_isp_again">Please try to reset your device in ISP Mode again</string>
<array name="uuencode_array">
<item>Yes</item>
<item>No</item>

Loading…
Cancel
Save