Skip to content

Commit

Permalink
fix issue #257: Temporarily accept NRCs during read DFCs
Browse files Browse the repository at this point in the history
Since not all vehicles support mode 0x0A, some do report NRC 11
  • Loading branch information
fr3ts0n committed Mar 20, 2024
1 parent 5cb97ad commit 436d86d
Showing 1 changed file with 33 additions and 18 deletions.
51 changes: 33 additions & 18 deletions androbd/src/main/java/com/fr3ts0n/ecu/gui/androbd/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,14 @@ public class MainActivity extends PluginManager
* toast for showing exit message
*/
private static Toast exitToast = null;

/**
* Flag to temporarily ignore NRCs
* This flag ist used to temporarily allow negative OBD responses without issuing an error message.
* i.e. un-supported mode 0x0A for DFC reading
*/
private static boolean ignoreNrcs = false;

/**
* handler for freeze frame selection
*/
Expand Down Expand Up @@ -426,38 +434,41 @@ public void handleMessage(Message msg)
// handle negative result code from OBD protocol
case MESSAGE_OBD_NRC:
// show error dialog ...
evt = (PropertyChangeEvent) msg.obj;
ObdProt.NRC nrc = (ObdProt.NRC) evt.getOldValue();
String nrcMsg = (String) evt.getNewValue();
switch (nrc.disp)
if(! ignoreNrcs)
{
case ERROR:
dlgBuilder
evt = (PropertyChangeEvent) msg.obj;
ObdProt.NRC nrc = (ObdProt.NRC) evt.getOldValue();
String nrcMsg = (String) evt.getNewValue();
switch (nrc.disp)
{
case ERROR:
dlgBuilder
.setIcon(android.R.drawable.ic_dialog_alert)
.setTitle(R.string.obd_error)
.setMessage(nrcMsg)
.setPositiveButton(null, null)
.show();
break;
// Display warning (with confirmation)
case WARN:
dlgBuilder
break;
// Display warning (with confirmation)
case WARN:
dlgBuilder
.setIcon(android.R.drawable.ic_dialog_info)
.setTitle(R.string.obd_error)
.setMessage(nrcMsg)
.setPositiveButton(null, null)
.show();
break;
// Display notification (no confirmation)
case NOTIFY:
Toast.makeText(getApplicationContext(),
break;
// Display notification (no confirmation)
case NOTIFY:
Toast.makeText(getApplicationContext(),
nrcMsg,
Toast.LENGTH_SHORT).show();
break;
break;

case HIDE:
default:
// intentionally ignore
case HIDE:
default:
// intentionally ignore
}
}
break;

Expand Down Expand Up @@ -1956,6 +1967,8 @@ private void setObdService(int newObdService, CharSequence menuTitle)
{
// remember this as current OBD service
obdService = newObdService;
ignoreNrcs = false;

// set list view
setContentView(mListView);
getListView().setOnItemLongClickListener(this);
Expand Down Expand Up @@ -2000,6 +2013,8 @@ private void setObdService(int newObdService, CharSequence menuTitle)
case ObdProt.OBD_SVC_PENDINGCODES:
case ObdProt.OBD_SVC_PERMACODES:
case ObdProt.OBD_SVC_READ_CODES:
// NOT all DFC modes are supported by all vehicles, disable NRC handling for this request
ignoreNrcs = true;
currDataAdapter = mDfcAdapter;
Toast.makeText(this, getString(R.string.long_press_dfc_hint), Toast.LENGTH_LONG).show();
break;
Expand Down

0 comments on commit 436d86d

Please sign in to comment.