Linux is asking for SocketCAN ISO-TP console connector #4123
progress towards UI
This commit is contained in:
parent
8e75728e50
commit
745e0b7c48
|
@ -10,6 +10,7 @@ import com.rusefi.core.EngineState;
|
||||||
import com.rusefi.io.serial.BufferedSerialIoStream;
|
import com.rusefi.io.serial.BufferedSerialIoStream;
|
||||||
import com.rusefi.io.serial.StreamConnector;
|
import com.rusefi.io.serial.StreamConnector;
|
||||||
import com.rusefi.io.stream.PCanIoStream;
|
import com.rusefi.io.stream.PCanIoStream;
|
||||||
|
import com.rusefi.io.stream.SocketCANIoStream;
|
||||||
import com.rusefi.io.tcp.TcpConnector;
|
import com.rusefi.io.tcp.TcpConnector;
|
||||||
import com.rusefi.io.tcp.TcpIoStream;
|
import com.rusefi.io.tcp.TcpIoStream;
|
||||||
import com.rusefi.util.IoUtils;
|
import com.rusefi.util.IoUtils;
|
||||||
|
@ -33,6 +34,7 @@ import static com.devexperts.logging.Logging.getLogging;
|
||||||
public class LinkManager implements Closeable {
|
public class LinkManager implements Closeable {
|
||||||
private static final Logging log = getLogging(LinkManager.class);
|
private static final Logging log = getLogging(LinkManager.class);
|
||||||
public static final String PCAN = "PCAN";
|
public static final String PCAN = "PCAN";
|
||||||
|
public static final String SOCKET_CAN = "SocketCAN";
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public static LogLevel LOG_LEVEL = LogLevel.INFO;
|
public static LogLevel LOG_LEVEL = LogLevel.INFO;
|
||||||
|
@ -231,7 +233,10 @@ public class LinkManager implements Closeable {
|
||||||
if (isLogViewerMode(port)) {
|
if (isLogViewerMode(port)) {
|
||||||
setConnector(LinkConnector.VOID);
|
setConnector(LinkConnector.VOID);
|
||||||
} else if (PCAN.equals(port)) {
|
} else if (PCAN.equals(port)) {
|
||||||
Callable<IoStream> streamFactory = PCanIoStream::getPCANIoStream;
|
Callable<IoStream> streamFactory = PCanIoStream::createStream;
|
||||||
|
setConnector(new StreamConnector(this, streamFactory));
|
||||||
|
} else if (SOCKET_CAN.equals(port)) {
|
||||||
|
Callable<IoStream> streamFactory = SocketCANIoStream::createStream;
|
||||||
setConnector(new StreamConnector(this, streamFactory));
|
setConnector(new StreamConnector(this, streamFactory));
|
||||||
} else if (TcpConnector.isTcpPort(port)) {
|
} else if (TcpConnector.isTcpPort(port)) {
|
||||||
Callable<IoStream> streamFactory = new Callable<IoStream>() {
|
Callable<IoStream> streamFactory = new Callable<IoStream>() {
|
||||||
|
|
|
@ -47,7 +47,7 @@ public class PCanIoStream extends AbstractIoStream {
|
||||||
};
|
};
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public static PCanIoStream getPCANIoStream() {
|
public static PCanIoStream createStream() {
|
||||||
PCANBasic can = new PCANBasic();
|
PCANBasic can = new PCANBasic();
|
||||||
can.initializeAPI();
|
can.initializeAPI();
|
||||||
TPCANStatus status = can.Initialize(CHANNEL, TPCANBaudrate.PCAN_BAUD_500K, TPCANType.PCAN_TYPE_NONE, 0, (short) 0);
|
TPCANStatus status = can.Initialize(CHANNEL, TPCANBaudrate.PCAN_BAUD_500K, TPCANType.PCAN_TYPE_NONE, 0, (short) 0);
|
||||||
|
|
|
@ -66,7 +66,7 @@ public class SocketCANIoStream extends AbstractIoStream {
|
||||||
|
|
||||||
public SocketCANIoStream() {
|
public SocketCANIoStream() {
|
||||||
try {
|
try {
|
||||||
NetworkDevice canInterface = NetworkDevice.lookup("can0");
|
NetworkDevice canInterface = NetworkDevice.lookup(System.getProperty("CAN_DEVICE_NAME", "can0"));
|
||||||
socket = CanChannels.newRawChannel();
|
socket = CanChannels.newRawChannel();
|
||||||
socket.bind(canInterface);
|
socket.bind(canInterface);
|
||||||
|
|
||||||
|
@ -122,4 +122,8 @@ public class SocketCANIoStream extends AbstractIoStream {
|
||||||
public IncomingDataBuffer getDataBuffer() {
|
public IncomingDataBuffer getDataBuffer() {
|
||||||
return dataBuffer;
|
return dataBuffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static IoStream createStream() {
|
||||||
|
return new SocketCANIoStream();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@ public class PCanSandbox {
|
||||||
private static final Logging log = getLogging(PCanSandbox.class);
|
private static final Logging log = getLogging(PCanSandbox.class);
|
||||||
|
|
||||||
public static void main(String[] args) throws IOException, InterruptedException {
|
public static void main(String[] args) throws IOException, InterruptedException {
|
||||||
AbstractIoStream tsStream = PCanIoStream.getPCANIoStream();
|
AbstractIoStream tsStream = PCanIoStream.createStream();
|
||||||
if (tsStream == null)
|
if (tsStream == null)
|
||||||
throw new IOException("No PCAN");
|
throw new IOException("No PCAN");
|
||||||
|
|
||||||
|
|
|
@ -59,6 +59,10 @@ public enum FileLog {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isLinux() {
|
||||||
|
return getOsName().equalsIgnoreCase("Linux");
|
||||||
|
}
|
||||||
|
|
||||||
public static String getOsName() {
|
public static String getOsName() {
|
||||||
return System.getProperty("os.name");
|
return System.getProperty("os.name");
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,8 @@ import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.CopyOnWriteArrayList;
|
import java.util.concurrent.CopyOnWriteArrayList;
|
||||||
|
|
||||||
|
import static com.rusefi.FileLog.isLinux;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Andrey Belomutskiy
|
* @author Andrey Belomutskiy
|
||||||
*/
|
*/
|
||||||
|
@ -18,6 +20,7 @@ public enum SerialPortScanner {
|
||||||
private volatile boolean isRunning = true;
|
private volatile boolean isRunning = true;
|
||||||
|
|
||||||
private static final boolean SHOW_PCAN = Boolean.parseBoolean(System.getenv().get("RUSEFI_PCAN"));
|
private static final boolean SHOW_PCAN = Boolean.parseBoolean(System.getenv().get("RUSEFI_PCAN"));
|
||||||
|
private static final boolean SHOW_SOCKETCAN = isLinux();
|
||||||
|
|
||||||
static final String AUTO_SERIAL = "Auto Serial";
|
static final String AUTO_SERIAL = "Auto Serial";
|
||||||
@NotNull
|
@NotNull
|
||||||
|
@ -38,6 +41,8 @@ public enum SerialPortScanner {
|
||||||
ports.addAll(TcpConnector.getAvailablePorts());
|
ports.addAll(TcpConnector.getAvailablePorts());
|
||||||
if (SHOW_PCAN)
|
if (SHOW_PCAN)
|
||||||
ports.add(LinkManager.PCAN);
|
ports.add(LinkManager.PCAN);
|
||||||
|
if (SHOW_SOCKETCAN)
|
||||||
|
ports.add(LinkManager.SOCKET_CAN);
|
||||||
|
|
||||||
boolean isListUpdated;
|
boolean isListUpdated;
|
||||||
synchronized (knownPorts) {
|
synchronized (knownPorts) {
|
||||||
|
|
|
@ -63,7 +63,7 @@ public class ConsoleTools {
|
||||||
registerTool("network_connector", strings -> NetworkConnectorStartup.start(), "Connect your rusEFI ECU to rusEFI Online");
|
registerTool("network_connector", strings -> NetworkConnectorStartup.start(), "Connect your rusEFI ECU to rusEFI Online");
|
||||||
registerTool("network_authenticator", strings -> LocalApplicationProxy.start(), "rusEFI Online Authenticator");
|
registerTool("network_authenticator", strings -> LocalApplicationProxy.start(), "rusEFI Online Authenticator");
|
||||||
registerTool("elm327_connector", strings -> Elm327ConnectorStartup.start(), "Connect your rusEFI ECU using ELM327 CAN-bus adapter");
|
registerTool("elm327_connector", strings -> Elm327ConnectorStartup.start(), "Connect your rusEFI ECU using ELM327 CAN-bus adapter");
|
||||||
registerTool("pcan_connector", strings -> CANConnectorStartup.start(PCanIoStream.getPCANIoStream()), "Connect your rusEFI ECU using PCAN CAN-bus adapter");
|
registerTool("pcan_connector", strings -> CANConnectorStartup.start(PCanIoStream.createStream()), "Connect your rusEFI ECU using PCAN CAN-bus adapter");
|
||||||
if (!FileLog.isWindows()) {
|
if (!FileLog.isWindows()) {
|
||||||
registerTool("socketcan_connector", strings -> CANConnectorStartup.start(SocketCANIoStream.create()), "Connect your rusEFI ECU using SocketCAN CAN-bus adapter");
|
registerTool("socketcan_connector", strings -> CANConnectorStartup.start(SocketCANIoStream.create()), "Connect your rusEFI ECU using SocketCAN CAN-bus adapter");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue