Skip to content

Commit

Permalink
Fix Linux GPIO logging (MarlinFirmware#20093)
Browse files Browse the repository at this point in the history
Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
  • Loading branch information
costas-basdekis and thinkyhead authored Nov 11, 2020
1 parent d4ba944 commit 3b68e44
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -183,3 +183,6 @@ cmake-build-*

#Python
__pycache__

#IOLogger logs
*_log.csv
23 changes: 11 additions & 12 deletions Marlin/src/HAL/LINUX/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,23 @@
*/
#ifdef __PLAT_LINUX__

extern void setup();
extern void loop();

#include <thread>

#include <iostream>
#include <fstream>
//#define GPIO_LOGGING // Full GPIO and Positional Logging

#include "../../inc/MarlinConfig.h"
#include <stdio.h>
#include <stdarg.h>
#include "../shared/Delay.h"
#include "hardware/IOLoggerCSV.h"
#include "hardware/Heater.h"
#include "hardware/LinearAxis.h"

#include <stdio.h>
#include <stdarg.h>
#include <thread>
#include <iostream>
#include <fstream>

extern void setup();
extern void loop();

// simple stdout / stdin implementation for fake serial port
void write_serial_thread() {
for (;;) {
Expand Down Expand Up @@ -64,8 +65,6 @@ void simulation_loop() {
LinearAxis z_axis(Z_ENABLE_PIN, Z_DIR_PIN, Z_STEP_PIN, Z_MIN_PIN, Z_MAX_PIN);
LinearAxis extruder0(E0_ENABLE_PIN, E0_DIR_PIN, E0_STEP_PIN, P_NC, P_NC);

//#define GPIO_LOGGING // Full GPIO and Positional Logging

#ifdef GPIO_LOGGING
IOLoggerCSV logger("all_gpio_log.csv");
Gpio::attachLogger(&logger);
Expand All @@ -88,7 +87,7 @@ void simulation_loop() {

#ifdef GPIO_LOGGING
if (x_axis.position != x || y_axis.position != y || z_axis.position != z) {
uint64_t update = MAX3(x_axis.last_update, y_axis.last_update, z_axis.last_update);
uint64_t update = _MAX(x_axis.last_update, y_axis.last_update, z_axis.last_update);
position_log << update << ", " << x_axis.position << ", " << y_axis.position << ", " << z_axis.position << std::endl;
position_log.flush();
x = x_axis.position;
Expand Down

0 comments on commit 3b68e44

Please sign in to comment.