Skip to content

Commit

Permalink
Removing, for now, BREAK-less packet support. It doesn't feel like it…
Browse files Browse the repository at this point in the history
… should go in this release but it might end up in a future one.
  • Loading branch information
ssilverman committed May 14, 2019
1 parent cac383d commit f6f1397
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 77 deletions.
10 changes: 0 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@ Some notable features of this library:
API. Alternate start codes can not only be handled, for example, for Text
Packets or System Information Packets (SIP), but responses can be sent back
to the transmitter, for example for RDM.
9. The receiver can, if configured to do so, handle BREAK-less packets. That is,
packets that don't start with a BREAK character. This is useful for receiving
RDM discovery response packets.

### Limitations

Expand Down Expand Up @@ -289,13 +286,6 @@ processing results when ready.
A more complete example is beyond the scope of this README.
### Receiving BREAK-less packets
Protocols such as RDM require listening for packets that don't start with a
BREAK character. The receiver can be configured to receive these packets by
calling `Receiver::setAllowBreaklessPackets`. See also
`Receiver::allowBreaklessPackets` to determine whether this mode is enabled.
## DMX transmit
### Code example
Expand Down
43 changes: 0 additions & 43 deletions src/Receiver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,6 @@ Receiver::Receiver(HardwareSerial &uart)
: TeensyDMX(uart),
began_(false),
state_{RecvStates::kIdle},
allowBreaklessPackets_(false),
breaklessStartTime_(0),
buf1_{0},
buf2_{0},
activeBuf_(buf1_),
Expand Down Expand Up @@ -479,18 +477,6 @@ void Receiver::completePacket() {
}

void Receiver::checkPacketTimeout() {
// Breakless packets
if (state_ == RecvStates::kBreaklessData) {
uint32_t t = micros();
if ((t - breaklessStartTime_) > kMaxBreaklessPacketTime ||
(t - lastSlotEndTime_) > kMaxBreaklessIdleTime) {
// Don't count as a timeout because that's how we detect end-of-packet
// for breakless packets
completePacket();
}
return;
}

if (state_ != RecvStates::kData) {
return;
}
Expand Down Expand Up @@ -588,35 +574,6 @@ void Receiver::receiveByte(uint8_t b) {
break;

case RecvStates::kIdle:
if (allowBreaklessPackets_) {
// First byte: Set packet start time
breaklessStartTime_ = eopTime - 44;
activeBufIndex_ = 0;
lastSlotEndTime_ = eopTime;
activeBuf_[activeBufIndex_++] = b;
if (activeBufIndex_ == kMaxDMXPacketSize) {
completePacket();
state_ = RecvStates::kSkipBreaklessData;
} else {
state_ = RecvStates::kBreaklessData;
}
}
return;

case RecvStates::kBreaklessData:
lastSlotEndTime_ = eopTime;
if ((eopTime - breaklessStartTime_) > kMaxBreaklessPacketTime) {
// Don't count as a timeout because that's how we detect end-of-packet
// for breakless packets
completePacket();
state_ = RecvStates::kSkipBreaklessData;
} else {
activeBuf_[activeBufIndex_++] = b;
if (activeBufIndex_ == kMaxDMXPacketSize) {
completePacket();
state_ = RecvStates::kSkipBreaklessData;
}
}
return;

default:
Expand Down
24 changes: 0 additions & 24 deletions src/TeensyDMX.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,18 +137,6 @@ class Receiver final : public TeensyDMX {

void end() override;

// Sets the receiver to allow BREAK-less packets. This supports RDM's
// discovery responses. By default, the maximum packet time is the same as for
// DMX and the maximum inter-slot idle time is 2.0ms.
void setAllowBreaklessPackets(bool flag) {
allowBreaklessPackets_ = flag;
}

// Returns whether the receiver allows BREAK-less packets.
bool allowBreaklessPackets() const {
return allowBreaklessPackets_;
}

// Reads all or part of the latest packet into buf. This returns zero if len
// is negative or zero, or if startChannel is negative or beyond
// kMaxDMXPacketSize. This only reads up to the end of the packet if
Expand Down Expand Up @@ -268,8 +256,6 @@ class Receiver final : public TeensyDMX {
kMAB, // Mark after break
kData, // Packet data
kIdle, // The end of data for one packet has been reached
kBreaklessData, // Breakless packet data
kSkipBreaklessData, // Skip data beyond the packet length
};

// The maximum allowed packet time for receivers, either BREAK plus data,
Expand All @@ -284,10 +270,6 @@ class Receiver final : public TeensyDMX {
// in microseconds, exclusive.
static constexpr uint32_t kMaxDMXIdleTime = 1000000;

// Breakless packet timeout parameters, RDM Controller timings
static constexpr uint32_t kMaxBreaklessPacketTime = kMaxDMXPacketTime;
static constexpr uint32_t kMaxBreaklessIdleTime = 2100;

// Disables all the UART IRQs so that variables can be accessed concurrently.
// The IRQs are not disabled if began_ is false.
void disableIRQs() const;
Expand Down Expand Up @@ -337,12 +319,6 @@ class Receiver final : public TeensyDMX {
// Keeps track of what we're receiving.
volatile RecvStates state_;

// Whether we allow BREAK-less packet.
volatile bool allowBreaklessPackets_;

// A BREAK-less packet's start time.
uint32_t breaklessStartTime_;

// The framing-error start time, in microseconds. This needs to be accessed
// from the same interrupt that triggered the framing error so that there's
// a guarantee that it doesn't get changed.
Expand Down

0 comments on commit f6f1397

Please sign in to comment.