Thanks for reminding me about the buffer structure implications. I now remember why I put it aside last time I looked, because I wasn't up with how tight memory was, etc...
After I've had coffee and discussed some NCE issues with a colleague, I'll look at the JMRI code.
Dave in Australia
toggle quoted message
Show quoted text
On 12 Feb 2020, at 2:46 AM, tnt23 <
tim.tashpulatov@...> wrote:
For the record, here are changes I made to DCC++ BaseStation code for 6 byte packets.
PacketRegister.h:
struct Packet{
? byte buf[11]; // was 10?
? byte nBits;
}; // Packet
PacketRegister.cpp: in?RegisterList::loadPacket starting from Line 70:
if(nBytes==3){
? ? p->nBits=49;
? } else{
? ? buf[6]+=b[3]>>2;? ? ? ? ? ? ? ? ? // b[3], bits 7-2
? ? buf[7]=b[3]<<6;? ? ? ? ? ? ? ? ? ?// b[3], bit 1-0
? ? if(nBytes==4){
? ? ? p->nBits=58;
? ? } else{
? ? ? buf[7]+=b[4]>>3;? ? ? ? ? ? ? ? // b[4], bits 7-3
? ? ? buf[8]=b[4]<<5;? ? ? ? ? ? ? ? ?// b[4], bits 2-0
? ? ? if(nBytes==5){
? ? ? ? p->nBits=67;
? ? ? } else{
? ? ? ? buf[8]+=b[5]>>4;? ? ? ? ? ? ? // b[5], bits 7-4
? ? ? ? buf[9]=b[5]<<4;? ? ? ? ? ? ? ?// b[5], bits 3-0
//? ? ? ? p->nBits=76;
? ? ? ? if (nBytes == 6) {
? ? ? ? ? p->nBits = 76;
? ? ? ? } else {
? ? ? ? ? buf[9]+=b[6]>>5;? ? ? ? ? ? ? // b[6], bits 7-5
? ? ? ? ? buf[10]=b[6]<<3;? ? ? ? ? ? ? ?// b[6], bits 4-0
? ? ? ? ? p->nBits=85;
? ? ? ? }? ? ? ??
? ? ? } // >5 bytes
? ? } // >4 bytes
? } // >3 bytes