mirror of https://github.com/rusefi/rusefi.git
read config error
This commit is contained in:
parent
9339253acb
commit
690b06133f
|
@ -35,6 +35,7 @@ import android.text.util.Linkify;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.Window;
|
import android.view.Window;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
|
import android.widget.Button;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
@ -55,6 +56,7 @@ import com.rusefi.io.ConnectionStateListener;
|
||||||
import com.rusefi.io.DfuHelper;
|
import com.rusefi.io.DfuHelper;
|
||||||
import com.rusefi.io.IoStream;
|
import com.rusefi.io.IoStream;
|
||||||
import com.rusefi.io.LinkManager;
|
import com.rusefi.io.LinkManager;
|
||||||
|
import com.rusefi.io.commands.ErrorInfoCommand;
|
||||||
import com.rusefi.io.serial.StreamConnector;
|
import com.rusefi.io.serial.StreamConnector;
|
||||||
import com.rusefi.proxy.NetworkConnector;
|
import com.rusefi.proxy.NetworkConnector;
|
||||||
import com.rusefi.proxy.NetworkConnectorContext;
|
import com.rusefi.proxy.NetworkConnectorContext;
|
||||||
|
@ -74,6 +76,8 @@ public class rusEFI extends Activity {
|
||||||
|
|
||||||
private static final String VERSION = "rusEFI app v0.20220524\n";
|
private static final String VERSION = "rusEFI app v0.20220524\n";
|
||||||
|
|
||||||
|
private static final int LOCAL_PORT = 29001;
|
||||||
|
|
||||||
/* UI elements */
|
/* UI elements */
|
||||||
private TextView mStatusView;
|
private TextView mStatusView;
|
||||||
private TextView mResultView; // global dump of all messages
|
private TextView mResultView; // global dump of all messages
|
||||||
|
@ -102,6 +106,9 @@ public class rusEFI extends Activity {
|
||||||
findViewById(R.id.buttonSound).setVisibility(View.GONE);
|
findViewById(R.id.buttonSound).setVisibility(View.GONE);
|
||||||
findViewById(R.id.buttonDfu).setVisibility(View.GONE);
|
findViewById(R.id.buttonDfu).setVisibility(View.GONE);
|
||||||
|
|
||||||
|
Button view = findViewById(R.id.localBroadcast);
|
||||||
|
view.setText("Local broadcast on " + LOCAL_PORT);
|
||||||
|
|
||||||
broadcastStatus = findViewById(R.id.broadcastStatus);
|
broadcastStatus = findViewById(R.id.broadcastStatus);
|
||||||
broadcastStatus.setVisibility(View.GONE);
|
broadcastStatus.setVisibility(View.GONE);
|
||||||
|
|
||||||
|
@ -264,6 +271,9 @@ public class rusEFI extends Activity {
|
||||||
connectDashboard();
|
connectDashboard();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void onLocalBroadcast(View view) {
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when the user touches a button
|
* Called when the user touches a button
|
||||||
*/
|
*/
|
||||||
|
@ -344,6 +354,10 @@ public class rusEFI extends Activity {
|
||||||
try {
|
try {
|
||||||
String signature = BinaryProtocol.getSignature(serial);
|
String signature = BinaryProtocol.getSignature(serial);
|
||||||
visibleLogAppend("Connected to " + signature);
|
visibleLogAppend("Connected to " + signature);
|
||||||
|
ErrorInfoCommand.send(serial);
|
||||||
|
String configError = ErrorInfoCommand.getResponse(serial.getDataBuffer());
|
||||||
|
if (configError != null)
|
||||||
|
visibleLogAppend("[CRITICAL] " + configError);
|
||||||
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
|
@ -60,6 +60,13 @@
|
||||||
android:onClick="onConnectButton"
|
android:onClick="onConnectButton"
|
||||||
android:text="Connect" />
|
android:text="Connect" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/localBroadcast"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:onClick="onLocalBroadcast"
|
||||||
|
android:text="local" />
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/buttonBroadcast"
|
android:id="@+id/buttonBroadcast"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
@ -83,5 +90,11 @@
|
||||||
android:layout_height="wrap_content" />
|
android:layout_height="wrap_content" />
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/button"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="Button" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
|
@ -0,0 +1,24 @@
|
||||||
|
package com.rusefi.io.commands;
|
||||||
|
|
||||||
|
import com.rusefi.binaryprotocol.IncomingDataBuffer;
|
||||||
|
import com.rusefi.config.generated.Fields;
|
||||||
|
import com.rusefi.io.IoStream;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.io.EOFException;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import static com.rusefi.io.commands.HelloCommand.getStringResponse;
|
||||||
|
|
||||||
|
public class ErrorInfoCommand {
|
||||||
|
public static void send(IoStream stream) throws IOException {
|
||||||
|
stream.sendPacket(new byte[]{Fields.TS_GET_CONFIG_ERROR});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public static String getResponse(IncomingDataBuffer incomingData) throws EOFException {
|
||||||
|
return getStringResponse("[config_error]", incomingData);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -24,7 +24,12 @@ public class HelloCommand implements Command {
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public static String getHelloResponse(IncomingDataBuffer incomingData) throws EOFException {
|
public static String getHelloResponse(IncomingDataBuffer incomingData) throws EOFException {
|
||||||
byte[] response = incomingData.getPacket("[hello]");
|
return getStringResponse("[hello]", incomingData);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public static String getStringResponse(String msg, IncomingDataBuffer incomingData) throws EOFException {
|
||||||
|
byte[] response = incomingData.getPacket(msg);
|
||||||
if (!checkResponseCode(response, (byte) Fields.TS_RESPONSE_OK))
|
if (!checkResponseCode(response, (byte) Fields.TS_RESPONSE_OK))
|
||||||
return null;
|
return null;
|
||||||
return new String(response, 1, response.length - 1);
|
return new String(response, 1, response.length - 1);
|
||||||
|
|
Loading…
Reference in New Issue