ssalonen / cec-rs

GNU General Public License v2.0
10 stars 8 forks source link

cfg.open() fails on macos and linux #33

Closed andrewdavidmackenzie closed 1 year ago

andrewdavidmackenzie commented 1 year ago

I have tried to run the example on macos and linux, and both fail on the cfg.open()

This line of code : (I added the expect())

let connection = cfg.open().expect("Could not open config");

Is this expected to work as-is, or is there any specific hardware I need to be attached to for it to work?

Thanks

ssalonen commented 1 year ago

Raspberry PI is needed for the example. If you have USB Cec adapter, changes to example are probably needed. Check out the port parameter

which hardware you are using?

andrewdavidmackenzie commented 1 year ago

I tried on macos on Mac, and Ubuntu on Thinkpad.

OK.

ssalonen commented 1 year ago

You need to have suitable hardware... this is one USB HDMI cec adapter https://www.pulse-eight.com/p/104/usb-hdmi-cec-adapter (have not tested though)

I am not sure if the devices you mention support HDMI CEC. If they do, at least the port name in the example needs to be changed.

If issues occur with supported hardware, please raise a new ticket

andrewdavidmackenzie commented 1 year ago

OK, I didn't realize that it was so targetted at Raspberry Pi.

I wanted to write a cross-platform utility for controlling external monitors using CEC (a bit like Monitor Control Lite does for external monitor brightness on macos, but for more things).

It sounds like it's out of scope and at most I should look at building on libcec-sys?

That README mentions Linux and Windows, but not macos nor RPi, so I'm not sure to what extent anything in the stack is trying to be really cross-desktop-platform?

ssalonen commented 1 year ago

This is cross-platform, similar to libcec itself. There has been even positive usage with windows but Mac has not been tested. It might work. Pull requests are welcome if it is not working.

I was just noting that example is tailored against Raspberry Pi, due to obvious reasons:

https://github.com/ssalonen/cec-rs/blob/d31e77ddcf1b3326e7f863261f5d0240e90f9d7c/examples/cec-example-cli/bin.rs#L42

Maybe first check port name with prebuilt libcec tools (http://libcec.pulse-eight.com/Downloads), and then try with this one

andrewdavidmackenzie commented 1 year ago

Understood. It would be great to have an example (CLI) for other platforms, just to see something working after cloning and building, but I know zero about what would be required to get it working (such as "correct" port names).

If I can find them, then I would do a PR where the port-name would be under #[cfg(target_os="...")] and one example would work for all...

ssalonen commented 1 year ago

I am not sure either how libcec works with this regard in detail...great idea however! We need brave volunteers that could try it out with some other system :)

ssalonen commented 1 year ago

Update to this: while Macs have HDMI ports, they do not support CEC https://support.apple.com/en-us/HT204388

Mac computers don't support using CEC (Consumer Electronics Control) to control HDMI devices.

So you might actually need an external adapter with Mac: https://reddit.com/r/osx/comments/8cg86s/_/dyg39s5/?context=1

andrewdavidmackenzie commented 1 year ago

Is it possible to build directly on my Pi (Pi400)?

I'm trying but getting errors on missing headers (cecc.h) even after I installed libcec-dev, and all python dev....

A bit more info on building/cross-build, and pre-requisites, on different build OS would be a great addition to the README.

ssalonen commented 1 year ago

Thanks for suggestion, indeed this lib is missing basics in readme,

For now, can you try with linux prerequisites listed in libcec-sys: https://github.com/ssalonen/libcec-sys

If the problems continue, please make a new issue