Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HardwareSerial::availableForWrite still return 128 after HardwareSerial::setTxBufferSize #6697

Closed
1 task done
imwhocodes opened this issue May 5, 2022 · 8 comments · Fixed by #6998
Closed
1 task done
Assignees
Labels
Area: ESP-IDF related ESP-IDF related issues Area: Peripherals API Relates to peripheral's APIs. Status: Solved Status: To be implemented Selected for Development
Milestone

Comments

@imwhocodes
Copy link

Board

ESP32 Dev Module

Device Description

Custom PCB

Hardware Configuration

A lot of stuff

Version

latest master (checkout manually)

IDE Name

Platformio

Operating System

Macos

Flash frequency

80

PSRAM enabled

no

Upload speed

115200

Description

I'm trying to use the new feature of v2.0.3

After setting TX buffer size with HardwareSerial::setTxBufferSize the function HardwareSerial::availableForWrite still always return 128 keeping track only of the free space in the TxFIFO without accounting of the newly allocated buffer for transmission

Sketch

#define NO_GLOBAL_SERIAL
#include <Arduino.h>

HardwareSerial SerialTest{1};

void setup(){
  SerialTest.setRxBufferSize(4096);
  SerialTest.setTxBufferSize(4096);
  SerialTest.begin(9600);
}

void loop() {
  log_e("availableForWrite:\t%d\n", SerialTest.availableForWrite());
}

Debug Message

availableForWrite: 128
availableForWrite: 128
availableForWrite: 128
availableForWrite: 128
availableForWrite: 128
availableForWrite: 128
....

Other Steps to Reproduce

No response

I have checked existing issues, online documentation and the Troubleshooting Guide

  • I confirm I have checked existing issues, online documentation and Troubleshooting guide.
@imwhocodes imwhocodes added the Status: Awaiting triage Issue is waiting for triage label May 5, 2022
@VojtechBartoska VojtechBartoska added Area: Peripherals API Relates to peripheral's APIs. Type: Question Only question and removed Status: Awaiting triage Issue is waiting for triage labels May 5, 2022
@SuGlider SuGlider added Type: Bug 🐛 All bugs Status: To be implemented Selected for Development and removed Type: Question Only question labels May 5, 2022
@SuGlider
Copy link
Collaborator

SuGlider commented May 5, 2022

@imwhocodes - Issue confirmed. Along the changes this fuction was left behind.
availableForWrite() only looks into the FIFO space. It has to be updated/fixed.

Thanks for reporting. I'll set a PR to fix it.

@SuGlider
Copy link
Collaborator

SuGlider commented May 6, 2022

I just looked into the code.... there is a big problem.
IDF has no function to get the left space in TX Ring Buffer associated to setTxBufferSize(size).
The Ring Buffer is created by IDF, but it can't be read, neither accessed.

I'll investigate it further, but it looks like there is no way to fix it at this time.

@SuGlider SuGlider added Area: ESP-IDF related ESP-IDF related issues and removed Type: Bug 🐛 All bugs labels May 6, 2022
@SuGlider SuGlider modified the milestones: 2.0.4, 2.1.0 May 6, 2022
@imwhocodes
Copy link
Author

I opened an issue / feature request on esp-idf, let see what they say

espressif/esp-idf#8932

@imwhocodes
Copy link
Author

I opened an issue / feature request on esp-idf, let see what they say

espressif/esp-idf#8932

@SuGlider issue was fixed on esp-idf repo, we need to update Arduino internal code

@SuGlider
Copy link
Collaborator

Thanks @imwhocodes
At this time this IDF function has been merged for IDF 5.0.
I've requested a backport to IDF 4.4 in order to allow us to use it within ESP32 Arduino Core.
I'll follow it as well.

@SuGlider
Copy link
Collaborator

I think it may be availble for a Arduino Core 2.0.5 (next release).
I'll add the fixes in the Arduino API and post a PR ready for when we have this IDF function in IDF 4.4.

@SuGlider SuGlider moved this from Todo to In Progress in Arduino ESP32 Core Project Roadmap Jul 12, 2022
@VojtechBartoska VojtechBartoska modified the milestones: 2.1.0, 2.0.5 Jul 13, 2022
@SuGlider
Copy link
Collaborator

SuGlider commented Jul 16, 2022

It has been backported to 4.4: espressif/esp-idf@dfb75aa
Confirmed to be present in the next Core Release based on PR e193e2a

@SuGlider
Copy link
Collaborator

@imwhocodes - PR #6998 shall solve the issue. Thanks for the help!

@VojtechBartoska VojtechBartoska moved this from In Progress to In Review in Arduino ESP32 Core Project Roadmap Jul 18, 2022
Repository owner moved this from In Review to Done in Arduino ESP32 Core Project Roadmap Aug 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: ESP-IDF related ESP-IDF related issues Area: Peripherals API Relates to peripheral's APIs. Status: Solved Status: To be implemented Selected for Development
Projects
Development

Successfully merging a pull request may close this issue.

3 participants