Debugging Streams
The base Slave class can serve as a passive debug
receiver for stream traffic. This is often the simplest way to inspect a stream
without writing a custom Slave implementation.
You typically use a debug Slave during bring-up, when verifying a new
connection path, when checking that channel and error fields look correct, or
when you need to see the first few payload bytes of each incoming Frame.
Most of the time the debug Slave is attached as a secondary Slave so it
observes traffic without disturbing the primary processing path.
Debug Behavior
Enable debug printing with setDebug(maxBytes, name) on a base Slave.
maxBytescontrols how many payload bytes are shown for each receivedFramenamecontrols the logger name suffix used for emitted messages
Python Example
import rogue.interfaces.stream as ris
# Data source
src = MyCustomMaster()
# Data destination
dst = MyCustomSlave()
# Debug Slave
dbg = ris.Slave()
# Print up to the first 100 bytes of each received Frame
dbg.setDebug(100, 'myDebug')
# Primary path
src >> dst
# Add the debug Slave as a second receiver
src >> dbg
C++ Example
#include "rogue/Helpers.h"
#include "rogue/interfaces/stream/Slave.h"
#include "MyCustomMaster.h"
#include "MyCustomSlave.h"
int main() {
// Data source
auto src = MyCustomMaster::create();
// Data destination
auto dst = MyCustomSlave::create();
// Debug Slave
auto dbg = rogue::interfaces::stream::Slave::create();
// Print up to the first 100 bytes of each received Frame
dbg->setDebug(100, "myDebug");
// Primary path
rogueStreamConnect(src, dst);
// Add the debug Slave as a second receiver
rogueStreamConnect(src, dbg);
return 0;
}
Logging
setDebug(maxBytes, name) uses Rogue C++ logging, not Python logging.
The emitted logger name is pyrogue.<name>.
For example, dbg.setDebug(100, 'stream.debug') emits through
pyrogue.stream.debug. Enable that logger before using the debug Slave:
import rogue
import rogue.interfaces.stream as ris
rogue.Logging.setFilter('pyrogue.stream.debug', rogue.Logging.Debug)
dbg = ris.Slave()
dbg.setDebug(100, 'stream.debug')
The helper creates the logger when debug mode is enabled, so it is best to set the filter first.
Debugging Notes
The base
Slavedebug path increments internal frame and byte counters.The logger name is determined entirely by the
nameargument passed tosetDebug(...).If a custom C++
SlaveoverridesacceptFrameand still wants the base debug and counter behavior, it should callSlave::acceptFrame(frame)or implement equivalent logic explicitly.
What To Explore Next
Connection placement rules: Connecting Streams
Receive-side handling: Receiving Frames
Fifotap patterns: FIFO BufferingRateDropsampling patterns: Rate Limiting With RateDrop