1
0
mirror of https://github.com/DCC-EX/CommandStation-EX.git synced 2024-11-27 10:06:13 +01:00

Compare commits

..

2 Commits

Author SHA1 Message Date
Harald Barth
fe9b1da8a3 version 5.2.35 2024-02-17 18:52:48 +01:00
Harald Barth
fbbedc7577 make ext acc packet format follow RCN-213 2024-02-17 18:51:13 +01:00
3 changed files with 34 additions and 16 deletions

45
DCC.cpp
View File

@ -289,28 +289,45 @@ decoders or data bytes to more complex accessory decoders. Each signal head can
XXXXX is for a single head. A value of 00000 for XXXXX indicates the absolute stop aspect. All other aspects
represented by the values for XXXXX are determined by the signaling system used and the prototype being
modeled.
*/
/* CAH Notes:
From https://normen.railcommunity.de/RCN-213.pdf:
More information is in RCN-213 about how the address bits are organized.
preamble -0- 1 0 A7 A6 A5 A4 A3 A2 -0- 0 ^A10 ^A9 ^A8 0 A1 A0 1 -0- ....
Thus in byte packet form the format is 10AAAAAA, 0AAA0AA1, 000XXXXX
Note that the Basic accessory format mentions
"By convention these bits (bits 4-6 of the second data byte) are in ones complement"
but this note is absent from the advanced packet description.
The (~address) construct below applies this because this appears to be
required.
Die Adresse für den ersten erweiterten Zubehördecoder ist wie bei den einfachen
Zubehördecodern die Adresse 4 = 1000-0001 0111-0001 . Diese Adresse wird in
Anwenderdialogen als Adresse 1 dargestellt.
This means that the first address shown to the user as "1" is mapped
to internal address 4.
Note that the Basic accessory format mentions "By convention these
bits (bits 4-6 of the second data byte) are in ones complement" but
this note is absent from the advanced packet description. The
english translation does not mention that the address format for
the advanced packet follows the one for the basic packet but
according to the RCN-213 this is the case.
We allow for addresses from -3 to 2047-3 as that allows to address the
whole range of the 11 bits sent to track.
*/
if (address != (address & 0x7FF)) return false; // 11 bits
if (value != (value & 0x1F)) return false; // 5 bits
if ((address > 2044) || (address < -3)) return false; // 2047-3, 11 bits but offset 3
if (value != (value & 0x1F)) return false; // 5 bits
address+=3; // +3 offset according to RCN-213
byte b[3];
b[0]= 0x80 | (address>>5);
b[1]= 0x01 | (((~address) & 0x1c)<<2) | ((address & 0x03)<<1);
b[0]= 0x80 // bits always on
| ((address>>2) & 0x3F); // shift out 2, mask out used bits
b[1]= 0x01 // bits always on
| (((~(address>>8)) & 0x07)<<4) // shift out 8, invert, mask 3 bits, shift up 4
| ((address & 0x03)<<1); // mask 2 bits, shift up 1
b[2]=value;
DCCWaveform::mainTrack.schedulePacket(b, sizeof(b), repeats); // Repeat on packet three times
DCCWaveform::mainTrack.schedulePacket(b, sizeof(b), repeats);
return true;
}
}
//
// writeCVByteMain: Write a byte with PoM on main. This writes

View File

@ -1 +1 @@
#define GITHUB_SHA "devel-202402050827Z"
#define GITHUB_SHA "devel-202402171752Z"

View File

@ -3,7 +3,8 @@
#include "StringFormatter.h"
#define VERSION "5.2.34"
#define VERSION "5.2.35"
// 5.2.35 - Bugfix: Make DCC Extended Accessories follow RCN-213
// 5.2.34 - <A address aspect> Command fopr DCC Extended Accessories
// - Exrail ASPECT(address,aspect) for above.
// - EXRAIL DCCX_SIGNAL(Address,redAspect,amberAspect,greenAspect)