CAN.Message.Data readonly

Is there any reason for this field to be readonly?

I would lik to simply affect Data with a byte array like this:

mess[0] = new GHI.Premium.Hardware.CAN.Message();
mess[0].ArbID = CANHS.candttx;
mess[0].DLC = 8;
mess[0].IsEID = true;
mess[0].IsRTR = false;
mess[0].Data = BitConverter.GetBytes((long)1);

but unfortunately a readonlyfield can not be assigned (while mess[0].Data[0] can be)

I think it is done this way to enforce size limit of the array.

This may be the reason… but an unconvevenient reason… Do you think it can have an impact on efficiency?

I agree. Personally, I would have done it differently. But there is no standard in writing APIs, so everybody does things differently. The main issue is once the API is out, it is really “hard” to change the API. All the documentation becomes invalid, examples don’t work, user code breaks. It has been done here few times. As for the efficiency, probably not a very big deal.

There actually IS a de facto standard for .NET :wink:

I guess CAN implementation is one of the oldest in GHI bag. It has many flaws…

@ Simon from Vilnius - I have that book :wink:

I have a list of changes to CAN on my end and will add this to it as well.

Oooooh, there’s a CAN To-Do list? I have a couple suggestions too!

Please provide any suggestions you have.

Opened a new topic:


Nice drop Simon. I also agree with all your points.