Int value passing from vehicle driver to hal occur error

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Int value passing from vehicle driver to hal occur error

2,544 Views
yifei_ren
Contributor III

Dear NXP Developer:

 

         When I using imx8qxp android P automotive version.

         I found property int value  passing from vehicle driver to vehicle hal occurs error.

         int value encoded in function 'vehicle_hal_set_property' in vehicle_core.c.

         This value will pass to vehicle hal.

void vehicle_hal_set_property(u16 prop, u8 index, u32 value)

         Such as 4 will become 2,  5 will become -3.

         Did you find it.

         I think it related with encode function.

         Could you help fix it ?

         Thank you.

0 Kudos
15 Replies

2,166 Views
jimmychan
NXP TechSupport
NXP TechSupport

I cannot find the code your mentioned. could you tell me more details about this?

0 Kudos

2,166 Views
yifei_ren
Contributor III

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
}
0 Kudos

2,166 Views
jimmychan
NXP TechSupport
NXP TechSupport

So, if you pass a value that is u32 type, is the decode value still wrong?

0 Kudos

2,166 Views
yifei_ren
Contributor III

yes, u32 type still wrong

0 Kudos

2,166 Views
jimmychan
NXP TechSupport
NXP TechSupport

Could you provide the log of the error?

0 Kudos

2,166 Views
yifei_ren
Contributor III

Value mismatch like this:

Driver Send |  HAL receive

        2          |           1

        3          |          -2

        4          |           2

        5          |          -3

        6          |           3

....

0 Kudos

2,166 Views
jimmychan
NXP TechSupport
NXP TechSupport

Could you tell me which Android P version are you using?

0 Kudos

2,166 Views
yifei_ren
Contributor III

Hello jimmy:

Android security patch : 2019.1.5

Kernel version : 4.14.98-07194

Android version : Android 9 2.1.0-auto-ga-rc4 

BTW, Can you ask question in one case once for all ?

0 Kudos

2,166 Views
jimmychan
NXP TechSupport
NXP TechSupport

I downloaded the newer version of Android BSP. (imx-p9.0.0_2.1.1-auto-ga.xml)

I found the vehicle_hal_set_property is different now.

please try it.

0 Kudos

2,166 Views
yifei_ren
Contributor III

Hello Jimmy Chan:

Which 2.1.1 version are you using ?

Imx8qxp only release 2.1.0.

Imx8qxm released 2.1.1, but  there is no difference in  vehicle_hal_set_property .

 

you mean imx8qxp 2.1.1 verison ? 

It still not release on NXP web.

Could you give me a download link ?

0 Kudos

2,166 Views
jimmychan
NXP TechSupport
NXP TechSupport

imx-manifest - i.MX Release Manifest 

repo init -u https://source.codeaurora.org/external/imx/imx-manifest -b imx-android-pie -m imx-p9.0.0_2.1.1-auto-ga.xml

0 Kudos

2,166 Views
krishnan_ramesh
Contributor III

hi jimmychan / nxp developers‌,

I would like to know how did u test this?

vehicle driver to vehicle hal ?

I am looking for CAN communication between CAN driver to Vehicle HAL?

Any idea of running vehicle hal test found here

<sources>packages/services/Car/tests/vehiclehal_test

or

running emulator in 

<sources>/hardware/interfaces/automotive/vehicle/2.0/default/tests

Regards,

Ramesh

0 Kudos

2,166 Views
yifei_ren
Contributor III

Please tell me you can reproduce it or not ?

Because I can reproduce  this issue 100% on my side.

0 Kudos

2,166 Views
yifei_ren
Contributor III

Add log in file /vendor/nxp-opensource/kernel_imx/drivers/mxc/vehicle/vehicle_protocol_callback.c

212bool encode_value_callback(pb_ostream_t *stream, const pb_field_t *field, void * const *arg)213{
....
237  propvalue.int32_values.arg = &data->value; // using pr_info check it, take value as 5  for example
.... }

In below file to check the value received in  Vehicle HAL received.

135void VehicleEmulator::doSetProperty(VehicleEmulator::EmulatorMessage& rxMsg,136                                    VehicleEmulator::EmulatorMessage& respMsg) {
{
...
157    if (protoVal.int32_values_size() > 0) {158        val.value.int32Values = std::vector<int32_t> { protoVal.int32_values().begin(),159                                                       protoVal.int32_values().end() };160    }
// recevice -3 at here. }
0 Kudos

2,166 Views
yifei_ren
Contributor III

File path : /android/vendor/nxp-opensource/kernel_imx/drivers/mxc/vehicle/vehicle_core.c 

In this file,function vehicle_hal_set_property will be called for encoding values.

Those value encoded by nanopb and decode by protobuf in HAL.

Please check it again.

0 Kudos