bozimmerman/Zimodem

Suggestion: add hardware setup to readme + help changing UART port

SonnoOcea opened this issue · 1 comments

I closed the other issue by accident, so I thought that making a new issue could be better since at the end the issue I had was solved.

Would it be possible add in the readme a simple diagram showing which pin has to be connected where, specifying that it has to be connected to the UART2 pins on the ESP32?

One more thing:
I was looking a bit at the code to change which UART port to use (on the board I wanted to use the pins for uart1 are connected to a sd card holder and the uart2 to a lcd) and I found this block of code in serout.ino that I think I should edit, but I'm not 100% sure
(sadly it's not possible to put code blocks into a spoiler)

void ZSerial::setFlowControlType(FlowControlType type)
{
  flowControlType = type;
#ifdef ZIMODEM_ESP32
  if(flowControlType == FCT_RTSCTS)
  {
    uart_set_hw_flow_ctrl(UART_NUM_2,UART_HW_FLOWCTRL_DISABLE,0);
    uint32_t invertMask = 0;
    if(pinSupport[pinCTS])
    {
      uart_set_pin(UART_NUM_2, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE, /*cts_io_num*/pinCTS);
      // cts is input to me, output to true RS232
      if(ctsActive == HIGH)
        invertMask = invertMask | UART_INVERSE_CTS;
    }
    if(pinSupport[pinRTS])
    {
      uart_set_pin(UART_NUM_2, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE, /*rts_io_num*/ pinRTS, UART_PIN_NO_CHANGE);
      s_pinWrite(pinRTS, rtsActive);
      // rts is output to me, input to true RS232
      if(rtsActive == HIGH)
        invertMask = invertMask | UART_INVERSE_RTS;
    }
    //debugPrintf("invert = %d magic values = %d %d, RTS_HIGH=%d, RTS_LOW=%d HIGHHIGH=%d LOWLOW=%d\n",invertMask,ctsActive,rtsActive, DEFAULT_RTS_HIGH, DEFAULT_RTS_LOW, HIGH, LOW);
    if(invertMask != 0)
      uart_set_line_inverse(UART_NUM_2, invertMask);
    const int CUTOFF = 100;
    if(pinSupport[pinRTS])
    {
      if(pinSupport[pinCTS])
        uart_set_hw_flow_ctrl(UART_NUM_2,UART_HW_FLOWCTRL_CTS_RTS,CUTOFF);
      else
        uart_set_hw_flow_ctrl(UART_NUM_2,UART_HW_FLOWCTRL_CTS_RTS,CUTOFF);
    }
    else
    if(pinSupport[pinCTS])
      uart_set_hw_flow_ctrl(UART_NUM_2,UART_HW_FLOWCTRL_CTS_RTS,CUTOFF);
  }
  else
    uart_set_hw_flow_ctrl(UART_NUM_2,UART_HW_FLOWCTRL_DISABLE,0);
#endif
}

Considering I have no hardware flow control and I'm using it on non-commodore stuff, the only thing I need to edit is the last UART_NUM_2 to UART_NUM_0 right?

So, first: our ESP32-based modem is also for non-Commodore computers, so no complication there.

That said, if you don't need flow control on any of your serial ports, then yes, cutting out all the code inside #ifdef ZIMODEM_ESP32 is just fine.