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

An error occurred setting monitor brightness (while transmitting data to the device on the I2C bus) #14

Open
eddie-LA opened this issue Nov 2, 2021 · 8 comments
Labels
brightness-crate An error coming up from github.com/stephaneyfx/brightness

Comments

@eddie-LA
Copy link

eddie-LA commented Nov 2, 2021

Starting the app yields following output. My monitors are a Dell S2721DS (Monitor 1, DDC/CI on from monitor menu) and MSI MAG274QRF (Monitor 2, no DDC/CI setting in menu but works).

[2021-11-02T08:20:32Z INFO  solar_screen_brightness::lock::lock_impl] Acquired lock: solar-screen-brightness-0dba1e
[2021-11-02T08:20:32Z INFO  solar_screen_brightness::config] Successfully loaded config file
[2021-11-02T08:20:32Z INFO  solar_screen_brightness::controller] Starting BrightnessController
[2021-11-02T08:20:32Z INFO  solar_screen_brightness::tray] Launching tray application
[2021-11-02T08:20:32Z INFO  solar_screen_brightness::controller::apply] Computed base brightness of 25%
[2021-11-02T08:20:32Z INFO  solar_screen_brightness::console] Showing console
[2021-11-02T08:20:32Z INFO  solar_screen_brightness::tui] Cursive thread starting
[2021-11-02T08:20:32Z INFO  solar_screen_brightness::console::console_impl] Found valid PDC_hWnd in 1.40 ms
[2021-11-02T08:20:32Z ERROR solar_screen_brightness::controller::apply] An error occurred setting monitor brightness: SettingBrightnessFailed { device: "\\\\.\\DISPLAY1\\Monitor0", source: SettingBrightnessFailed { device_name: "\\\\.\\DISPLAY1\\Monitor0", source: Error { code: 0xC0262582, message: "An error occurred while transmitting data to the device on the I2C bus." } } } - SettingBrightnessFailed { device_name: "\\\\.\\DISPLAY1\\Monitor0", source: Error { code: 0xC0262582, message: "An error occurred while transmitting data to the device on the I2C bus." } } - Error { code: 0xC0262582, message: "An error occurred while transmitting data to the device on the I2C bus." }
[2021-11-02T08:20:33Z INFO  solar_screen_brightness::controller::worker] Brightness Worker sleeping for 22214s

In addition:
The app window was not responding when I ran it from CMD to capture the log. Subsequent runs normally also yielded a non-responding window. Running once with elevation fixed it and it no longer needs to be run with elevation for the ncurses window to work. Above error still comes up, though.

@jacob-pro
Copy link
Owner

jacob-pro commented Nov 2, 2021

So first just to check I understood: your second monitor (MSI MAG274QRF) is working fine right - the brightness is being adjusted by the program successfully?

The error in the log for your first monitor looks like there is a driver issue of some sort. The error we are seeing is coming from this call in the brightness crate:

https://github.com/stephaneyfx/brightness/blob/master/src/windows.rs#L395-L400

If you google the error: "0xC0262582 / An error occurred while transmitting data to the device on the I2C bus" I am generally seeing that this is a driver error. These posts suggest it is the Intel graphics driver - are you using Intel graphics?

https://www.dell.com/community/Monitors/U2715H-Intel-GPU-driver-updated-DDM-not-recognize-monitor/td-p/7475411
https://www.dell.com/community/Monitors/U3417W-XPS-15-9560-DDM-not-working/td-p/7638301

I would also suggest trying to update the drivers for your monitor itself.

There is also this similar advice from Nirsoft's ControlMyMonitor:

If you get error 0xc0262582 (or similar codes) and the main window of ControlMyMonitor is empty, it means that Windows operating system cannot connect your monitor using DDC/CI.
Here's what you can do in order to try to solve the problem:

Update the driver of your graphics card.
Try to plug your monitor using different type of cable/connector (VGA, DVI, HDMI, DisplayPort).
If you use a KVM switch, try to plug your monitor directly to the computer, without the KVM switch.

@eddie-LA
Copy link
Author

eddie-LA commented Nov 2, 2021

The brightness isn't being adjusted on either monitor, just double checked. I'm on an AMD machine with NVIDIA graphics, so the issue seems to not be strictly with Intel. I have both monitor drivers installed since the beginning. Both monitors are connected directly to the GPU via DP.

@jacob-pro jacob-pro added the brightness-crate An error coming up from github.com/stephaneyfx/brightness label Nov 4, 2021
@jacob-pro
Copy link
Owner

Hi @eddie-LA, I'm trying to figure out if your issue is with monitor drivers or the rust brightness crate.

Would you please consider installing Monitorian, and seeing if you can control both of your screens with that utility?

It provides a very helpful debug report using the probe button - https://github.com/emoacht/Monitorian#probe, if you could paste the results of that here, it might help us figure out what is wrong ?

@eddie-LA
Copy link
Author

eddie-LA commented Feb 9, 2022

Hi there, sure! I completely lost track of this in the last couple of months. Over this time I've also updated to Windows 11. Could validate what works and what doesn't as well as try and solve this issue. I just don't have much free time these days, but I'll try to keep up.

@jacks-cbus
Copy link

Hey there! I'm having essentially the same issue as Eddie with a very similar setup. The program successfully controls the brightness on one monitor (ASUS PG279Q) while it usually doesn't for the other (ASUS VG27AQ). What typically happens is that it will lower the brightness partially, but not all the way. My guess is that it is occasionally able to connect to the second monitor (and update it when it does), but usually not, leaving its brightness somewhere between 0-100 (I have it set to transition over 40 minutes). Occasionally when I reload the configuration it will be successful for both, but usually it says:

Error occurred during applying: Setting brightness failed for device \.\DISPLAY6\Monitor0

I went ahead and did a clean install for my graphics drivers, and manually located and installed the drivers for the problematic monitor (I couldn't find drivers for the other). Neither of these solutions worked, so I went ahead and installed Monitorian like you recommended to Eddie and used the probe button. I can control both of my monitors just fine with Monitorian, and I've attached the log that it generated at the end of this post.

For clarity:

  1. Two monitors - ASUS PG279Q and ASUS VG27AQ
  2. PG279Q works fine - VG27AQ only occasionally works
  3. Both plugged directly into GPU
  4. Both use DP connectors
  5. NVIDIA graphics on AMD machine

Also, the output I receive when running this program is very similar to what Eddie posted, but I'll post mine just for completeness:

[2022-04-03T01:49:25Z INFO  solar_screen_brightness::lock::lock_impl] Acquired lock: solar-screen-brightness-0abbb8
[2022-04-03T01:49:25Z INFO  solar_screen_brightness::config] Successfully loaded config file
[2022-04-03T01:49:25Z INFO  solar_screen_brightness::controller] Starting BrightnessController
[2022-04-03T01:49:25Z INFO  solar_screen_brightness::tray] Launching tray application
[2022-04-03T01:49:25Z INFO  solar_screen_brightness::controller::apply] Computed base brightness of 0%
[2022-04-03T01:49:26Z INFO  solar_screen_brightness::console] Showing console
[2022-04-03T01:49:26Z INFO  solar_screen_brightness::tui] Cursive thread starting
[2022-04-03T01:49:26Z INFO  solar_screen_brightness::console::console_impl] Found valid PDC_hWnd in 1.50 ms
[2022-04-03T01:49:26Z ERROR solar_screen_brightness::controller::apply] An error occurred setting monitor brightness: SettingBrightnessFailed { device: "\\\\.\\DISPLAY6\\Monitor0", source: SettingBrightnessFailed { device_name: "\\\\.\\DISPLAY6\\Monitor0", source: Error { code: 0xC0262582, message: An error occurred while transmitting data to the device on the I2C bus.
     } } } for: BrightnessDevice(Brightness { physical_monitor: 4, file_handle: 612, device_name: "\\\\.\\DISPLAY6\\Monitor0", device_description: "ASUS VG27A(DisplayPort)", device_key: "\\Registry\\Machine\\System\\CurrentControlSet\\Control\\Class\\{4d36e96e-e325-11ce-bfc1-08002be10318}\\0007", device_path: "\\\\?\\DISPLAY#AUS2722#5&26709729&2&UID155909#{e6f07b5f-ee97-4a90-b076-33f57bf4eaa7}", output_technology: 10 })
[2022-04-03T01:49:26Z INFO  solar_screen_brightness::controller::worker] Brightness Worker sleeping for 7:42:10

Let me know if you figure anything out or need additional information, because I really like this program!

probe.log

@jacob-pro jacob-pro changed the title An error occurred setting monitor brightness An error occurred setting monitor brightness (while transmitting data to the device on the I2C bus) Apr 3, 2022
@jacob-pro
Copy link
Owner

jacob-pro commented Apr 3, 2022

Hi @jacks-cbus , sorry it is not working for you, and thanks for providing the logs.

To be honest I'm kind of out of ideas! The error is actually coming from this crate, which may be a better place to raise the issue:

https://github.com/stephaneyfx/brightness/blob/16653e2030b968f52d9b50e24c4156f5880db637/src/windows.rs#L510-L519

We are getting an error calling the SetMonitorBrightness function from the Windows API, which is kind of out of my control.

On the other hand according to Monitarian the SetMonitorBrightness() function does work for your monitor!

When you say it occasionally works can you think of if there any particular correlation with your setup why that could be? Did you experience any intermittent behaviour with Monitarian when trying to set brightness?

Maybe if the monitor works intermittently we could introduce a retry loop, and attempt setting brightness up 3 or so times before giving up?

@jacks-cbus
Copy link

To be honest, it appears totally random to me as to when it successfully configures. This is likely purely coincidental, but I noticed when I unplugged the HDMI connector (leaving just the DP connector) and retried that it was able to configure. The first two times I tried this it was successful, but the third time it wasn't. I'll try and see if I can identify any patterns.

Also it is much more likely than not to be unsuccessful in configuring the second monitor, so I'm not sure that three retries would be sufficient. Perhaps we could do something where the user could choose the number of retries or set it to retry indefinitely until successful, and be able to set a timer as to how often it should retry. This might be useful for identifying when it is most likely to successfully configure.

@jacob-pro
Copy link
Owner

Sure that sounds like a good idea @jacks-cbus , I can maybe look at it sometime in a few weeks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
brightness-crate An error coming up from github.com/stephaneyfx/brightness
Projects
None yet
Development

No branches or pull requests

3 participants