Closed linosanfilippo-kunbus closed 1 year ago
Ugh, I've realized only now that the aioConfig_s[i].uHeader.sHeaderTyp1.bitAddress
field is necessary to find the SAioConfig
for a given address. Maybe use a separate u8[]
array to store the address for a given array index?
About commit f1ac37cb7e1c ("piControl: use pibridge_req_io() to send AIO config messages"):
Functionally, the commit is fine. I still have a recommendation: I would amend the definitions of
SAioConfig
andSAioInConfig
in IoProtocol.h to drop theuHeader
andi8uCrc
members.Next, drop all the code in
piAIOComm_Config()
to populate theuHeader
fields and calculate thei8uCrc
. All of that is just dead code because you letpibridge_req_io()
construct the header and crc. It's confusing to retain that code even though it no longer has any use.These changes will allow you to define
AIO_CONFIG_DATA1/2/3_LEN
assizeof(SAioConfig)
orsizeof(SAioInConfig)
, respectively, leading to (IMO) clearer code. Alternatively, you could forgo those macro definitions entirely and just usesizeof()
directly in thepibridge_req_io()
calls. If you feel that it adds value to document those packet sizes (it probably does), add the information to IoProtocol.h.