Browse Source

fixed serial communication on PORT1, reduced "enqueing command" messages on serial in farm mode

PavelSindler 7 years ago
parent
commit
aa2dc723a1
3 changed files with 28 additions and 16 deletions
  1. 1 1
      Firmware/Configuration.h
  2. 15 7
      Firmware/MarlinSerial.h
  3. 12 8
      Firmware/Marlin_main.cpp

+ 1 - 1
Firmware/Configuration.h

@@ -5,7 +5,7 @@
 #include "Configuration_prusa.h"
 
 // Firmware version
-#define FW_version "3.0.12-3"
+#define FW_version "3.0.12-4"
 
 #define FW_PRUSA3D_MAGIC "PRUSA3DFW"
 #define FW_PRUSA3D_MAGIC_LEN 10

+ 15 - 7
Firmware/MarlinSerial.h

@@ -101,14 +101,22 @@ class MarlinSerial //: public Stream
     {
       return (unsigned int)(RX_BUFFER_SIZE + rx_buffer.head - rx_buffer.tail) % RX_BUFFER_SIZE;
     }
-    
-    FORCE_INLINE void write(uint8_t c)
-    {
-      while (!((M_UCSRxA) & (1 << M_UDREx)))
-        ;
 
-      M_UDRx = c;
-    }
+	void write(uint8_t c)
+	{
+		if (selectedSerialPort == 0) {
+			while (!((M_UCSRxA) & (1 << M_UDREx)))
+				;
+
+			M_UDRx = c;
+		}
+		else if (selectedSerialPort == 1) {
+			while (!((UCSR2A) & (1 << UDRE2)))
+				;
+
+			UDR2 = c;
+		}
+	}
     
     
     void checkRx(void)

+ 12 - 8
Firmware/Marlin_main.cpp

@@ -761,10 +761,12 @@ void enquecommand(const char *cmd, bool from_progmem)
             strcpy_P(cmdbuffer + bufindw + 1, cmd);
         else
             strcpy(cmdbuffer + bufindw + 1, cmd);
-        SERIAL_ECHO_START;
-        SERIAL_ECHORPGM(MSG_Enqueing);
-        SERIAL_ECHO(cmdbuffer + bufindw + 1);
-        SERIAL_ECHOLNPGM("\"");
+		if (!farm_mode) {
+			SERIAL_ECHO_START;
+			SERIAL_ECHORPGM(MSG_Enqueing);
+			SERIAL_ECHO(cmdbuffer + bufindw + 1);
+			SERIAL_ECHOLNPGM("\"");
+		}
         bufindw += len + 2;
         if (bufindw == sizeof(cmdbuffer))
             bufindw = 0;
@@ -797,10 +799,12 @@ void enquecommand_front(const char *cmd, bool from_progmem)
         else
             strcpy(cmdbuffer + bufindr + 1, cmd);
         ++ buflen;
-        SERIAL_ECHO_START;
-        SERIAL_ECHOPGM("Enqueing to the front: \"");
-        SERIAL_ECHO(cmdbuffer + bufindr + 1);
-        SERIAL_ECHOLNPGM("\"");
+		if (!farm_mode) {
+			SERIAL_ECHO_START;
+			SERIAL_ECHOPGM("Enqueing to the front: \"");
+			SERIAL_ECHO(cmdbuffer + bufindr + 1);
+			SERIAL_ECHOLNPGM("\"");
+		}
 #ifdef CMDBUFFER_DEBUG
         cmdqueue_dump_to_serial();
 #endif /* CMDBUFFER_DEBUG */