espressif / esp-protocols

Collection of ESP-IDF components related to networking protocols
180 stars 125 forks source link

About HW Flow Control (IDFGH-7281) #31

Closed diplfranzhoepfinger closed 2 years ago

diplfranzhoepfinger commented 2 years ago

Hello:

if i want to use ESP_MODEM_FLOW_CONTROL_HW.

the Scenario would be (in my Opinion, but i might be wrong)

  1. Connect to the Modem with ESP_MODEM_FLOW_CONTROL_NONE
  2. issue a esp_modem_set_flow_control(dce, 2, 2)
  3. Disconnect
  4. Reconnect to the Modem with ESP_MODEM_FLOW_CONTROL_HW

how do i achieve this ?

another way would be:

  1. Connect to the Modem with ESP_MODEM_FLOW_CONTROL_NONE
  2. issue a esp_modem_set_flow_control(dce, 2, 2)
  3. change FlowControl from ESP_MODEM_FLOW_CONTROL_NONE --> ESP_MODEM_FLOW_CONTROL_HW

Literature Reading: SIM7070_SIM7080_SIM7090 Series_AT Command Manual_V1.05.pdf Sections about Flow Control.

franz-ms-muc commented 2 years ago

In SIM7000 Series UART Application Note_V1.00 there is more info.

One should send AT repeated to synchronize Baudrate. After this one should send AT+IFC=2,2.

franz-ms-muc commented 2 years ago

Other story would be if one would like to set higher Baudrate. Like 2000000. Need to connect first with lower Baudrate. The. Send AT+IPR. Then connect by the higher Baudrate.

diplfranzhoepfinger commented 2 years ago

@david-cermak

david-cermak commented 2 years ago

Hi,

Most devices support changing the UART parameters both temporarily and permanently. This works with the baudrate at least, here we use a temporary command:

https://github.com/espressif/esp-protocols/blob/38149c8d9bdf469806fe0685558eba74f3366d73/components/esp_modem/src/esp_modem_command_library.cpp#L142-L146

But, we can also issue AT+IPREX to set the baudrate permanently (You can play with these settings in the console example)

As for the control flow, I believe that you can set the parameter without reconnection. I also remember using ESP_MODEM_FLOW_CONTROL_HW directly from startup and configuring AT+IFC immediately after that, but need to double-check that. I'll test it with some devices and get back to you.

david-cermak commented 2 years ago

About the control flow: Yes, I was correct. It's just enough to init the modem with:

    esp_modem_dte_config_t dte_config = ESP_MODEM_DTE_DEFAULT_CONFIG();
    dte_config.uart_config.flow_control = ESP_MODEM_FLOW_CONTROL_HW;
    auto uart_dte = create_uart_dte(&dte_config);

and just issue this command

cmd AT+IFC=2,2

to enable flow control on the device side. (this seems to work, as the CTS is asserted in no-flow-control mode, so we could send data and once the device receives it, it activates modem signals and we could receive data, too)

diplfranzhoepfinger commented 2 years ago

Cool. Will test.

david-cermak @.***> schrieb am Do., 5. Mai 2022, 17:32:

About the control flow: Yes, I was correct. It's just enough to init the modem with:

esp_modem_dte_config_t dte_config = ESP_MODEM_DTE_DEFAULT_CONFIG();
dte_config.uart_config.flow_control = ESP_MODEM_FLOW_CONTROL_HW;
auto uart_dte = create_uart_dte(&dte_config);

and just issue this command

cmd AT+IFC=2,2

to enable flow control on the device side. (this seems to work, as the CTS is asserted in no-flow-control mode, so we could send data and once the device receives it, it activates modem signals and we could receive data, too)

— Reply to this email directly, view it on GitHub https://github.com/espressif/esp-protocols/issues/31#issuecomment-1118703945, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJAHMXLHBKXMMVYLV2UUSH3VIPSX7ANCNFSM5UZ25AZQ . You are receiving this because you authored the thread.Message ID: @.***>

-- Diplom-Informatiker Franz Höpfinger e.K. Reibersdorf 16a 84419 Schwindegg

diplfranzhoepfinger commented 2 years ago

so, setting a fixed Baudrate worked. this does eliminate the need for Auto-Baud. cool so far ...

after a restart (ESP32 reboots, but SIM Module stay on Battery) i get often: E (3877) pppos_example: esp_modem_set_flow_control failed with 263 ESP_ERR_TIMEOUT

this does not happen on the First restarts. only after say 4-5 times ... seems the Modem hooks up somehow...

i thnik i understand: if the Modem is in a PPPOS Session, it cannot accept AT Commands ... that might be the Reason ! --> tested. this is the case ...

after a fresh reboot (disconnect Battery) i get: I (4477) pppos_example: esp_modem_set_flow_control: OK I (4487) pppos_example: Module: SIMCOM_SIM7070

david-cermak commented 2 years ago

@diplfranzhoepfinger Could we close this issue or do you still have trouble setting the flow control?