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

AndroidAutoProtocol 1.6 Support #29

Open
wants to merge 8 commits into
base: newdev
Choose a base branch
from

Conversation

sjdean
Copy link

@sjdean sjdean commented Jan 7, 2025

(Second Attempt)

AAP-Proto 1.6 Support and Tidy Ups

  • Restructure AASDK Proto Protobuf files for Android Auto 1.6 Support based on information from https://milek7.pl/.stuff/galdocs/readme.md
    This fleshes out enums and other methods with their full naming conventions for better readability and understanding.
  • Restructure AASDK source/header with additional renames to clarify differences between AudioService, VideoService and AVInput. Updated to MediaSinkService which is extended by AudioMediaSinkService and VideoMediaSinkService which themselves are extended by the individual service channels.
  • Added initial GenericNotification, MediaBrowser, MediaPlaybackStatus, PhoneStatus, Radio, VendorExtension and WifiProjection services for future use.
  • Update AASDK_LOG entries for extra consistency
  • Simplify CMAKE to build and install keeping parameters to a minimum. Default to Release mode and Raspberry PI build unless otherwise specified.

Simon.Dean and others added 8 commits October 7, 2024 15:44
Slight tweaks
- Add isInterleaved boolean
- If message is NULL and Frame Type is MIDDLE or LAST, then look for an existing message in buffer (if the message_ is null, then we need a FIRST or BULK frame)
- If message is still NULL, then we will create a new message, but recognise it as a valid frame ONLY if this is a FIRST or BULK frame because we cannot start on a MIDDLE or LAST.
- Rename recentFrameType to thisFrameType for more accuracy
- Only Resolve the Frame if the frame is BULK or LAST and the frame is valid.
- If the frame is interleaved, then we will use our interleavedPromise handler. Only resolve the main promise if the frame is not interleaved.
- Also reset message once resolved.
- Carry on reading if the original promise is not resolved (ie FIRST, MIDDLE, or Interleaved frame)
- Add some counters for debugging purposes.
- Have adjusted the buffer mechanism so instead of using the buffer to store a message in the event of an interleaved frame, we basically perform all work on the buffer (albeit we take the existing message for the channel id from the buffer for the frame we're working on and write the message to the buffer if the message isn't resolved).
- Moved writing to buffer to receiveFramePayloadHandler() function if the message is BULK or LAST and therefore not resolved.
- Simplified receiveFrameHeaderHandler() so that we automatically try to find a message from the buffer and then createa message as necessary depending on the frame type.
- Excellent stability with no noticeable artefacts in audio after 1 hour.
- Removed majority of debugging after achieving stability.
* Restructure AASDK Proto Protobuf files for Android Auto 1.6 Support based on information from https://milek7.pl/.stuff/galdocs/readme.md
This fleshes out enums and other methods with their full naming conventions for better readability and understanding.
* Restructure AASDK source/header with additional renames to clarify differences between AudioService, VideoService and AVInput. Updated to MediaSinkService which is extended by AudioMediaSinkService and VideoMediaSinkService which themselves are extended by the individual service channels.
* Added initial GenericNotification, MediaBrowser, MediaPlaybackStatus, PhoneStatus, Radio, VendorExtension and WifiProjection services.
* Update AASDK_LOG entries for extra consistency
* Simplify CMAKE to build and install keeping parameters to a minimum. Default to Release mode and Raspberry PI build unless otherwise specified.
# Conflicts:
#	.gitignore
#	CMakeLists.txt
#	aasdk_proto/ChannelDescriptorData.proto
#	aasdk_proto/VideoFPSEnum.proto
#	aasdk_proto/VideoFocusRequestMessage.proto
#	aasdk_proto/WifiSecurityRequestMessage.proto
#	include/aasdk/Common/Log.hpp
#	include/aasdk/Messenger/ChannelId.hpp
#	include/aasdk/Messenger/Cryptor.hpp
#	include/aasdk/Messenger/FrameSize.hpp
#	include/aasdk/Messenger/FrameType.hpp
#	include/aasdk/Messenger/ICryptor.hpp
#	include/aasdk/Messenger/MessageInStream.hpp
#	include/aasdk/Messenger/Messenger.hpp
#	src/Common/Data.cpp
#	src/Messenger/ChannelId.cpp
#	src/Messenger/Cryptor.cpp
#	src/Messenger/FrameSize.cpp
#	src/Messenger/FrameType.cpp
#	src/Messenger/MessageInStream.cpp
#	src/Messenger/MessageInStream.ut.cpp
#	src/Messenger/MessageOutStream.ut.cpp
#	src/Messenger/Messenger.cpp
#	src/Messenger/Messenger.ut.cpp
#	src/TCP/TCPEndpoint.ut.cpp
#	src/Transport/SSLWrapper.cpp
#	src/Transport/TCPTransport.ut.cpp
#	src/Transport/USBTransport.ut.cpp
#	src/USB/AOAPDevice.ut.cpp
#	src/USB/AccessoryModeQueryChain.ut.cpp
#	src/USB/AccessoryModeSendStringQuery.ut.cpp
#	src/USB/AccessoryModeStartQuery.ut.cpp
#	src/USB/ConnectedAccessoriesEnumerator.cpp
#	src/USB/ConnectedAccessoriesEnumerator.ut.cpp
#	src/USB/USBEndpoint.ut.cpp
#	src/USB/USBHub.ut.cpp
@matt2005
Copy link

matt2005 commented Jan 7, 2025

This requires a large review. I'll have a go at merging locally and testing.

Needs a combined effort to review as I've not looked at the code in a while.

@SonOfGib keen to hear your views on this as you've been updating the code recently.

@SonOfGib
Copy link

SonOfGib commented Jan 7, 2025

Yeah I think its worth working on, I left my thoughts on the previous pr.

I was eventually planning to look over the changes in depth and adapt the main code changes without the refactoring/build changes. That would take a while though.

From a high level I thought we might want to take the changes to the functionality / protobufs without refactoring the namespaces or changing the build setup. I am not familiar with building c++ apps/libraries so not sure if this build setup or the original setup are more "correct."

@matt2005
Copy link

matt2005 commented Jan 8, 2025

The changes make sense and personally I think it might be better to get this tested and merged sooner as it'll be easier to work off one base.

I know last time I did a major reorg I missed a few fixes due to them being written at same time and they got lost is merge conflicts.

@sjdean
Copy link
Author

sjdean commented Jan 8, 2025

I've been running this (and my forthcoming merge of OpenAuto - I'll do another PR for that), quite happily. But appreciate you'll need to do some internal testing.

My main goal was to bring in all the latest decoded Proto files from what appears to be a reliable source while introducing some stubs for future development and working on a little consistency in some of the naming conventions especially around sink/source etc. As there were a number of ProtoBuf's, we could either keep them together as one main proto file, or split them up. I favoured keeping them split with one proto per file, which meant restructuring the folders and trying to rationalise the difference between Service and Channel, and Sink, Output, Source and Input.

I also then wanted to review the build process, so now we can build the ProtoBuf's as one shared library, then build AASDK as another shared library....

ie

mkdir /aasdk/protobuf/build 
cd /aasdk/protobuf/build
cmake ..
make
make install

mkdir /aasdk/build
cd /aasdk/build
cmake ..
make
make install

I think it makes it a little simpler than having to specify the paths separately. I'm also hoping this will put us on track for going down the route of setting up our own apt repository for apt integrated updating and versioning etc.

I tried not to implement modifications for the sake of it, but it did need a bit of TLC in places due to the growth of the project and to hopefully move things forward.

If you need me to clarify anything though, please let me know.

@matt2005
Copy link

matt2005 commented Jan 8, 2025

@sjdean are you able to review and resolve the merge conflicts?

@sjdean
Copy link
Author

sjdean commented Jan 8, 2025

@sjdean are you able to review and resolve the merge conflicts?

Last time I checked I didn't have permission, but I would be happy to review and merge, it looks like it should be auto mergable.

@matt2005 matt2005 requested review from matt2005 and SonOfGib January 8, 2025 21:40
@matt2005
Copy link

matt2005 commented Jan 8, 2025

@SonOfGib I'm away with work for a few days. Do you think you could see if this builds. I know there is another pr against openauto that is dependent on these changes. So they will need to be built together.

@SonOfGib
Copy link

SonOfGib commented Jan 8, 2025

I will find some time to review and build over the next couple days. I will try to take some notes on what (if anything) is required to make it build properly vs the scripts we have now.

@matt2005
Copy link

matt2005 commented Jan 8, 2025

Thanks, on a side note did you get the slack invite?

@SonOfGib
Copy link

SonOfGib commented Jan 8, 2025

Oops, wasn't checking my email thanks for the heads up.

@matt2005
Copy link

matt2005 commented Jan 9, 2025

@sjdean it's not building for me.

I updated the entrypoint.sh to add the aasdk_proto build.

diff --git a/buildenv/entrypoint.sh b/buildenv/entrypoint.sh
index 7bbbd71..e85809d 100644
--- a/buildenv/entrypoint.sh
+++ b/buildenv/entrypoint.sh
@@ -17,6 +17,13 @@ fi

 echo "Now building within docker for $ARCH"

+# Make protobuf
+mkdir protobuf/build
+cd protobuf/build
+cmake -DCMAKE_BUILD_TYPE=Release -DTARGET_ARCH=$ARCH ..
+make
+make install
+
 # Clear out the /build directory
 rm -f bin/*
 rm -f lib/*

and protobuf/CMakeLists.txt

diff --git a/protobuf/CMakeLists.txt b/protobuf/CMakeLists.txt
index acdf51f..74dd534 100644
--- a/protobuf/CMakeLists.txt
+++ b/protobuf/CMakeLists.txt
@@ -3,7 +3,20 @@ cmake_minimum_required(VERSION 3.5)
 #Android Auto Projection Protocol Library
 project(aap_protobuf)
 message(STATUS "AASDK ProtoBuf Library")
-
+message(STATUS "Cross Compiling?")
+
+# Cross Compiling Architecture
+if( TARGET_ARCH STREQUAL "amd64" )
+    message(STATUS "...amd64")
+    set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "amd64")
+elseif( TARGET_ARCH STREQUAL "armhf" )
+    message(STATUS "...armhf")
+    set(CMAKE_C_COMPILER /usr/bin/arm-linux-gnueabihf-gcc-8)
+    set(CMAKE_CXX_COMPILER /usr/bin/arm-linux-gnueabihf-g++-8)
+    set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "armhf")
+else()
+    message(STATUS "...not cross compiling")
+endif()
 # Set Compile Versions
 set(LIBRARY_BUILD_DATE "20241121")    # Binary Release Build Date
 set(LIBRARY_BUILD_MAJOR_RELEASE 4)        # Binary Release Build Number (increment if released on same day)

But when building it fails

Attaching to buildenv-aasdk-build-1
buildenv-aasdk-build-1  | Now building within docker for armhf
buildenv-aasdk-build-1  | mkdir: cannot create directory 'protobuf/build': File exists
buildenv-aasdk-build-1  | -- AASDK ProtoBuf Library
buildenv-aasdk-build-1  | -- Cross Compiling?
buildenv-aasdk-build-1  | -- ...armhf
buildenv-aasdk-build-1  | CMake Error: Attempt to add a custom rule to output "/src/protobuf/build/InstrumentClusterInput.pb.h.rule" which already has a custom rule.
buildenv-aasdk-build-1  | NOTICEConfiguring SHARED Library
buildenv-aasdk-build-1  | -- Project Version: 4.0.0+20241121
buildenv-aasdk-build-1  | -- Configuring incomplete, errors occurred!
buildenv-aasdk-build-1  | See also "/src/protobuf/build/CMakeFiles/CMakeOutput.log".
buildenv-aasdk-build-1  | See also "/src/protobuf/build/CMakeFiles/CMakeError.log".
buildenv-aasdk-build-1  | make: *** No targets specified and no makefile found.  Stop.
buildenv-aasdk-build-1  | make: *** No rule to make target 'install'.  Stop.
buildenv-aasdk-build-1  | mkdir: cannot create directory 'build': File exists
buildenv-aasdk-build-1  | -- AASDK ProtoBuf Library
buildenv-aasdk-build-1  | -- Cross Compiling?
buildenv-aasdk-build-1  | -- ...armhf
buildenv-aasdk-build-1  | CMake Error: Attempt to add a custom rule to output "/src/protobuf/build/InstrumentClusterInput.pb.h.rule" which already has a custom rule.
buildenv-aasdk-build-1  | NOTICEConfiguring SHARED Library
buildenv-aasdk-build-1  | -- Project Version: 4.0.0+20241121
buildenv-aasdk-build-1  | -- Configuring incomplete, errors occurred!
buildenv-aasdk-build-1  | See also "/src/protobuf/build/CMakeFiles/CMakeOutput.log".
buildenv-aasdk-build-1  | See also "/src/protobuf/build/CMakeFiles/CMakeError.log".
buildenv-aasdk-build-1  | make: *** No targets specified and no makefile found.  Stop.
buildenv-aasdk-build-1  | CPack Error: Cannot find CPack config file: "CPackConfig.cmake"
buildenv-aasdk-build-1  | mv: cannot stat '*.deb': No such file or directory
buildenv-aasdk-build-1  | mv: cannot stat 'lib/*.so*': No such file or directory
buildenv-aasdk-build-1 exited with code 1

@sjdean
Copy link
Author

sjdean commented Jan 9, 2025 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants