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

[Bug]: Timing issues with sent frames? #12

Open
pzich opened this issue Nov 4, 2024 · 1 comment
Open

[Bug]: Timing issues with sent frames? #12

pzich opened this issue Nov 4, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@pzich
Copy link

pzich commented Nov 4, 2024

The problem

I'm looking to place my HDMI-CEC adapter (in this case, a Pulse-Eight USB-CEC Adapter), and this component is seeming like a great option! Thank you for building this!

However, while debugging things, I've been looking at the log output from the Pulse-Eight device, and every time the ESP sends a frame, there are a ton of HIGH_ERROR messages, suggesting there is something wrong with the timing of these messages?

HIGH_ERROR

I'm far from an expert when it comes to precise timing with MCUs, but looking at the code, I was wondering if a few things could be the culprit:

  • There seems to be a mix of delayMicroseconds() and delay_microseconds_safe(). Would it be better to use only one of these for all cases?
  • I noticed that send_and_read_ack_() is structured using an initial start_us = micros(), and after using delayMicroseconds(HIGH_BIT_US), the timing is controlled by checking against the start time with while((micros() - start_us) < SAFE_SAMPLE_US) and while((micros() - start_us) < TOTAL_BIT_US), while send_bit_() just uses pin_->digital_write()s and delayMicroseconds(). I'd imagine the timing for these is pretty reliable, but perhaps it would also benefit from a similar looped delay structure?
  • As far as I can tell, the InterruptLock in send_frame_() is all that's needed to prevent interrupts, but perhaps something is still causing an interrupt or other unexpected delay?

Which version of ESPHome was used when this happened?

2024.10.2

What platform are you using?

ESP32-IDF

Board

ESP32-DevKitC

Example YAML snippet

Just the plain hdmi_cec setup will trigger this when it responds (e.g. responding to 0x83):

hdmi_cec:
  pin: GPIO13
  address: 0x8
  physical_address: 0x3000

Also happens for hdmi_cec.send actions:

  - platform: template
    name: "HDMI3"
    on_press:
      hdmi_cec.send:
        destination: 0xF
        data: [0x82, 0x30, 0x00]

Anything in the logs that might be useful?

There seem to be Component hdmi_cec took a long time for an operation message (almost?) every time it sends. Nothing else out of the ordinary in the logs

[15:08:04][D][hdmi_cec:076]: frame received: 08:8C
[15:08:04][D][hdmi_cec:205]: sending frame: 80:00:8C:00
[15:08:04][D][hdmi_cec:219]: HDMICEC::send(): frame sent and acknowledged
[15:08:04][W][component:237]: Component hdmi_cec took a long time for an operation (121 ms).
[15:08:04][W][component:238]: Components should block for at most 30 ms.

Additional information

No response

@pzich pzich added the bug Something isn't working label Nov 4, 2024
@TheAndi
Copy link

TheAndi commented Nov 9, 2024

I can confirm that something is off with this implementation!

I am not able to control my Philips OLED808 with this. The TV can send me requests, but even if I reply to them, the TV keeps asking, this does not happen with ceclib on an Orange Pi.

Furthermore, the TV also ignores all my commands or requests. The only thing that triggers the TV is XF:36 (OFF as broadcast)

On the exact same Hardware (ESP32 and ESP32C3) I tested Tasmota HDMI CEC as well as the older ESPHome CEC component on which this is based on.

Looking forward to a fix. I can also beta-test new code if required ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants