Skip to content

Commit

Permalink
Merge 0fb641a into 2779984
Browse files Browse the repository at this point in the history
  • Loading branch information
peternewman committed Dec 12, 2014
2 parents 2779984 + 0fb641a commit 0442268
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 32 deletions.
1 change: 1 addition & 0 deletions common/utils/StringUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,7 @@ void CapitalizeLabel(string *s) {
for (string::iterator iter = s->begin(); iter != s->end(); ++iter) {
switch (*iter) {
case '-':
// fall through, also convert to space
case '_':
*iter = ' ';
case ' ':
Expand Down
1 change: 1 addition & 0 deletions examples/ola-dmxconsole.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,7 @@ void changepalette(int p) {
switch (p) {
default:
palette_number = 0;
// fall through, use 0 as default palette
case 0:
init_pair(CHANNEL, COLOR_BLACK, COLOR_CYAN);
init_pair(ZERO, COLOR_BLACK, COLOR_WHITE);
Expand Down
1 change: 1 addition & 0 deletions examples/ola-dmxmonitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,7 @@ void DmxMonitor::ChangePalette(int p) {
switch (p) {
default:
m_palette_number = 0;
// fall through, use 0 as default palette
case 0:
init_pair(CHANNEL, COLOR_BLACK, COLOR_CYAN);
init_pair(ZERO, COLOR_BLACK, COLOR_WHITE);
Expand Down
5 changes: 3 additions & 2 deletions examples/ola-rdm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include <ola/Logging.h>
#include <ola/OlaCallbackClient.h>
#include <ola/OlaClientWrapper.h>
#include <ola/StringUtils.h>
#include <ola/base/Init.h>
#include <ola/base/SysExits.h>
#include <ola/file/Util.h>
Expand Down Expand Up @@ -308,8 +309,8 @@ void RDMController::HandleResponse(
cout << "Request NACKed: " <<
ola::rdm::NackReasonToString(response_status.NackReason()) << endl;
} else {
cout << "Unknown RDM response type " << std::hex <<
static_cast<int>(response_status.response_type) << endl;
cout << "Unknown RDM response type "
<< ola::IntToHexString(response_status.response_type) << endl;
}
PrintRemainingMessages(response_status.message_count);
m_ola_client.GetSelectServer()->Terminate();
Expand Down
4 changes: 2 additions & 2 deletions plugins/pathport/PathportPort.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ class PathportOutputPort: public BasicOutputPort {
return m_helper.Description(GetUniverse());
}
bool WriteDMX(const DmxBuffer &buffer, uint8_t priority);
bool PreSetUniverse(Universe *old_universe, Universe *new_universe) {
bool PreSetUniverse(OLA_UNUSED Universe *old_universe,
Universe *new_universe) {
return m_helper.PreSetUniverse(new_universe);
(void) old_universe;
}

private:
Expand Down
65 changes: 37 additions & 28 deletions tools/rdmpro/rdm-sniffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include <ola/Constants.h>
#include <ola/Clock.h>
#include <ola/Logging.h>
#include <ola/StringUtils.h>
#include <ola/base/Flags.h>
#include <ola/base/Init.h>
#include <ola/base/SysExits.h>
Expand Down Expand Up @@ -52,6 +53,7 @@ using std::cout;
using std::endl;
using std::string;
using std::vector;
using ola::IntToHexString;
using ola::io::SelectServerInterface;
using ola::plugin::usbpro::DispatchingUsbProWidget;
using ola::messaging::Descriptor;
Expand Down Expand Up @@ -173,8 +175,9 @@ RDMSniffer::RDMSniffer(const RDMSnifferOptions &options)
m_options(options),
m_pid_helper(options.pid_location, 4),
m_command_printer(&cout, &m_pid_helper) {
if (!m_pid_helper.Init())
if (!m_pid_helper.Init()) {
OLA_WARN << "Failed to init PidStore";
}
}


Expand Down Expand Up @@ -235,9 +238,9 @@ void RDMSniffer::ProcessTuple(uint8_t control_byte, uint8_t data_byte) {
m_frame.AddByte(data_byte);
break;
default:
OLA_WARN << "Unknown transition from state " << m_state <<
", with data 0x" << std::hex << static_cast<int>(control_byte) <<
" 0x" << static_cast<int>(data_byte);
OLA_WARN << "Unknown transition from state " << m_state
<< ", with data " << IntToHexString(control_byte) << " "
<< IntToHexString(data_byte);
}
} else {
// control byte
Expand All @@ -247,9 +250,9 @@ void RDMSniffer::ProcessTuple(uint8_t control_byte, uint8_t data_byte) {
m_state = MAB;
break;
default:
OLA_WARN << "Unknown transition from state " << m_state <<
", with data 0x" << std::hex << static_cast<int>(control_byte) <<
" 0x" << static_cast<int>(data_byte);
OLA_WARN << "Unknown transition from state " << m_state
<< ", with data " << IntToHexString(control_byte) << " "
<< IntToHexString(data_byte);
}
} else if (data_byte == 1) {
switch (m_state) {
Expand All @@ -261,9 +264,9 @@ void RDMSniffer::ProcessTuple(uint8_t control_byte, uint8_t data_byte) {
m_state = BREAK;
break;
default:
OLA_WARN << "Unknown transition from state " << m_state <<
", with data 0x" << std::hex << static_cast<int>(control_byte) <<
" 0x" << static_cast<int>(data_byte);
OLA_WARN << "Unknown transition from state " << m_state
<< ", with data " << IntToHexString(control_byte) << " "
<< IntToHexString(data_byte);
}
} else if (data_byte == 2) {
switch (m_state) {
Expand All @@ -276,9 +279,9 @@ void RDMSniffer::ProcessTuple(uint8_t control_byte, uint8_t data_byte) {
ProcessFrame();
}
} else {
OLA_WARN << "Unknown transition from state " << m_state <<
", with data 0x" << std::hex << static_cast<int>(control_byte) <<
" 0x" << static_cast<int>(data_byte);
OLA_WARN << "Unknown transition from state " << m_state
<< ", with data " << IntToHexString(control_byte) << " "
<< IntToHexString(data_byte);
}
}
}
Expand All @@ -290,15 +293,17 @@ void RDMSniffer::ProcessTuple(uint8_t control_byte, uint8_t data_byte) {
void RDMSniffer::ProcessFrame() {
switch (m_frame[0]) {
case ola::DMX512_START_CODE:
if (m_options.display_dmx_frames)
if (m_options.display_dmx_frames) {
DisplayDmxFrame();
}
break;
case RDMCommand::START_CODE:
DisplayRDMFrame();
break;
default:
if (m_options.display_non_rdm_asc_frames)
if (m_options.display_non_rdm_asc_frames) {
DisplayAlternateFrame();
}
}
}

Expand All @@ -310,8 +315,9 @@ void RDMSniffer::DisplayDmxFrame() {
unsigned int dmx_slot_count = m_frame.Size() - 1;
MaybePrintTimestamp();
cout << "DMX " << std::dec;
if (m_options.dmx_slot_limit < dmx_slot_count)
if (m_options.dmx_slot_limit < dmx_slot_count) {
cout << m_options.dmx_slot_limit << "/";
}
cout << dmx_slot_count << ":" << std::hex;
unsigned int slots_to_display = std::min(
dmx_slot_count,
Expand All @@ -327,8 +333,8 @@ void RDMSniffer::DisplayDmxFrame() {
void RDMSniffer::DisplayAlternateFrame() {
unsigned int slot_count = m_frame.Size() - 1;
MaybePrintTimestamp();
cout << "SC 0x" << std::hex << std::setw(2) << static_cast<int>(m_frame[0])
<< " " << std::dec << slot_count << ":" << std::hex;
cout << "SC " << IntToHexString(m_frame[0])
<< " " << slot_count << ":" << std::hex;
unsigned int slots_to_display = std::min(
slot_count,
static_cast<unsigned int>(m_options.dmx_slot_limit));
Expand All @@ -346,11 +352,13 @@ void RDMSniffer::DisplayRDMFrame() {
RDMCommand::Inflate(reinterpret_cast<const uint8_t*>(&m_frame[1]),
slot_count));
if (command.get()) {
if (!m_options.summarize_rdm_frames)
if (!m_options.summarize_rdm_frames) {
cout << "---------------------------------------" << endl;
}

if (!m_options.summarize_rdm_frames && m_options.timestamp)
if (!m_options.summarize_rdm_frames && m_options.timestamp) {
cout << endl;
}

MaybePrintTimestamp();

Expand All @@ -367,8 +375,9 @@ void RDMSniffer::DisplayRDMFrame() {
* Dump out the raw data if we couldn't parse it correctly.
*/
void RDMSniffer::DisplayRawData(unsigned int start, unsigned int end) {
for (unsigned int i = start; i <= end; i++)
for (unsigned int i = start; i <= end; i++) {
cout << std::hex << std::setw(2) << static_cast<int>(m_frame[i]) << " ";
}
cout << endl;
}

Expand All @@ -377,8 +386,9 @@ void RDMSniffer::DisplayRawData(unsigned int start, unsigned int end) {
* Print the timestamp if timestamps are enabled
*/
void RDMSniffer::MaybePrintTimestamp() {
if (!m_options.timestamp)
if (!m_options.timestamp) {
return;
}

ola::TimeStamp now;
ola::Clock clock;
Expand Down Expand Up @@ -443,8 +453,7 @@ int main(int argc, char *argv[]) {
"Sniff traffic from a ENTTEC RDM Pro device.");

if (!FLAGS_savefile.str().empty() && !FLAGS_readfile.str().empty()) {
ola::DisplayUsage();
exit(ola::EXIT_USAGE);
ola::DisplayUsageAndExit();
}

RDMSniffer::RDMSnifferOptions sniffer_options;
Expand All @@ -463,7 +472,7 @@ int main(int argc, char *argv[]) {
std::ios::out | std::ios::binary);
if (!file.is_open()) {
cerr << "Could not open file for writing: " << sniffer_options.write_file
<< endl;
<< endl;
exit(ola::EXIT_UNAVAILABLE);
}
}
Expand All @@ -475,16 +484,16 @@ int main(int argc, char *argv[]) {
}

if (argc != 2) {
ola::DisplayUsage();
exit(ola::EXIT_USAGE);
ola::DisplayUsageAndExit();
}

const string device = argv[1];

ola::io::ConnectedDescriptor *descriptor =
ola::plugin::usbpro::BaseUsbProWidget::OpenDevice(device);
if (!descriptor)
if (!descriptor) {
exit(ola::EXIT_UNAVAILABLE);
}

ola::io::SelectServer ss;
descriptor->SetOnClose(ola::NewSingleCallback(&Stop, &ss));
Expand Down

0 comments on commit 0442268

Please sign in to comment.