You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We find between datalength and data there is extra “00 00 00 00”.
I trace the code, found in site-packages\prophy\composite.py
def encode(self, endianness):
data = b""
for field in self._descriptor:
data += (self._get_padding(len(data), field.type._ALIGNMENT))
data += field.encode_fcn(self, field.type, getattr(self, field.name, None), endianness)
if field.type._PARTIAL_ALIGNMENT:
data += self._get_padding(len(data), field.type._PARTIAL_ALIGNMENT)
data += self._get_padding(len(data), self._ALIGNMENT)
return data
Why add padding after the previous data(or say 'before the next data') based on next data’s field.type._ALIGNMENT ?
This is how C++ structures work. It's natural. Pointers to int64_t have to be aligned to 8 bytes. If you need "pack" feature, check out prophy.struct_packed:
We met a issue, when use python version:
payload whished:
.... 0x20 0x00 0x00 0x00 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x01 0x00 0x00 0x00 0x80 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
result:
.... 0x20 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x01 0x00 0x00 0x00 0x80 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
Here is our code:
class SApiBbbSendVsbDataReq(prophy.with_metaclass(prophy.struct_generator, prophy.struct)):
_descriptor = [
('transactionId', prophy.u32),
('portId', EBbbPortId),
('vsbTxRegionId', prophy.u32),
('transmissionEnabled', prophy.u32),
('dataLength', prophy.u32),
('data', prophy.array(prophy.u64, size=32)),
]
msg_type = 'SApiBbbSendVsbDataReq'
msg_name = 'API_BBB_SEND_VSB_DATA_REQ_MSG'
hwapi_msg = fsp.syscom.get_hwapi_message(msg_type=msg_type, msg_name=msg_name)
msg_obj = hwapi_msg.get_msg_obj()
msg_obj.transactionId = 0x0000001b
msg_obj.portId = get_EBbbPortId(cell.cpri_link[0])
msg_obj.vsbTxRegionId = 0x00000000
msg_obj.transmissionEnabled = 0x00000001
msg_obj.dataLength = 0x00000020
msg_obj.data[0] = 0xffffffffffffffff
msg_obj.data[1] = 0x0000000000000000
msg_obj.data[2] = 0x0000000800000001
We find between datalength and data there is extra “00 00 00 00”.
I trace the code, found in site-packages\prophy\composite.py
def encode(self, endianness):
data = b""
**data += (self._get_padding(len(data), field.type._ALIGNMENT))
len(data) = 20, field.type._ALIGNMENT = 8 ( next data is array u64)**
Why add padding after the previous data(or say 'before the next data') based on next data’s field.type._ALIGNMENT ?
This is why “00000000” was added in payload between “datalength” and “data”.
Is this the right behavior?
Can you help us check it?
The text was updated successfully, but these errors were encountered: