mirror of
https://github.com/DCC-EX/CommandStation-EX.git
synced 2024-11-23 08:06:13 +01:00
Bugfix: Transmit packages of size MAX_PACKET_SIZE (5) as well
This commit is contained in:
parent
d35529e94a
commit
98071602c3
8
DCC.cpp
8
DCC.cpp
|
@ -198,6 +198,10 @@ void DCC::setAccessory(int address, byte number, bool activate) {
|
||||||
DCCWaveform::mainTrack.schedulePacket(b, 2, 4); // Repeat the packet four times
|
DCCWaveform::mainTrack.schedulePacket(b, 2, 4); // Repeat the packet four times
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// writeCVByteMain: Write a byte with PoM on main. This writes
|
||||||
|
// the 5 byte sized packet to implement this DCC function
|
||||||
|
//
|
||||||
void DCC::writeCVByteMain(int cab, int cv, byte bValue) {
|
void DCC::writeCVByteMain(int cab, int cv, byte bValue) {
|
||||||
byte b[5];
|
byte b[5];
|
||||||
byte nB = 0;
|
byte nB = 0;
|
||||||
|
@ -212,6 +216,10 @@ void DCC::writeCVByteMain(int cab, int cv, byte bValue) {
|
||||||
DCCWaveform::mainTrack.schedulePacket(b, nB, 4);
|
DCCWaveform::mainTrack.schedulePacket(b, nB, 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// writeCVBitMain: Write a bit of a byte with PoM on main. This writes
|
||||||
|
// the 5 byte sized packet to implement this DCC function
|
||||||
|
//
|
||||||
void DCC::writeCVBitMain(int cab, int cv, byte bNum, bool bValue) {
|
void DCC::writeCVBitMain(int cab, int cv, byte bNum, bool bValue) {
|
||||||
byte b[5];
|
byte b[5];
|
||||||
byte nB = 0;
|
byte nB = 0;
|
||||||
|
|
|
@ -256,7 +256,7 @@ void DCCWaveform::interrupt2() {
|
||||||
|
|
||||||
// Wait until there is no packet pending, then make this pending
|
// Wait until there is no packet pending, then make this pending
|
||||||
void DCCWaveform::schedulePacket(const byte buffer[], byte byteCount, byte repeats) {
|
void DCCWaveform::schedulePacket(const byte buffer[], byte byteCount, byte repeats) {
|
||||||
if (byteCount >= MAX_PACKET_SIZE) return; // allow for chksum
|
if (byteCount > MAX_PACKET_SIZE) return; // allow for chksum
|
||||||
while (packetPending);
|
while (packetPending);
|
||||||
|
|
||||||
byte checksum = 0;
|
byte checksum = 0;
|
||||||
|
@ -264,6 +264,7 @@ void DCCWaveform::schedulePacket(const byte buffer[], byte byteCount, byte repea
|
||||||
checksum ^= buffer[b];
|
checksum ^= buffer[b];
|
||||||
pendingPacket[b] = buffer[b];
|
pendingPacket[b] = buffer[b];
|
||||||
}
|
}
|
||||||
|
// buffer is MAX_PACKET_SIZE but pendingPacket is one bigger
|
||||||
pendingPacket[byteCount] = checksum;
|
pendingPacket[byteCount] = checksum;
|
||||||
pendingLength = byteCount + 1;
|
pendingLength = byteCount + 1;
|
||||||
pendingRepeats = repeats;
|
pendingRepeats = repeats;
|
||||||
|
|
|
@ -29,7 +29,7 @@ const int POWER_SAMPLE_OVERLOAD_WAIT = 20;
|
||||||
// Number of preamble bits.
|
// Number of preamble bits.
|
||||||
const int PREAMBLE_BITS_MAIN = 16;
|
const int PREAMBLE_BITS_MAIN = 16;
|
||||||
const int PREAMBLE_BITS_PROG = 22;
|
const int PREAMBLE_BITS_PROG = 22;
|
||||||
const byte MAX_PACKET_SIZE = 5; // NMRA standard exrtended packets
|
const byte MAX_PACKET_SIZE = 5; // NMRA standard extended packets, payload size WITHOUT checksum.
|
||||||
|
|
||||||
// The WAVE_STATE enum is deliberately numbered because a change of order would be catastrophic
|
// The WAVE_STATE enum is deliberately numbered because a change of order would be catastrophic
|
||||||
// to the transform array.
|
// to the transform array.
|
||||||
|
@ -119,7 +119,7 @@ class DCCWaveform {
|
||||||
bool isMainTrack;
|
bool isMainTrack;
|
||||||
MotorDriver* motorDriver;
|
MotorDriver* motorDriver;
|
||||||
// Transmission controller
|
// Transmission controller
|
||||||
byte transmitPacket[MAX_PACKET_SIZE]; // packet being transmitted
|
byte transmitPacket[MAX_PACKET_SIZE+1]; // +1 for checksum
|
||||||
byte transmitLength;
|
byte transmitLength;
|
||||||
byte transmitRepeats; // remaining repeats of transmission
|
byte transmitRepeats; // remaining repeats of transmission
|
||||||
byte remainingPreambles;
|
byte remainingPreambles;
|
||||||
|
@ -127,7 +127,7 @@ class DCCWaveform {
|
||||||
byte bits_sent; // 0-8 (yes 9 bits) sent for current byte
|
byte bits_sent; // 0-8 (yes 9 bits) sent for current byte
|
||||||
byte bytes_sent; // number of bytes sent from transmitPacket
|
byte bytes_sent; // number of bytes sent from transmitPacket
|
||||||
WAVE_STATE state; // wave generator state machine
|
WAVE_STATE state; // wave generator state machine
|
||||||
byte pendingPacket[MAX_PACKET_SIZE];
|
byte pendingPacket[MAX_PACKET_SIZE+1]; // +1 for checksum
|
||||||
byte pendingLength;
|
byte pendingLength;
|
||||||
byte pendingRepeats;
|
byte pendingRepeats;
|
||||||
int lastCurrent;
|
int lastCurrent;
|
||||||
|
|
|
@ -3,7 +3,9 @@
|
||||||
|
|
||||||
#include "StringFormatter.h"
|
#include "StringFormatter.h"
|
||||||
|
|
||||||
#define VERSION "3.0.5"
|
#define VERSION "3.0.6"
|
||||||
|
// 3.0.6 Includes:
|
||||||
|
// Fix Bug that did not let us transmit 5 byte sized packets like PoM
|
||||||
// 3.0.5 Includes:
|
// 3.0.5 Includes:
|
||||||
// Fix Fn Key startup with loco ID and fix state change for F16-28
|
// Fix Fn Key startup with loco ID and fix state change for F16-28
|
||||||
// 3.0.4 Includes:
|
// 3.0.4 Includes:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user