Status Update
Comments
sa...@google.com <sa...@google.com>
rk...@google.com <rk...@google.com>
si...@google.com <si...@google.com> #2
My apologies. Looks to be a duplicate of
si...@google.com <si...@google.com> #3
si...@google.com <si...@google.com> #4
co...@accenture.com <co...@accenture.com> #5
I followed the basic tutorial in
I then created and started an AAOS emulator on Linux using
- sdkmanager --channel=3 "system-images;android-32;android-automotive-playstore;x86_64"
- avdmanager -v create avd -f -n aaos -k "system-images;android-32;android-automotive-playstore;x86_64" -d automotive_1024p_landscape -p "/opt/android-sdk/avds/aaos"
- /opt/android-sdk/emulator/emulator @aaos -allow-host-audio -ports 5554,5555 -skip-adb-auth -no-boot-anim -grpc 8554 -accel on -gpu host -no-snapshot
Once the emulator UI is visible I ran the client.py code using the following value (because its easier to see that the fuel on in my original code)
value = VehicleHalProto_pb2.VehiclePropValue(
prop=358614275,
area_id=49,
float_values=[19]
When I run the script I get the following error
Traceback (most recent call last):
File "grpc/grpc/examples/python/avd/client.py", line 30, in <module>
run()
File "grpc/grpc/examples/python/avd/client.py", line 24, in run
response = stub.sendCarEvent(car_service_pb2.CarEvent(data=msg.SerializeToString()))
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x83 in position 7: invalid start byte
I then change the local proto file so that CarEvent is bytes instead of string. Now I get the following error
Traceback (most recent call last):
File "grpc/grpc/examples/python/avd/client.py", line 30, in <module>
run()
File "grpc/grpc/examples/python/avd/client.py", line 24, in run
response = stub.sendCarEvent(car_service_pb2.CarEvent(data=msg.SerializeToString()))
File "grpc/venv/lib/python3.10/site-packages/grpc/_channel.py", line 1181, in __call__
return _end_unary_response_blocking(state, call, False, None)
File "grpc/venv/lib/python3.10/site-packages/grpc/_channel.py", line 1006, in _end_unary_response_blocking
raise _InactiveRpcError(state) # pytype: disable=not-instantiable
grpc._channel._InactiveRpcError: <_InactiveRpcError of RPC that terminated with:
status = StatusCode.INTERNAL
details = ""
debug_error_string = "UNKNOWN:Error received from peer {created_time:"2024-09-23T10:27:57.065536334+01:00", grpc_status:13, grpc_message:""}"
I then make the same change on the emulator side, rebuild it and restart the emulator. This time there are no errors from python and you can see the temperature value change in the UI.
si...@google.com <si...@google.com> #6
Thanks! Reproduced the issue and confirmed the change
Reproduce process
Assume the environemnt is gLinux.
1. install grpc
pip install grpcio-tools
might need --break-system-packages
appended
2. Get required protos
< This is from Android repositoryVehicleHalProto_pb2.py < This is from emulator repositorycar_service.proto
Copy those files to a wherever path you will execute a python script
3. Generate pb2.py
You need to generate pb2 py file from car_service.proto
python -m grpc_tools.protoc -I . --python_out=. --grpc_python_out=. ./car_service.proto
car_service_pb2.py
and car_service_pb2_grpc.py
files are generated
4. prepare python client
Copy a script from the description of this bug. Will save it as test.py
in this example
5. Run a client
First, launch an emulator with -grpc 8554
argument to avoid authentication
Run a python client with
PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python python test.py
PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python
might be needed in case of protobuf version issue
Result : The same failure UnicodeDecodeError: 'utf-8' codec can't decode byte
as is in
6. Apply a fix`
Change
Copy the changed car_service.proto
file and repeat 3. Generate pb2.py to apply the change into python client
Rebuild an emulator with the change applied.
Relaunch an emulator using the rebuild one.
Now the fixes should have been applied to both the python (grpc) client and the emulator
7. Test again
Re run a client as is in 5. Run a client
If there were no error, the client ran successfully
8. How to check if it's well applied
See the emulator. click extended window (3 dots in the bottom of emulator menu). Car data > Vhal properties.
Find a property with id 287310853
as is used in the python client.
If 287310853
doesn't exist in your emulator, find another property id that has integer value, change the client to use this property id, and test again.
Check if the integer value was changed into 1
after the client run. You can further test by changing int32_values=[1]
value into [0]
, [2]
or whatever value, and then confirm it is changed in vhal table.
Description
The Car Service API allows programmatic access to the AAOS VHAL. The problem is that thehttps://android.googlesource.com/platform/external/qemu/+/emu-master-dev/android/android-grpc/services/incubating/car/proto/car_service.proto has the type for CarEvent as string whereas its expected as a byte string by AAOS.
The fix is to change the type from string to bytes. I've rebuilt the emulator on Linux and the fix is working fine with both python and node.js gRPC clients.
The following example python script can be used for reproducing the problem using a Linux emulator running an AAOS image (for example system-images;android-32;android-automotive-playstore;x86_64)