VehcileDriver get value from M4 side by rpmsg. such as value is 5 which is int type.
In vehicle_hal_set_property it will encoded by nanopb.
file:/android/vendor/nxp-opensource/kernel_imx/drivers/mxc/vehicle/vehicle_core.c
void vehicle_hal_set_property(u16 prop, u8 index, u32 value)
{ send_message.msg_type = emulator_MsgType_SET_PROPERTY_CMD;
send_message.has_status = true;
send_message.status = emulator_Status_RESULT_OK;
send_message.value.funcs.encode = &encode_value_callback;
send_message.value.arg = &property_encode;
if (!pb_encode(&stream, emulator_EmulatorMessage_fields, &send_message)) // pb_encode will call encode_value_callback
pr_err("vehicle protocol encode fail \n");
send_usrmsg(buffer, stream.bytes_written); //send to HAL
file : /android/vendor/nxp-opensource/kernel_imx/drivers/mxc/vehicle/vehicle_protocol_callback.c
bool encode_value_callback(pb_ostream_t *stream, const pb_field_t *field, void * const *arg){
....
propvalue.int32_values.funcs.encode = &encode_int32_values_callback;
propvalue.int32_values.arg = &data->value;
propvalue.value_type = VEHICLEPROPERTYTYPE_INT32;
}
bool encode_int32_values_callback(pb_ostream_t *stream, const pb_field_t *field, void * const *arg)
{
u32 *value = (u32 *)*arg;
if (!pb_encode_tag_for_field(stream, field))
return false;
return pb_encode_varint(stream,*value);
}
// In VHAL it will call protobuf to decode it.
In VehicleEmulator.cpp
void VehicleEmulator::parseRxProtoBuf(std::vector<uint8_t>& msg) {
if (rxMsg.ParseFromArray(msg.data(), static_cast<int32_t>(msg.size()))) // value here will be decoded and value is wrong
}