From 7441f6b6bad575ca108f6de56b7d45576671bbb4 Mon Sep 17 00:00:00 2001 From: Markus Hitter Date: Sun, 31 Dec 2017 20:35:09 +0100 Subject: [PATCH] Simulator: be more clear about files opened. Before, a seemingly valid command like ... ./sim -o sim-log.log -t 0 testcases/triangle-odd.gcode ... would not act as expected (treat both files as G-code source) and not give meaningful hints on what's going on either. It just reported 'Could not stat file'. No hint that it tries to open the intended log file as G-code source. Now the message reporting opening of a G-code file names it as 'G-code source' and opening of the recorder file gets reported, too. Which should give a good idea about what's going on. --- simulator/data_recorder.c | 3 ++- simulator/serial_sim.c | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/simulator/data_recorder.c b/simulator/data_recorder.c index 7880675..f4ee399 100644 --- a/simulator/data_recorder.c +++ b/simulator/data_recorder.c @@ -30,8 +30,9 @@ static void recorder_close(void) { void recorder_init(const char* filename) { sim_assert( ! file, "Recorder already initialized"); + sim_info("Opening recorder file %s.", filename); file = fopen(filename, "w"); - sim_assert(file, "record_init: failed to create file"); + sim_assert(file, "record_init: failed to create recorder file."); time_t t = time(NULL); fprintf(file, "# Teacup_Firmware simulator v1.0\n"); diff --git a/simulator/serial_sim.c b/simulator/serial_sim.c index e63acb2..0a96c07 100644 --- a/simulator/serial_sim.c +++ b/simulator/serial_sim.c @@ -41,13 +41,13 @@ static void open_file() { // No more files if (i > g_argc) return; - sim_info("opening %s", filename); - sim_assert(!stat(filename, &st), "Could not stat file."); + sim_info("Opening G-code source %s.", filename); + sim_assert(!stat(filename, &st), "Could not stat G-code source."); if (!st.st_rdev) { // Normal file gcode_fd = open(filename, O_RDONLY ); - sim_assert(gcode_fd, "Could not open file."); + sim_assert(gcode_fd, "Could not open G-code file."); } else { // Some kind of device (treat as TTY) open_tty(filename);