openDsh / aasdk

Library to build AndroidAuto headunit emulator
15 stars 24 forks source link

invalid conversion from 'int' to 'libusb_hotplug_flag' #16

Open JesseMFrey opened 3 years ago

JesseMFrey commented 3 years ago
I get the following error when I try to compile aasdk: `In file included from /home/alarm/pkgbuilds/aasdk-git/src/aasdk-dash-git/include/aasdk/USB/IUSBWrapper.hpp:24, from /home/alarm/pkgbuilds/aasdk-git/src/aasdk-dash-git/src/USB/USBHub.cpp:20: /home/alarm/pkgbuilds/aasdk-git/src/aasdk-dash-git/src/USB/USBHub.cpp: In lambda function: /home/alarm/pkgbuilds/aasdk-git/src/aasdk-dash-git/src/USB/USBHub.cpp:52:103: error: invalid conversion from 'int' to 'libusb_hotplug_flag' [-fpermissive] 52 hotplugHandle = usbWrapper.hotplugRegisterCallback(LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED, LIBUSB_HOTPLUG_NO_FLAGS, LIBUSB_HOTPLUG_MATCH_ANY, LIBUSB_HOTPLUG_MATCH_ANY, ^~~~~~~
int

In file included from /home/alarm/pkgbuilds/aasdk-git/src/aasdk-dash-git/src/USB/USBHub.cpp:20: /home/alarm/pkgbuilds/aasdk-git/src/aasdk-dash-git/include/aasdk/USB/IUSBWrapper.hpp:75:108: note: initializing argument 2 of 'virtual aasdk::usb::HotplugCallbackHandle aasdk::usb::IUSBWrapper::hotplugRegisterCallback(libusb_hotplug_event, libusb_hotplug_flag, int, int, int, libusb_hotplug_callback_fn, void*)' 75 | virtual HotplugCallbackHandle hotplugRegisterCallback(libusb_hotplug_event events, libusb_hotplug_flag flags, int vendor_id, int product_id, int dev_class, | ~~~~^~~~~ make[2]: [CMakeFiles/aasdk.dir/build.make:678: CMakeFiles/aasdk.dir/src/USB/USBHub.cpp.o] Error 1 make[1]: [CMakeFiles/Makefile2:100: CMakeFiles/aasdk.dir/all] Error 2 make: *** [Makefile:136: all] Error 2 ` I have libusb version 1.0.24

robert5974 commented 3 years ago

Did you try the install.sh script or are you manually building?

JesseMFrey commented 3 years ago

Manually building

robert5974 commented 3 years ago

I'd recommend the install script. You might be missing a package that is needed. You could even look at the packages the install script installs. The install script is in the dash directory after you clone that repo. The install script will build aasdk, Openauto, qt-gstreamer, and dash.

What hardware and OS are you using?

JesseMFrey commented 3 years ago

The install script uses apt (I think) and this, doesn't work I'm using arch on a pi4

robert5974 commented 3 years ago

Yeah, we haven't had any support for another OS outside of RPi OS and Ubuntu (debian based). I think I might be the only one to try Ubuntu 64bit 20.10 on the Pi4 with OpenDash. I got everything installed but I had to find a few packages that had different names due to those packages having a 64bit variant.

You should check your libusb version against the package in debian based OS and see if what Arch has is the same or newer. I've never used Arch so I couldn't tell you without diving into it. Let us know what you find.

Also, everything for dash is written to not require running as root. Only exception is when installing aasdk and Openauto to /usr/local directory with "sudo make install". If built using root, there can be issues when connecting your device for Openauto functionality.

JesseMFrey commented 3 years ago

Like I said in the first post, I have libusb version 1.0.24. Not sure what version other distros are using but, Arch often adopts new things first.

I did get it to work with the following patch, just casting to libusb_hotplug_flag (not sure this is the "right way" but, it works)

diff --git a/src/USB/USBHub.cpp b/src/USB/USBHub.cpp
index cc302d9..7898d48 100644
--- a/src/USB/USBHub.cpp
+++ b/src/USB/USBHub.cpp
@@ -49,7 +49,7 @@ void USBHub::start(Promise::Pointer promise)
         if(self_ == nullptr)
         {
             self_ = this->shared_from_this();
-            hotplugHandle_ = usbWrapper_.hotplugRegisterCallback(LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED, LIBUSB_HOTPLUG_NO_FLAGS, LIBUSB_HOTPLUG_MATCH_ANY, LIBUSB_HOTPLUG_MATCH_ANY,
+            hotplugHandle_ = usbWrapper_.hotplugRegisterCallback(LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED, (libusb_hotplug_flag)LIBUSB_HOTPLUG_NO_FLAGS, LIBUSB_HOTPLUG_MATCH_ANY, LIBUSB_HOTPLUG_MATCH_ANY,
                                                                  LIBUSB_HOTPLUG_MATCH_ANY, reinterpret_cast<libusb_hotplug_callback_fn>(&USBHub::hotplugEventsHandler), reinterpret_cast<void*>(this));
         }
     });

installing things has not been a huge problem. The Arch scripts install things to a temp directory as fakeroot and then it's installed to / with the package manager.

robert5974 commented 3 years ago

Nice. It'll be good to document how to get it working on other distros. Hope everything else goes smooth. When you get to qt-gstreamer, perhaps Arch has it already for installation like Ubuntu. Instead of having to build it manually for the Pi.

JesseMFrey commented 3 years ago

I ended up building dash with:

cmake -DCMAKE_BUILD_TYPE=Release ../ -DRPI_BUILD=FALSE -DGST_BUILD=TRUE

arch does have a qt-gstreamer package

robert5974 commented 3 years ago

So you had to build qt-gstreamer then? Was that as intended or did you have to make adjustments?

Are you using an official Raspberry Pi 7" touchscreen? If so, make sure you create the udev rules for the backlight.

JesseMFrey commented 3 years ago

It was missing libraries without -DGST_BUILD=TRUE it would complain about some includes

Not sure if I made some rules previously or added myself to the right group but, brightness works

robert5974 commented 3 years ago

Awesome yeah that makes sense. Probably that you are in the right group.

Just curious, Are you using 32bit or 64bit Arch?

JesseMFrey commented 3 years ago

I'm using the 32 bit arch linux

stefan-sherwood commented 3 years ago

FWIW, in order to get the build to work on WSL I had to change apt to apt-get. I don't know of any reason why that can't be done across the board.

robert5974 commented 3 years ago

@JesseMFrey how's the build running for you on Arch?

JesseMFrey commented 3 years ago

I haven't tried but, switching from apt to apt-get shouldn't help because Arch uses pacman

stefan-sherwood commented 3 years ago

Should be easy enough to conditionalize the script for Arch and pacman

JesseMFrey commented 3 years ago

I suppose that's possible. I guess I'd rather have an actual package built with dependencies

stefan-sherwood commented 3 years ago

Not sure I understand. This project doesn't have a prebuilt images so you have to build it yourself by running the install script.