dbcc icon indicating copy to clipboard operation
dbcc copied to clipboard

Partial extended multiplexing support

Open mguzzina opened this issue 1 year ago • 4 comments

Should somewhat support SG_MUL_VAL_s.

I included an example dbc so you can generate the code and see what comes out.

mguzzina avatar Jun 07 '24 21:06 mguzzina

Looks like a good start, the generated code is not properly indented and does not match the style of the other code. The logical wrong values needs some work as well. In the rest of the messages if there is an error condition the check is performed and we immediately return, eliminating the need for the wrong value temporary variables.

howerj avatar Jun 10 '24 19:06 howerj

The indentation should now be fixed.

What should I do in this case to remove wrong value variable?

		bool wrong_value_muxed_muxer = true;
		if (o->can_0x692_extended_multiplex.muxed_muxer == 1) {
			wrong_value_muxed_muxer = false;
			/* muxed1: start-bit 32, length 32, endianess intel, scaling 1, offset 0 */
			x = ((uint32_t)(o->can_0x692_extended_multiplex.muxed1)) & 0xffffffff;
			x <<= 32; 
			i |= x;
		}
		if (o->can_0x692_extended_multiplex.muxed_muxer == 4) {
			wrong_value_muxed_muxer = false;
			/* muxed2: start-bit 32, length 32, endianess intel, scaling 1, offset 0 */
			x = ((uint32_t)(o->can_0x692_extended_multiplex.muxed2)) & 0xffffffff;
			x <<= 32; 
			i |= x;
		}
		if(wrong_value_muxed_muxer) {
			return -1;
		}

Is this acceptable or would you rather I implement it differently?

		if (o->can_0x692_extended_multiplex.muxed_muxer == 1) {
			/* muxed1: start-bit 32, length 32, endianess intel, scaling 1, offset 0 */
			x = ((uint32_t)(o->can_0x692_extended_multiplex.muxed1)) & 0xffffffff;
			x <<= 32; 
			i |= x;
		} else if (o->can_0x692_extended_multiplex.muxed_muxer == 4) {
			/* muxed2: start-bit 32, length 32, endianess intel, scaling 1, offset 0 */
			x = ((uint32_t)(o->can_0x692_extended_multiplex.muxed2)) & 0xffffffff;
			x <<= 32; 
			i |= x;
		} else {
			return -1;
		}

mguzzina avatar Jun 11 '24 09:06 mguzzina

The if...else if...else chain is acceptable, also a switch statement would be fine as well.

howerj avatar Jun 14 '24 21:06 howerj

In that case it should be already implemented. Do you want me to squash the commits? (At least the ones about multiplexing)

mguzzina avatar Jun 23 '24 16:06 mguzzina

Looks good, no need to squash, I'm not too fussed about that.

howerj avatar Jul 04 '24 18:07 howerj