ssalonen / cec-rs Goto Github PK
View Code? Open in Web Editor NEWLicense: GNU General Public License v2.0
License: GNU General Public License v2.0
Hi there,
Does this wrapper support autodetecting a Pulse Eight CEC Adapter? I'm fiddling withlibcec-sys
to hopefully make it work.
The example cec-client
autodetects devices if one is not specified.
CI is super-slow, probably due to
vendored
builds, building libcec. sscache
needed?See
https://www.uffizzi.com/blog/optimizing-rust-builds-for-faster-github-actions-pipelines
and
https://github.com/Mozilla-Actions/sccache-action
https://xuanwo.io/en-us/reports/2023-04/ (using sccache-action with rust)
https://news.ycombinator.com/item?id=23191505 (using sccache with cmake generated builds)
I am trying to build cec-rs on my Raspberry Pi 400.
I have installed:
When I try cargo build
I get "No such file or directory" for #include <cecc.h>
in the build/smoke_abi*.c
files
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
With ssalonen/libcec-sys#15 (to be released https://github.com/ssalonen/libcec-sys/actions/runs/2811518193), cec-rs should be able to support windows as well
Let's add the test to CI
Currently cec-rs initializes an empty CecLogicalAddresses struct as:
cec_logical_addresses {
primary: CecLogicalAddress::Unknown as i32,
addresses: [CecLogicalAddress::Unknown as i32; 16],
};
However this differs from libcec's representation, which marks an empty list with a primary address of UNREGISTERED:
https://github.com/Pulse-Eight/libcec/blob/76551ea1dd9a55f0ce1533e440dc12dbc594f7ba/include/cectypes.h#L1280-L1285
This seems to force cec-rs to always wake up devices even if CecConnectionCfg#wakeDevices is unset.
See compilation problem against libcec6 ssalonen/cec-alsa-sync#7, and related issue in libcec-sys ssalonen/libcec-sys#10
This wrapper library should probably expose feature flags for different ABI versions
I compiled it straight from the win-support
branch and it works fine on my computer.
Originally posted by @ok-nick in #26 (comment)
For example CecConnectionCfg uses new type structs for a number of its attributes. Although the structs themselves are public, their fields are private making it impossible to construct them. For example it is impossible to configure wake_devices
because the ArrayVec
field in CecLogicalAddresses
is private, making it impossible to construct an instance of CecLogicalAddresses
.
This is also true of trying to construct or extract parameters from CecCommands: the ArrayVec in CecDatapacket is private. Forcing users to convert it to a libcec_sys::cec_command to access the underlying data.
It seems like the there is a mismatch of how libcec defines cec_logical_addresses
and how CecLogicalAddresses
interprets them.
libcec defines cec_logical_addresses as:
struct {
cec_logical_address primary; /< the primary logical address to use */
int addresses[16]; /< the list of addresses */
}
Unfortunately the comment /**< the list of addresses */
is extremely misleading. It should actually be called a bit map rather than a list where the keys are logical addresses and the values are booleans that indicate if the address is present. This behavior is visible in the implementation for Set():
void Set(cec_logical_address address)
{
if (primary == CECDEVICE_UNREGISTERED)
primary = address;
addresses[(int) address] = 1;
}
On the other hand cec-rs interprets the struct as list of logical addresses (where the primary address lives on its own).
I'm fairly new to rust, but it seems like callbacks (ie CecConnectionCfg#command_received_callback) should require the closure to be Send
. libcec will invoke callbacks from a different thread than the main thread that constructed CecConnectionCfg.
CecConnection::transmit will fail with libcec version x (TODO) when trying to transmit command having data packet of maximum size
The crash occurs in raspberry pi libcec adapter code.
Possible failure reason (not verified):
cec_adapter_message_state CRPiCECAdapterMessageQueue::Write(const cec_command &command, bool &bRetry, uint32_t iLineTimeout, bool bIsReply, VC_CEC_ERROR_T &vcReply)
<SNIP>
#if defined(RPI_USE_SEND_MESSAGE2)
<SNIP>
#else
<SNIP>
uint8_t payload[32];
<SNIP>
for (uint8_t iPtr = 0; iPtr < command.parameters.size; iPtr++)
payload[iPtr + 1] = command.parameters.At(iPtr);
}
<SNIP>
#fi
However, command.parameters
can be up to 64 uint8_t
cectypes.h --> payload
local variable is not large enough!
TODO
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.