/** * URL is in form of: * tcp://192.168.1.2:200 */ public void Open(String url) { var u = TCPStream.ParseUrl(url); string host = u[URL_ADDR]; int port = int.Parse(u[URL_PORT]); Logger.trace("TCPStream", "TCP Stream: " + host + ":" + port); try { sock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); sock.Connect(new IPEndPoint(IPAddress.Parse(host), port)); } catch (Exception) {} if (sock != null && sock.Connected) { //sock.ReceiveTimeout = 50; //sock.ReceiveBufferSize = 128; } else { sock = null; throw new Exception("Can't connect socket " + url); } }
public static void EngineConnect() { var veh = config.GetVehicle(config.Vehicle); if (veh == null) { veh = new ConfigVehicleData(); } if (HOBD.engine == null) { HOBD.engine = Engine.CreateInstance(veh.ECUEngine); } IStream stream = null; if (config.Port.StartsWith("btspp")) { stream = new BluetoothStream(); } else if (config.Port.StartsWith("tcp")) { stream = new TCPStream(); } else { stream = new SerialStream(); } engine.Deactivate(); engine.Registry = Registry; engine.Init(stream, config.Port, ""); }
public static void EngineConnect() { var veh = config.GetVehicle(config.Vehicle); if (veh == null) veh = new ConfigVehicleData(); if (HOBD.engine == null) HOBD.engine = Engine.CreateInstance(veh.ECUEngine); IStream stream = null; if (config.Port.StartsWith("btspp")) stream = new BluetoothStream(); else if (config.Port.StartsWith("tcp")) stream = new TCPStream(); else stream = new SerialStream(); engine.Deactivate(); engine.Registry = Registry; engine.Init(stream, config.Port, ""); }