CAN_SetValue returns Unknown Error
Posted: Thu 8. May 2025, 19:49
I was trying to implement the event system on Windows in a Rust library that wraps the PCANBasic API. I only get back Unknown Error (0x10000) whenever I make this call. Snippet of code looks like this, copying from the C++ example.
PCAN_LIBRARY is just a struct with function pointers loaded from the DLL. channel is just the usual PCAN_USBBUS2 (0x52). The HANDLE in the windows crate is just a thin wrapper around a usual void pointer (that's what's returned by the .0 notation).
Is there anything obvious that I'm doing wrong?
Code: Select all
// HANDLE iBuffer = CreateEvent(NULL, FALSE, FALSE, L"");
let event_handle: windows::Win32::Foundation::HANDLE =
unsafe { CreateEventA(None, false, false, s!("")).unwrap() };
// TPCANStatus stsResult = CAN_SetValue(PcanHandle, PCAN_RECEIVE_EVENT, &iBuffer, sizeof(iBuffer));
let status: PcanStatus = unsafe {
dbg!(PCAN_LIBRARY.CAN_SetValue(
channel,
PCAN_RECEIVE_EVENT as u8,
event_handle.0,
std::mem::size_of::<windows::Win32::Foundation::HANDLE>() as u32,
// std::mem::size_of_val(&event_handle) as u32,
))
}.into();
Is there anything obvious that I'm doing wrong?