DCC model trains

Has anybody written their own sketch to implement DCC, not just used DCC++? My code to move an engine works OK, and I can turn the lights on on an engine, but I am unable to combine both commands into a single packet even though spec NMRA 9.2.1 implies I should be able to. As a work around, if I first send a packet commanding the engine to move forward it works, if I now send a 2nd packet to turn on the lights, the lights turn on but the engine stops moving. The 2nd packet over-rides unrelated commands in the 1st packet.

If I send a packet containing both commands, the decoder on the train only recognises the 1st command and ignores the 2nd command. The decoder correctly knows it is a two command packet as it correctly recalculates exclusive OR.

If possible, I would like to chat with a coder who has implemented a sketch for DCC.

Thanks in advance.