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.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.TextView;
|
||||
|
||||
|
@ -55,6 +56,7 @@ import com.rusefi.io.ConnectionStateListener;
|
|||
import com.rusefi.io.DfuHelper;
|
||||
import com.rusefi.io.IoStream;
|
||||
import com.rusefi.io.LinkManager;
|
||||
import com.rusefi.io.commands.ErrorInfoCommand;
|
||||
import com.rusefi.io.serial.StreamConnector;
|
||||
import com.rusefi.proxy.NetworkConnector;
|
||||
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 int LOCAL_PORT = 29001;
|
||||
|
||||
/* UI elements */
|
||||
private TextView mStatusView;
|
||||
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.buttonDfu).setVisibility(View.GONE);
|
||||
|
||||
Button view = findViewById(R.id.localBroadcast);
|
||||
view.setText("Local broadcast on " + LOCAL_PORT);
|
||||
|
||||
broadcastStatus = findViewById(R.id.broadcastStatus);
|
||||
broadcastStatus.setVisibility(View.GONE);
|
||||
|
||||
|
@ -264,6 +271,9 @@ public class rusEFI extends Activity {
|
|||
connectDashboard();
|
||||
}
|
||||
|
||||
public void onLocalBroadcast(View view) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the user touches a button
|
||||
*/
|
||||
|
@ -344,6 +354,10 @@ public class rusEFI extends Activity {
|
|||
try {
|
||||
String signature = BinaryProtocol.getSignature(serial);
|
||||
visibleLogAppend("Connected to " + signature);
|
||||
ErrorInfoCommand.send(serial);
|
||||
String configError = ErrorInfoCommand.getResponse(serial.getDataBuffer());
|
||||
if (configError != null)
|
||||
visibleLogAppend("[CRITICAL] " + configError);
|
||||
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
|
|
|
@ -60,6 +60,13 @@
|
|||
android:onClick="onConnectButton"
|
||||
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
|
||||
android:id="@+id/buttonBroadcast"
|
||||
android:layout_width="match_parent"
|
||||
|
@ -83,5 +90,11 @@
|
|||
android:layout_height="wrap_content" />
|
||||
</ScrollView>
|
||||
|
||||
<Button
|
||||
android:id="@+id/button"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Button" />
|
||||
|
||||
</LinearLayout>
|
||||
</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
|
||||
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))
|
||||
return null;
|
||||
return new String(response, 1, response.length - 1);
|
||||
|
|
Loading…
Reference in New Issue