Skip to content

Commit

Permalink
fixing missing PSTR and possible other communication bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Nibbels committed Mar 13, 2018
1 parent 639bebc commit a7f0eb4
Show file tree
Hide file tree
Showing 14 changed files with 101 additions and 259 deletions.
2 changes: 1 addition & 1 deletion Repetier/Commands.cpp
Expand Up @@ -858,7 +858,7 @@ void Commands::executeGCode(GCode *com)
Printer::destinationSteps[E_AXIS] = Printer::currentPositionSteps[E_AXIS] = Printer::convertToMM(com->E) * Printer::axisStepsPerMM[E_AXIS];
wissen:
Printer::queuePositionTargetSteps[axis] <---> Printer::destinationSteps[axis]
Printer::currentPositionSteps[axis] <---> Printer::queuePositionCurrentSteps[axis]
Printer::queuePositionCurrentSteps[axis] <---> Printer::currentPositionSteps[axis]
*/
}
break;
Expand Down
3 changes: 0 additions & 3 deletions Repetier/Configuration.h
Expand Up @@ -587,9 +587,6 @@ Select the language to use.
1 = German */
#define UI_LANGUAGE 0

/** \brief Animate switches between menus etc. */
#define UI_ANIMATION false

/** \brief How many ms should a single page be shown, until it is switched to the next one.*/
#define UI_PAGES_DURATION 4000

Expand Down
6 changes: 3 additions & 3 deletions Repetier/Extruder.cpp
Expand Up @@ -35,10 +35,10 @@ uint8_t Extruder::dittoMode = 0;

#if ANALOG_INPUTS>0
const uint8 osAnalogInputChannels[] PROGMEM = ANALOG_INPUT_CHANNELS;
volatile uint8 osAnalogInputCounter[ANALOG_INPUTS];
volatile uint osAnalogInputBuildup[ANALOG_INPUTS];
volatile uint8 osAnalogInputCounter[ANALOG_INPUTS] = {0};
volatile uint osAnalogInputBuildup[ANALOG_INPUTS] = {0};
volatile uint8 osAnalogInputPos=0; // Current sampling position
volatile uint osAnalogInputValues[ANALOG_INPUTS];
volatile uint osAnalogInputValues[ANALOG_INPUTS] = {0};
#endif // ANALOG_INPUTS>0

#ifdef USE_GENERIC_THERMISTORTABLE_1
Expand Down
115 changes: 57 additions & 58 deletions Repetier/HAL.cpp
Expand Up @@ -1288,79 +1288,78 @@ inline void rf_store_char(unsigned char c, ring_buffer_rx *buffer)


#if !defined(USART0_RX_vect) && defined(USART1_RX_vect)
// do nothing - on the 32u4 the first USART is USART1
// do nothing - on the 32u4 the first USART is USART1
#else
void rfSerialEvent() __attribute__((weak));
void rfSerialEvent() {}
#define serialEvent_implemented
#if defined(USART_RX_vect)
SIGNAL(USART_RX_vect)
#elif defined(USART0_RX_vect)
SIGNAL(USART0_RX_vect)
#else
#if defined(SIG_USART0_RECV)
SIGNAL(SIG_USART0_RECV)
#elif defined(SIG_UART0_RECV)
SIGNAL(SIG_UART0_RECV)
#elif defined(SIG_UART_RECV)
SIGNAL(SIG_UART_RECV)
#else
#error "Don't know what the Data Received vector is called for the first UART"
#endif // defined(SIG_USART0_RECV)
#endif // defined(USART_RX_vect)
{
#if defined(UDR0)
void rfSerialEvent() __attribute__((weak));
void rfSerialEvent() {}
#define serialEvent_implemented
#if defined(USART_RX_vect)
SIGNAL(USART_RX_vect)
#elif defined(USART0_RX_vect)
SIGNAL(USART0_RX_vect)
#else
#if defined(SIG_USART0_RECV)
SIGNAL(SIG_USART0_RECV)
#elif defined(SIG_UART0_RECV)
SIGNAL(SIG_UART0_RECV)
#elif defined(SIG_UART_RECV)
SIGNAL(SIG_UART_RECV)
#else
#error "Don't know what the Data Received vector is called for the first UART"
#endif // defined(SIG_USART0_RECV)
#endif // defined(USART_RX_vect)
{
#if defined(UDR0)
unsigned char c = UDR0;
#elif defined(UDR)
#elif defined(UDR)
unsigned char c = UDR;
#else
#error UDR not defined
#endif // defined(UDR0)
#else
#error UDR not defined
#endif // defined(UDR0)
rf_store_char(c, &rx_buffer);
}
}
#endif // !defined(USART0_RX_vect) && defined(USART1_RX_vect)

#if !defined(USART0_UDRE_vect) && defined(USART1_UDRE_vect)
// do nothing - on the 32u4 the first USART is USART1
#else
#if !defined(UART0_UDRE_vect) && !defined(UART_UDRE_vect) && !defined(USART0_UDRE_vect) && !defined(USART_UDRE_vect)
#error "Don't know what the Data Register Empty vector is called for the first UART"
// do nothing - on the 32u4 the first USART is USART1
#else
#if defined(UART0_UDRE_vect)
ISR(UART0_UDRE_vect)
#elif defined(UART_UDRE_vect)
ISR(UART_UDRE_vect)
#elif defined(USART0_UDRE_vect)
ISR(USART0_UDRE_vect)
#elif defined(USART_UDRE_vect)
ISR(USART_UDRE_vect)
#endif // defined(UART0_UDRE_vect)
{
#if !defined(UART0_UDRE_vect) && !defined(UART_UDRE_vect) && !defined(USART0_UDRE_vect) && !defined(USART_UDRE_vect)
#error "Don't know what the Data Register Empty vector is called for the first UART"
#else
#if defined(UART0_UDRE_vect)
ISR(UART0_UDRE_vect)
#elif defined(UART_UDRE_vect)
ISR(UART_UDRE_vect)
#elif defined(USART0_UDRE_vect)
ISR(USART0_UDRE_vect)
#elif defined(USART_UDRE_vect)
ISR(USART_UDRE_vect)
#endif // defined(UART0_UDRE_vect)
{
if (tx_buffer.head == tx_buffer.tail)
{
// Buffer empty, so disable interrupts
#if defined(UCSR0B)
#if defined(UCSR0B)
bit_clear(UCSR0B, UDRIE0);
#else
#else
bit_clear(UCSRB, UDRIE);
#endif // defined(UCSR0B)
#endif // defined(UCSR0B)
}
else
{
// There is more data in the output buffer. Send the next byte
uint8_t c = tx_buffer.buffer[tx_buffer.tail];
tx_buffer.tail = (tx_buffer.tail + 1) & SERIAL_TX_BUFFER_MASK;

#if defined(UDR0)
#if defined(UDR0)
UDR0 = c;
#elif defined(UDR)
#elif defined(UDR)
UDR = c;
#else
#error UDR not defined
#endif // defined(UDR0)
#else
#error UDR not defined
#endif // defined(UDR0)
}
}
#endif // !defined(UART0_UDRE_vect) && !defined(UART_UDRE_vect) && !defined(USART0_UDRE_vect) && !defined(USART_UDRE_vect)
}
#endif // !defined(UART0_UDRE_vect) && !defined(UART_UDRE_vect) && !defined(USART0_UDRE_vect) && !defined(USART_UDRE_vect)
#endif // !defined(USART0_UDRE_vect) && defined(USART1_UDRE_vect)


Expand Down Expand Up @@ -1462,7 +1461,7 @@ int RFHardwareSerial::available(void)

int RFHardwareSerial::outputUnused(void)
{
return SERIAL_TX_BUFFER_SIZE-(unsigned int)((SERIAL_TX_BUFFER_SIZE + _tx_buffer->head - _tx_buffer->tail) & SERIAL_TX_BUFFER_MASK);
return SERIAL_TX_BUFFER_SIZE - (unsigned int)((SERIAL_TX_BUFFER_SIZE + _tx_buffer->head - _tx_buffer->tail) & SERIAL_TX_BUFFER_MASK);

} // outputUnused

Expand Down Expand Up @@ -1520,19 +1519,19 @@ size_t RFHardwareSerial::write(uint8_t c)


#if defined(UBRRH) && defined(UBRRL)
RFHardwareSerial RFSerial(&rx_buffer, &tx_buffer, &UBRRH, &UBRRL, &UCSRA, &UCSRB, &UDR, RXEN, TXEN, RXCIE, UDRIE, U2X);
RFHardwareSerial RFSerial(&rx_buffer, &tx_buffer, &UBRRH, &UBRRL, &UCSRA, &UCSRB, &UDR, RXEN, TXEN, RXCIE, UDRIE, U2X);
#elif defined(UBRR0H) && defined(UBRR0L)
RFHardwareSerial RFSerial(&rx_buffer, &tx_buffer, &UBRR0H, &UBRR0L, &UCSR0A, &UCSR0B, &UDR0, RXEN0, TXEN0, RXCIE0, UDRIE0, U2X0);
RFHardwareSerial RFSerial(&rx_buffer, &tx_buffer, &UBRR0H, &UBRR0L, &UCSR0A, &UCSR0B, &UDR0, RXEN0, TXEN0, RXCIE0, UDRIE0, U2X0);
#elif defined(USBCON)
// do nothing - Serial object and buffers are initialized in CDC code
// do nothing - Serial object and buffers are initialized in CDC code
#else
#error no serial port defined (port 0)
#error no serial port defined (port 0)
#endif // defined(UBRRH) && defined(UBRRL)

#if FEATURE_CASE_LIGHT
#if !defined CASE_LIGHT_PIN || CASE_LIGHT_PIN < 0
#if !defined CASE_LIGHT_PIN || CASE_LIGHT_PIN < 0
#error The case light pin must be defined in case the case light feature shall be used.
#endif //!defined CASE_LIGHT_PIN || CASE_LIGHT_PIN < 0
#endif //!defined CASE_LIGHT_PIN || CASE_LIGHT_PIN < 0
#endif // FEATURE_CASE_LIGHT

#endif // EXTERNALSERIAL
Expand Down
12 changes: 10 additions & 2 deletions Repetier/HAL.h
Expand Up @@ -193,8 +193,16 @@ void FEATURE_READ_CALIPER_HOOK(); //read in calipers 48bit protocol bitwise!
//undef fix gegen compiler warning
#define SERIAL_RX_BUFFER_SIZE 128
#define SERIAL_RX_BUFFER_MASK 127
#define SERIAL_TX_BUFFER_SIZE 64
#define SERIAL_TX_BUFFER_MASK 63

#undef SERIAL_TX_BUFFER_SIZE
#undef SERIAL_TX_BUFFER_MASK
#ifdef BIG_OUTPUT_BUFFER
#define SERIAL_TX_BUFFER_SIZE 128
#define SERIAL_TX_BUFFER_MASK 127
#else
#define SERIAL_TX_BUFFER_SIZE 64
#define SERIAL_TX_BUFFER_MASK 63
#endif

struct ring_buffer_rx
{
Expand Down
26 changes: 17 additions & 9 deletions Repetier/Printer.cpp
Expand Up @@ -82,18 +82,18 @@ long Printer::advanceExecuted; ///< Exe
volatile int Printer::advanceStepsSet;
#endif // USE_ADVANCE

long Printer::maxSteps[3]; ///< For software endstops, limit of move in positive direction.
long Printer::minSteps[3]; ///< For software endstops, limit of move in negative direction.
float Printer::lengthMM[3];
float Printer::minMM[2];
long Printer::maxSteps[3] = {0}; ///< For software endstops, limit of move in positive direction.
long Printer::minSteps[3] = {0}; ///< For software endstops, limit of move in negative direction.
float Printer::lengthMM[3] = {0}; ///< Maximale Achskoordinate soll
float Printer::minMM[2] = {0}; ///< Minimale Achskoordinate -> normal ist das 0, ausser geänderte config.
float Printer::feedrate; ///< Last requested feedrate.
int Printer::feedrateMultiply = 1; ///< Multiplier for feedrate in percent (factor 1 = 100)
int Printer::extrudeMultiply = 1; ///< Flow multiplier in percdent (factor 1 = 100)
int Printer::feedrateMultiply = 1; ///< Multiplier for feedrate in percent (factor 1 = 100)
int Printer::extrudeMultiply = 1; ///< Flow multiplier in percdent (factor 1 = 100)
float Printer::extrudeMultiplyError = 0;
float Printer::extrusionFactor = 1.0;
float Printer::maxJerk; ///< Maximum allowed jerk in mm/s
float Printer::maxZJerk; ///< Maximum allowed jerk in z direction in mm/s
float Printer::extruderOffset[3]; ///< offset for different extruder positions.
float Printer::extruderOffset[3] = {0}; ///< offset for different extruder positions.
unsigned int Printer::vMaxReached; ///< Maximum reached speed
unsigned long Printer::msecondsPrinting; ///< Milliseconds of printing time (means time with heated extruder)
unsigned long Printer::msecondsMilling; ///< Milliseconds of milling time
Expand All @@ -112,6 +112,7 @@ float Printer::memoryX;
float Printer::memoryY;
float Printer::memoryZ;
float Printer::memoryE;
float Printer::memoryF;
#endif // FEATURE_MEMORY_POSITION

#ifdef DEBUG_PRINT
Expand Down Expand Up @@ -218,7 +219,7 @@ unsigned char Printer::wrongType;
unsigned char Printer::g_unlock_movement = 0;
#endif //FEATURE_UNLOCK_MOVEMENT

uint8_t Printer::motorCurrent[5] = {0,0,0,0,0};
uint8_t Printer::motorCurrent[DRV8711_NUM_CHANNELS] = {0};

#if FEATURE_ZERO_DIGITS
bool Printer::g_pressure_offset_active = true;
Expand All @@ -227,7 +228,7 @@ short Printer::g_pressure_offset = 0;

#if FEATURE_ADJUSTABLE_MICROSTEPS
//RF_MICRO_STEPS_ have values 0=FULL 1=2MS, 2=4MS, 3=8MS, 4=16MS, 5=32MS, 6=64MS, 7=128MS, 8=256MS
uint8_t Printer::motorMicroStepsModeValue[5] = {0,0,0,0,0}; //init later because of recalculation of value
uint8_t Printer::motorMicroStepsModeValue[DRV8711_NUM_CHANNELS] = {0}; //init later because of recalculation of value
#endif // FEATURE_ADJUSTABLE_MICROSTEPS

void Printer::constrainQueueDestinationCoords()
Expand Down Expand Up @@ -1252,9 +1253,12 @@ void Printer::defaultLoopActions()
#if FEATURE_MEMORY_POSITION
void Printer::MemoryPosition()
{
//https://github.com/repetier/Repetier-Firmware/blob/652d86aa5ad778222cab738f4448f6495bb85245/src/ArduinoAVR/Repetier/Printer.cpp#L1309
Commands::waitUntilEndOfAllMoves(); //MemoryPosition: Repetier hat hier schon geupdated aber alles auf CURRENT nicht auf LAST position? Macht das einen Unterschied?
updateCurrentPosition(false);
lastCalculatedPosition(memoryX,memoryY,memoryZ); //fill with queuePositionLastMM[]
memoryE = queuePositionLastSteps[E_AXIS]*invAxisStepsPerMM[E_AXIS];
memoryF = feedrate;
} // MemoryPosition

void Printer::GoToMemoryPosition(bool x,bool y,bool z,bool e,float feed)
Expand All @@ -1265,6 +1269,8 @@ void Printer::GoToMemoryPosition(bool x,bool y,bool z,bool e,float feed)
,(all || z ? memoryZ : IGNORE_COORDINATE)
,(e ? memoryE:IGNORE_COORDINATE),
feed);
feedrate = memoryF;
updateCurrentPosition(false);
} // GoToMemoryPosition
#endif // FEATURE_MEMORY_POSITION

Expand Down Expand Up @@ -1526,6 +1532,8 @@ int8_t Printer::checkHome(int8_t axis) //X_AXIS 0, Y_AXIS 1, Z_AXIS 2
Com::printFLN( PSTR( "checkHome: start axis" ), axis );
//if(axis == Z_AXIS) return -1; //noch verboten, weil solange das läuft der emergency-Stop nicht funktioniert. funktion wird evtl. wie HBS oder ZOS geteilt.

if(axis > Z_AXIS) return -1;

//do not allow checkHome without Home
if( !Printer::isAxisHomed(axis) ) return -1;
Com::printFLN( PSTR( "ishomed!" ) );
Expand Down
5 changes: 3 additions & 2 deletions Repetier/Printer.h
Expand Up @@ -127,6 +127,7 @@ class Printer
static float memoryY;
static float memoryZ;
static float memoryE;
static float memoryF;
#endif // FEATURE_MEMORY_POSITION

#if FEATURE_HEAT_BED_Z_COMPENSATION
Expand Down Expand Up @@ -227,15 +228,15 @@ class Printer
static unsigned char g_unlock_movement;
#endif //FEATURE_UNLOCK_MOVEMENT

static uint8_t motorCurrent[5];
static uint8_t motorCurrent[DRV8711_NUM_CHANNELS];

#if FEATURE_ZERO_DIGITS
static bool g_pressure_offset_active;
static short g_pressure_offset;
#endif // FEATURE_ZERO_DIGITS

#if FEATURE_ADJUSTABLE_MICROSTEPS
static uint8_t motorMicroStepsModeValue[5]; //1=2MS, 2=4MS, 3=8MS, 4=16MS, 5=32MS, 6=64MS, 7=128MS, 8=256MS
static uint8_t motorMicroStepsModeValue[DRV8711_NUM_CHANNELS]; //1=2MS, 2=4MS, 3=8MS, 4=16MS, 5=32MS, 6=64MS, 7=128MS, 8=256MS
#endif // FEATURE_ADJUSTABLE_MICROSTEPS

static INLINE void setMenuMode(uint8_t mode,bool on)
Expand Down
2 changes: 0 additions & 2 deletions Repetier/RF.cpp
Expand Up @@ -11885,8 +11885,6 @@ void nextPreviousZAction( int8_t increment )

#if STEPPER_CURRENT_CONTROL==CURRENT_CONTROL_DRV8711

#define DRV8711_NUM_CHANNELS 5

void drv8711Transmit( unsigned short command )
{
char i;
Expand Down
1 change: 1 addition & 0 deletions Repetier/RF.h
Expand Up @@ -492,6 +492,7 @@ The following variables are used for movements in x/y/z direction:
*/

#define DRV8711_NUM_CHANNELS 5

extern const char ui_text_error[] PROGMEM;
extern const char ui_text_warning[] PROGMEM;
Expand Down
4 changes: 0 additions & 4 deletions Repetier/Repetier.h
Expand Up @@ -167,10 +167,6 @@ extern void motorCurrentControlInit();


extern long baudrate;
#if OS_ANALOG_INPUTS>0
// Get last result for pin x
extern volatile uint osAnalogInputValues[OS_ANALOG_INPUTS];
#endif // OS_ANALOG_INPUTS>0

#include "HAL.h"

Expand Down

0 comments on commit a7f0eb4

Please sign in to comment.