Fix "ID String Type/Length Code" byte for get sdr command

Root cause :
Currently, the byte of "Type/Length Code" for dbus-sdr
get sdr record command is incorrect when the length of
sensor name is longer than 16 bytes. The suffix of the
sensor name would be replace with blank and resize the
sensor name with FULL_RECORD_ID_STR_MAX_LENGTH. Due to
this reason the "Type/Length Code" would record incorrect
data 0x10 (i.e. 16 bytes length sensor ID string).

Solution :
Resizing the sensor name when it is still longer than 16
bytes after replacing the suffix with blank.

Example :
Sensor Name = cpu0_pvccd_hv_Temperature

The result of getting SDR record without this change.
e4 00 e3 00 51 01 3b 20 00 e3 07 2f 00 68 01 01
85 32 85 32 1b 1b 80 01 00 00 01 00 00 00 00 00
00 00 00 00 00 00 00 5f 5a 00 00 03 00 00 00 00
00 10 63 70 75 30 20 70 76 63 63 64 20 68 76 00
00 00

The result of getting SDR record with this change.
c2 00 c1 00 51 01 3b 20 00 c1 07 2f 00 68 01 01
85 32 85 32 1b 1b 80 01 00 00 01 00 00 00 00 00
00 00 00 00 00 00 00 5f 5a 00 00 03 00 00 00 00
00 0d 63 70 75 30 20 70 76 63 63 64 20 68 76 00
00 00

Resize code reference:
https://github.com/openbmc/phosphor-host-ipmid/blob/master/dbus-sdr/sensorcommands.cpp#L445

Signed-off-by: Duke Du <Duke.Du@quantatw.com>
Change-Id: I63b81f5a54466318b25099d9496fc7796ab06752
1 file changed