private void autoDetect(ChronopicAuto caNormal) { LogB.Information("starting port detection"); string [] usbSerial = ChronopicPorts.GetPorts(); bool first = true; foreach (string port in usbSerial) { if (configAutoDetect == Config.AutodetectPortEnum.DISCARDFIRST && first) { first = false; LogB.Warning("Discarded port = ", port); continue; } SerialPort sp = new SerialPort(port); LogB.Information("searching normal Chronopic at port: ", port); string readed = caNormal.Read(sp); if (caNormal.Found == ChronopicType.NORMAL) //We found a normal Chronopic { if (searched == ChronopicType.NORMAL) //normal Chronopic is what we are searching { Detected = port; return; } else { /* * else: * means that we are searching for an encoder chronopic and found a normal * so don't try to search for an encoder on that port, because 115200 bauds will saturate it */ LogB.Information("our goal is to search encoder but found normal Chronopic at port: ", port); } } else if (searched == ChronopicType.ENCODER) { /* * we are searching an encoder * if we arrived here, we know is not a normal chronopic * then wecan search safely for an encoder here */ ChronopicAuto caEncoder = new ChronopicAutoCheckEncoder(); caEncoder.IsEncoder = true; //for the bauds. LogB.Information("searching encoder Chronopic at port: ", port); readed = caEncoder.Read(sp); if (caEncoder.Found == ChronopicType.ENCODER) { Detected = port; return; } } } Detected = ""; }
public static void Exception(string message, Exception e) { Stack <Exception> exception_chain = new Stack <Exception> (); StringBuilder builder = new StringBuilder(); while (e != null) { exception_chain.Push(e); e = e.InnerException; } while (exception_chain.Count > 0) { e = exception_chain.Pop(); builder.AppendFormat("{0}: {1} (in `{2}')", e.GetType(), e.Message, e.Source).AppendLine(); builder.Append(e.StackTrace); if (exception_chain.Count > 0) { builder.AppendLine(); } } // FIXME: We should save these to an actual log file LogB.Warning(message ?? "Caught an exception", builder.ToString(), false); }
//height can be -1 to maintain aspect ratio public static bool ImageSurfaceResize(ImageSurface imgSurface, string filename_dest, int width, int height) { //maintain aspect ratio if (height == -1) { double ratioOriginal = imgSurface.Width / (1.0 * imgSurface.Height); height = Convert.ToInt32(width / ratioOriginal); } //return if problems on calculating aspect ratio if (width <= 0 || height <= 0) { return(false); } Surface surfaceResized = scale_surface( imgSurface, imgSurface.Width, imgSurface.Height, width, height); LogB.Information("ImageFileResize - " + filename_dest); try { surfaceResized.WriteToPng(filename_dest); } catch { LogB.Warning("Catched at ImageFileResize"); return(false); } return(true); }
private bool make(SerialPort sp) { this.sp = sp; if (sp == null) { return(false); } LogB.Information("opening port... "); try { if (sp != null) { if (sp.IsOpen) { sp.Close(); //close to ensure no bytes are comming } } sp.Open(); } catch { LogB.Warning("catched!"); return(false); } LogB.Information("opened"); if (IsEncoder) { setEncoderBauds(); } str = ""; return(true); }
//'template method' public string Write(SerialPort sp, int num) { if (!make(sp)) { return("Error sp == null"); } sendNum = num; //bool needToFlush = false; try { str = Communicate(); } catch { //this.error=ErrorType.Timeout; LogB.Warning("Error or Timeout. This is not Chronopic-Automatic-Firmware"); str = "Error / not Multitest firmware"; //needToFlush = true; } /* * if(needToFlush) * flush(); */ close(sp); return(str); }
/* * protected void readingOutput (object sendingProcess, DataReceivedEventArgs outputFromR) * { * if (! String.IsNullOrEmpty(outputFromR.Data)) * LogB.Information(outputFromR.Data); * } */ protected void readingError(object sendingProcess, DataReceivedEventArgs errorFromR) { if (String.IsNullOrEmpty(errorFromR.Data)) { return; } string str = errorFromR.Data; if (str.Length > 6 && str.StartsWith("***") && str.EndsWith("***")) { /* * 0123456 * ***1*** * str.Substring(3,1) 1 is the length */ str = str.Substring(3, str.Length - 6); if (Util.IsNumber(str, false)) { CurvesReaded = Convert.ToInt32(str); } return; } LogB.Warning(str); }
void on_button_import_clicked(object o, EventArgs args) { Gtk.FileChooserDialog fc = new Gtk.FileChooserDialog(Catalog.GetString("Select file to import"), encoder_configuration, FileChooserAction.Open, Catalog.GetString("Cancel"), ResponseType.Cancel, Catalog.GetString("Accept"), ResponseType.Accept ); fc.Filter = new FileFilter(); fc.Filter.AddPattern("*.txt"); if (fc.Run() == (int)ResponseType.Accept) { try { string contents = Util.ReadFile(fc.Filename, false); if (contents != null && contents != "") { EncoderConfigurationSQLObject econfSO = new EncoderConfigurationSQLObject(contents); if (econfSO.encoderGI != encoderGI) { if (encoderGI == Constants.EncoderGI.GRAVITATORY) { new DialogMessage(Constants.MessageTypes.WARNING, Catalog.GetString("Chronojump is currently in gravitory mode.") + "\n" + Catalog.GetString("Selected configuration is inertial.") + "\n\n" + Catalog.GetString("If you still want to import it, change to inertial mode.")); } else if (encoderGI == Constants.EncoderGI.INERTIAL) { new DialogMessage(Constants.MessageTypes.WARNING, Catalog.GetString("Chronojump is currently in inertial mode.") + "\n" + Catalog.GetString("Selected configuration is gravitatory.") + "\n\n" + Catalog.GetString("If you still want to import it, change to gravitatory mode.")); } } else if (econfSO.name != null && econfSO.name != "") { //add more suffixes until name is unique econfSO.name = SqliteEncoderConfiguration.IfNameExistsAddSuffix(econfSO.name, "_" + Catalog.GetString("copy")); SqliteEncoderConfiguration.MarkAllAsUnactive(false, encoderGI); econfSO.active = true; SqliteEncoderConfiguration.Insert(false, econfSO); store.AppendValues(new string[] { econfSO.name, econfSO.description }); UtilGtk.TreeviewSelectRowWithName(treeview_select, store, colName, econfSO.name, true); } } } catch { LogB.Warning("Catched! Configuration cannot be imported"); new DialogMessage(Constants.MessageTypes.WARNING, Catalog.GetString("Error importing data.")); } } //Don't forget to call Destroy() or the FileChooserDialog window won't get closed. fc.Destroy(); }
//*************************************** // METODOS PRIVADOS //*************************************** //-- Esperar a recibir una trama de cambio de estado private bool Read_cambio(byte[] respuesta) { //-- Crear la trama int n = 0; int count; bool status; //-- Esperar a que llegue la respuesta //-- Se espera hasta que en el buffer se tengan el numero de bytes //-- esperados para la trama. (En el caso de id son 4). Si hay un //-- timeout se aborta count = 0; do { //try, catch done because mono-1.2.3 throws an exception when there's a timeout //http://bugzilla.gnome.org/show_bug.cgi?id=420520 bool success = false; do { try { n = sp.Read(respuesta, count, 5 - count); LogB.Warning("respuesta = "); LogB.Warning(respuesta.ToString()); count += n; success = true; } catch {} } while (!success); } while (count < 5 && n != -1); //-- Comprobar la respuesta recibida switch (count) { case 5: //-- Datos listos if (respuesta[0] == (byte)Trama.Evento) //-- Trama de evento { this.error = ErrorType.Ok; status = true; } else //-- Recibida trama invalida { this.error = ErrorType.Invalid; status = false; //-- Esperar un tiempo y vaciar buffer Thread.Sleep(ErrorTimeout); this.flush(); } break; default: //-- Timeout (u otro error desconocido) status = false; this.error = ErrorType.Timeout; break; } return(status); }
// Executes file_name without creating a Window and without using the shell // with the parameters. Waits that it finishes it. Returns the stdout and stderr. private static Result runDo(string file_name, List <string> parameters) { Process process = new Process(); ProcessStartInfo processStartInfo = new ProcessStartInfo(); processStartInfo.FileName = file_name; string parameters_string = ""; foreach (string parameter in parameters) { parameters_string += CommandLineEncoder.EncodeArgText(parameter) + " "; } processStartInfo.Arguments = parameters_string; LogB.Debug("ExecuteProcess FileName: " + processStartInfo.FileName); LogB.Debug("ExecuteProcess Arguments: " + processStartInfo.Arguments); processStartInfo.CreateNoWindow = true; processStartInfo.UseShellExecute = false; processStartInfo.RedirectStandardInput = false; processStartInfo.RedirectStandardError = true; processStartInfo.RedirectStandardOutput = true; process.StartInfo = processStartInfo; try { process.Start(); } catch (Exception e) { string errorMessage = String.Format(Catalog.GetString("Cannot start:\n" + "{0}\n" + "with the parameters:" + "{1}\n" + "Exception:\n" + "{2}"), processStartInfo.FileName, parameters_string, e.Message); LogB.Warning(errorMessage); return(new Result("", "", Result.ERROR_CANT_START, errorMessage)); } string stdout = process.StandardOutput.ReadToEnd().TrimEnd('\n'); string stderr = process.StandardError.ReadToEnd().TrimEnd('\n'); process.WaitForExit(); if (stderr != "") { LogB.Warning(String.Format("Executed: {0} Parameters: {1} Stdout: {2} Stderr: {3}", processStartInfo.FileName, parameters_string, stdout, stderr)); } int exitCode = process.ExitCode; return(new Result(stdout, stderr, exitCode)); }
//*************************************** // METODOS PUBLICOS //*************************************** //-------------------------------------------------- //-- Leer un evento en Chronopic //-- Devuelve: //-- * timestamp : Marca de tiempo //-- * plataforma: Nuevo estado de la plataforma //-------------------------------------------------- public bool Read_event(out double timestamp, out Plataforma plataforma) { double t; //-- Trama de Evento byte[] trama = new byte[5]; bool ok; //-- Esperar a que llegue la trama o que se //-- produzca un timeout ok = Read_cambio(trama); LogB.Warning("after Read_cambio ="); LogB.Warning(ok.ToString()); //-- Si hay timeout o errores if (ok == false) { plataforma = Plataforma.UNKNOW; timestamp = 0.0; return(false); } //-- Comprobar que el estado transmitido en la trama es correcto //-- El estado de la plataforma solo puede tener los valores 0,1 if (trama[1] != 0 && trama[1] != 1) { //-- Trama erronea plataforma = Plataforma.UNKNOW; timestamp = 0.0; return(false); } //-- Actualizar el estado if (trama[1] == 0) { plataforma = Plataforma.OFF; } else { plataforma = Plataforma.ON; } //-- Obtener el tiempo t = (double)((trama[2] * 65536 + trama[3] * 256 + trama[4]) * 8) / 1000; timestamp = t; return(true); }
private void on_combo_all_none_selected_changed(object o, EventArgs args) { string myText = UtilGtk.ComboGetActive(combo_all_none_selected); if (myText != "" & myText != Catalog.GetString("Selected")) { try { markSelected(myText); } catch { LogB.Warning("Do later!!"); } } }
/* * run a process on the background, eg: read rfid. * don't call WaitForExit(), kill it on Chronojump exit * returns false if there are problems calling it */ public static bool RunAtBackground(Process process, string file_name, List <string> parameters) { if (!File.Exists(parameters[0])) { LogB.Debug("ExecuteProcess does not exist parameter: " + parameters[0]); return(false); } ProcessStartInfo processStartInfo = new ProcessStartInfo(); processStartInfo.FileName = file_name; string parameters_string = ""; foreach (string parameter in parameters) { parameters_string += CommandLineEncoder.EncodeArgText(parameter) + " "; } processStartInfo.Arguments = parameters_string; LogB.Debug("ExecuteProcess FileName: " + processStartInfo.FileName); LogB.Debug("ExecuteProcess Arguments: " + processStartInfo.Arguments); processStartInfo.CreateNoWindow = true; processStartInfo.UseShellExecute = false; processStartInfo.RedirectStandardInput = false; processStartInfo.RedirectStandardError = true; processStartInfo.RedirectStandardOutput = true; process.StartInfo = processStartInfo; try { process.Start(); } catch (Exception e) { string errorMessage = String.Format(Catalog.GetString("Cannot start:\n" + "{0}\n" + "with the parameters:" + "{1}\n" + "Exception:\n" + "{2}"), processStartInfo.FileName, parameters_string, e.Message); LogB.Warning(errorMessage); return(false); } return(true); }
private void connectContactsRealEnd() { if (SuccededConnectContactsRealThread) { LogB.Information("Success at Connecting real!"); } else { LogB.Warning("Failure at Connecting real!"); } hideAndNull(); FakeButtonContactsRealDone.Click(); }
public static void UpdateField(string field, string text) { //adapted from //http://stackoverflow.com/a/2401873 string tempfile = Path.GetTempFileName(); LogB.Information("UpdateField, field: " + field + ", text: " + text); if (!File.Exists(UtilAll.GetConfigFileName())) { try { using (var writer = new StreamWriter(tempfile)) { writer.WriteLine(field + "=" + text); } File.Copy(tempfile, UtilAll.GetConfigFileName(), true); } catch { LogB.Warning("Cannot write at Config.UpdateField"); } } else { try { using (var writer = new StreamWriter(tempfile)) using (var reader = new StreamReader(UtilAll.GetConfigFileName())) { while (!reader.EndOfStream) { string line = reader.ReadLine(); if (line != "" && line[0] != '#') { string [] parts = line.Split(new char[] { '=' }); if (parts.Length == 2 && parts[0] == field) { line = field + "=" + text; } } writer.WriteLine(line); } } File.Copy(tempfile, UtilAll.GetConfigFileName(), true); } catch { LogB.Warning("Cannot write at Config.UpdateField"); } } }
public void SendEndProcess() { if (ExecuteProcess.IsRunning(p)) { LogB.Debug("Closing R script"); try { p.StandardInput.WriteLine("Q"); } catch { LogB.Warning("Seems stdin write gots broken"); } } else { LogB.Debug("R script is not working. Don't need to close."); } }
public void Destroy() { //it seem on some machines (MacOSX) splash_window maybe is Destroyed previously because on_delete_event it's called //Destroy here if it has not been destroyed if (SplashWindowBox.splash_window == null) { LogB.Information("splash_window is null. Do nothing."); } else { LogB.Warning("splash_window is not null. Destroying now..."); SplashWindowBox.splash_window.Destroy(); LogB.Information("Destroyed!"); } }
private void on_connection_contacts_real_done(object o, EventArgs args) { cp2016.FakeButtonContactsRealDone.Clicked -= new EventHandler(on_connection_contacts_real_done); if (cp2016.SuccededConnectContactsRealThread) { LogB.Information("Success at Connecting real! (main GUI)"); connectingSequence = connectingSequenceEnum.FIRMWAREIFNEEDED; chronopicConnectionSequenceDo(); } else { LogB.Warning("Failure at Connecting real! (main GUI)"); } }
//imageHalfUrl is "jugadors/*.jpg" public bool DownloadImage(string imageHalfUrl, int personID) { try { using (WebClient client = new WebClient()) { LogB.Information("DownloadImage!!"); LogB.Information(getImagesUrl() + imageHalfUrl); LogB.Information(Path.Combine(Path.GetTempPath(), personID.ToString())); client.DownloadFile(new Uri(getImagesUrl() + imageHalfUrl), Path.Combine(Path.GetTempPath(), personID.ToString())); } } catch { LogB.Warning("DownloadImage catched"); return(false); } return(true); }
void on_button_tmp_folder_open_clicked(object o, EventArgs args) { string dir = UtilAll.GetTempDir(); //potser cal una arrobar abans (a windows) System.IO.FileInfo fInfo = new System.IO.FileInfo(dir); try { if (fInfo.Exists) { System.Diagnostics.Process.Start(dir); } } catch { new DialogMessage(Constants.MessageTypes.WARNING, Constants.DirectoryCannotOpen + "\n\n" + dir); } LogB.Warning(dir); }
/* * run a process on the background, eg: read rfid. * don't call WaitForExit(), kill it on Chronojump exit * returns false if there are problems calling it */ public static bool RunAtBackground(ref Process process, string file_name, List <string> parameters, bool createNoWindow, bool useShellExecute, bool redirectInput, bool redirectOutput, bool redirectStderr) { ProcessStartInfo processStartInfo = new ProcessStartInfo(); processStartInfo.FileName = file_name; string parameters_string = ""; foreach (string parameter in parameters) { parameters_string += CommandLineEncoder.EncodeArgText(parameter) + " "; } processStartInfo.Arguments = parameters_string; LogB.Debug("ExecuteProcess FileName: " + processStartInfo.FileName); LogB.Debug("ExecuteProcess Arguments: " + processStartInfo.Arguments); processStartInfo.CreateNoWindow = createNoWindow; processStartInfo.UseShellExecute = useShellExecute; processStartInfo.RedirectStandardInput = redirectInput; //note UseShellExecute has to be false to be able to redirect processStartInfo.RedirectStandardError = redirectOutput; processStartInfo.RedirectStandardOutput = redirectStderr; process.StartInfo = processStartInfo; try { process.Start(); } catch (Exception e) { string errorMessage = String.Format(Catalog.GetString("Cannot start:\n" + "{0}\n" + "with the parameters:" + "{1}\n" + "Exception:\n" + "{2}"), processStartInfo.FileName, parameters_string, e.Message); LogB.Warning(errorMessage); return(false); } return(true); }
private void capture() { LogB.Information("Serial port opened. Send capture message"); System.Threading.Thread.Sleep(3000); //sleep to let arduino start reading serial event sp.WriteLine("start_capture:"); LogB.Information("'start_capture:' sent"); string str = ""; do { System.Threading.Thread.Sleep(100); //sleep to let arduino start reading try { str = sp.ReadLine(); } catch { LogB.Warning("Catched at capture"); return; } LogB.Information("init string: " + str); }while(!str.Contains("Starting capture")); writer.WriteLine("Time;S1;S2;S3;S4"); for (int i = 0; i < 400; i++) { if (readRowMark()) { readForceValues(); } else { LogB.Information("problem reading row mark"); } /* * int b = sp.ReadByte(); * LogB.Information(b.ToString()); * writer.WriteLine(b.ToString()); */ } LogB.Information("capture ended"); sp.WriteLine("end_capture:"); LogB.Information("'end_capture:' sent"); }
private void findVersion() { LogB.Debug("--1--"); //pingStart = true; pulseGTKPingShouldEnd = false; splashShowButton = true; LogB.Debug("--2--"); //maybe other thread doesn't create at time the splash win //then just wait while (!createdSplashWin) { ; } LogB.Debug("--2.1--"); try { if (splashWin.FakeButtonCreated) { LogB.Information("Created splashWin.FakeButton"); } else { LogB.Warning("NOT Created splashWin.FakeButton, si es bloqueja, posar aquĆ un while (mentre no estigui creat)"); } splashWin.FakeButtonCancel.Clicked += new EventHandler(on_find_version_cancelled); LogB.Debug("--3--"); } catch { LogB.Warning("Problem with splash win"); } versionAvailable = Server.Ping(true, progName, UtilAll.ReadVersion()); //doInsertion LogB.Debug("--4--"); splashShowButton = false; LogB.Information(" version: ", versionAvailable); LogB.Debug("\n--5--"); //pingEnd = true; LogB.Debug("--6--"); }
/* * this will read what's in the serial port until time out */ private void flushByTimeOut() { byte[] buffer = new byte[256]; //try, catch done because mono-1.2.3 throws an exception when there's a timeout //http://bugzilla.gnome.org/show_bug.cgi?id=420520 bool timeOut = false; do { try{ sp.Read(buffer, 0, 256); LogB.Debug(" spReaded "); } catch { LogB.Warning(" catchedTimeOut "); timeOut = true; } } while(!timeOut); }
private static void createBlankDBServer() { LogB.SQL("Creating blank database for server"); if (Sqlite.CheckFileServer()) { LogB.Error("File already exists. Cannot create."); } else { Sqlite.ConnectServer(); Sqlite.CreateFile(); Sqlite.CreateTables(true); //server LogB.SQL("Created blank database! Exiting"); string myVersion = UtilAll.ReadVersion(); LogB.Warning("CAUTION: client info about versionAvailable (on server): ", myVersion); SqlitePreferences.Update("availableVersion", myVersion, false); LogB.Information("Maybe you don't want to show this version on pings, change it to last stable published version"); } }
/* --------------------- * other support methods * ---------------------*/ private void chronojumpCrashedBefore() { Log.CopyOldToCrashed(); /* * string windowsTextLog = ""; * * string crashLogFile = Log.GetLast().Replace(".txt", "-crash.txt"); * //on vista there's no crash file because redirection is forbidden * if(UtilAll.IsWindows() && File.Exists(crashLogFile)) * windowsTextLog = "\n" + crashLogFile; */ //if there's a copy on temp... if (File.Exists(Util.GetDatabaseTempDir() + Path.DirectorySeparatorChar + "chronojump.db")) { // if exist also a file in default db location (improbable but done for solve eventual problems if (File.Exists(Util.GetDatabaseDir() + Path.DirectorySeparatorChar + "chronojump.db")) { Util.BackupDatabase(); //copy it to backup File.Delete(Util.GetDatabaseDir() + Path.DirectorySeparatorChar + "chronojump.db"); //delete it } //move temp dir to default db location dir File.Move(Util.GetDatabaseTempDir() + Path.DirectorySeparatorChar + "chronojump.db", Util.GetDatabaseDir() + Path.DirectorySeparatorChar + "chronojump.db"); } messageCrashedBefore = "\n" + string.Format(Catalog.GetString("Chronojump {0} crashed before."), progVersion) + "\n\n" + Catalog.GetString("Please, fill your email and click on 'Send error log' in order to fix this fast and contact you if appropriate.") + "\n\n" + Catalog.GetString("Your help is needed.") + "\n"; //messageCrashedBefore += "\n" + Catalog.GetString("Experimental webcam record has been disabled.") + "\n"; /* * This are the only outputs to Console. Other's use Log that prints to console and to log file * this doesn't go to log because it talks about log */ LogB.Warning(messageCrashedBefore); return; }
private void assignPhotoToPixbuf(Gtk.Image image, bool fromFile, string photoFile) { Pixbuf pixbuf; try { if (fromFile) { pixbuf = new Pixbuf(photoFile); //from a file } else { pixbuf = new Pixbuf(null, photoFile); //from assemblies } image.Pixbuf = pixbuf; } catch { LogB.Warning("catched while assigning image: " + photoFile); } }
private bool make(SerialPort sp) { this.sp = sp; if (sp == null) { return(false); } if (sp.IsOpen) { LogB.Information("Port is opened. flushing ... "); byte[] buffer = new byte[256]; for (int count = 0; count < 1; count++) //flush by reading buffer or timeout 1 time { try{ sp.Read(buffer, 0, 256); LogB.Debug(" spReaded "); } catch { LogB.Warning(" catchedTimeOut "); } count++; } LogB.Information("flushed"); } else { LogB.Information("Port is closed. Opening ... "); sp.Open(); } LogB.Information("ready!"); if (IsEncoder) { setEncoderBauds(); } str = ""; return(true); }
public static Gdk.Pixbuf OpenPixbufSafe(string filename, Gdk.Pixbuf pixbuf) { imageFileWaitUntilCreated(filename); bool readedOk; do { readedOk = true; try { pixbuf = new Pixbuf(filename); //from a file } catch { LogB.Warning("File is still not ready. Wait a bit"); System.Threading.Thread.Sleep(50); readedOk = false; } } while(!readedOk); return(pixbuf); }
protected Chronopic.Plataforma chronopicInitialValue(Chronopic cp) { Chronopic.Plataforma myPlatformState = Chronopic.Plataforma.UNKNOW; //on (in platform), off (jumping), or unknow bool ok = false; int timeWait = 50; //wait 50ms between calls to Read_platform int timeLimit = 1000; int count = 0; do { try { ok = cp.Read_platform(out myPlatformState); } catch { LogB.Warning("Manage called after finishing constructor, do later"); } Thread.Sleep(timeWait); //wait 50ms count += timeWait; } while (!ok && count < timeLimit); return(myPlatformState); }
/* * The process.Responding only works on GUI processes * So, here we send a "ping" expecting to see the result in short time * * TODO: maybe is good to kill the unresponsive processes */ public static bool IsResponsive(Process p) { Random rnd = new Random(); int randomInt = rnd.Next(); //eg. 1234 string randomPingStr = "PING" + Path.Combine(Path.GetTempPath(), "chronojump" + randomInt.ToString() + ".txt"); //eg Linux: 'PING/tmp/chronojump1234.txt' //eg Windows: 'PINGC:\Temp...\chronojump1234.txt' if (UtilAll.IsWindows()) { //On win32 R understands backlash as an escape character and //a file path uses Unix-like path separator '/' randomPingStr = randomPingStr.Replace("\\", "/"); } //eg Windows: 'PINGC:/Temp.../chronojump1234.txt' LogB.Information("Sending ping: " + randomPingStr); try { p.StandardInput.WriteLine(randomPingStr); } catch { LogB.Warning("Catched waiting response"); return(false); } //wait 250ms the response System.Threading.Thread.Sleep(250); //On Linux will be '/' on Windows '\' if (File.Exists(Path.Combine(Path.GetTempPath(), "chronojump" + randomInt.ToString() + ".txt"))) { LogB.Information("Process is responding"); return(true); } LogB.Warning("Process is NOT responding"); return(false); }