Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion common/base/SysExits.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
#define EX_NOHOST 68 /**< @brief host name unknown */
#define EX_UNAVAILABLE 69 /**< @brief service unavailable */
#define EX_SOFTWARE 70 /**< @brief internal software error */
#define EX_OSERR 71 /**< @brief system error (e.g., can't fork) */
#define EX_OSERR 71 /**< @brief system error (e.g. can't fork) */
#define EX_OSFILE 72 /**< @brief critical OS file missing */
#define EX_CANTCREAT 73 /**< @brief can't create (user) output file */
#define EX_IOERR 74 /**< @brief input/output error */
Expand Down
71 changes: 37 additions & 34 deletions common/rdm/RDMCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,15 +111,15 @@ RDMCommand::~RDMCommand() {

string RDMCommand::ToString() const {
std::ostringstream str;
str << m_source << " -> " << m_destination << ", Trans # " <<
static_cast<int>(m_transaction_number) << ", Port ID " <<
static_cast<int>(m_port_id) << ", Msg Cnt " <<
static_cast<int>(m_message_count) << ", SubDevice " << m_sub_device
<< ", Cmd Class " << CommandClass() << ", Param ID " << m_param_id
<< ", Data Len " << m_data_length;
str << m_source << " -> " << m_destination << ", Trans # "
<< static_cast<int>(m_transaction_number) << ", Port ID "
<< static_cast<int>(m_port_id) << ", Msg Cnt "
<< static_cast<int>(m_message_count) << ", SubDevice " << m_sub_device
<< ", Cmd Class " << CommandClass() << ", Param ID " << m_param_id
<< ", Data Len " << m_data_length;
str << ", Data ";
for (unsigned int i = 0 ; i < m_data_length; i++) {
str << std::hex << std::setw(2) << static_cast<int>(m_data[i]) << " ";
str << ToHex(m_data[i], false) << " ";
}
return str.str();
}
Expand Down Expand Up @@ -171,8 +171,9 @@ uint8_t RDMCommand::MessageLength() const {
void RDMCommand::SetParamData(const uint8_t *data, unsigned int length) {
m_data_length = length;
if (m_data_length > 0 && data != NULL) {
if (m_data)
if (m_data) {
delete[] m_data;
}

m_data = new uint8_t[m_data_length];
memcpy(m_data, data, m_data_length);
Expand All @@ -192,8 +193,8 @@ RDMStatusCode RDMCommand::VerifyData(const uint8_t *data,
size_t length,
RDMCommandHeader *command_header) {
if (length < sizeof(RDMCommandHeader)) {
OLA_WARN << "RDM message is too small, needs to be at least " <<
sizeof(RDMCommandHeader) << ", was " << length;
OLA_WARN << "RDM message is too small, needs to be at least "
<< sizeof(RDMCommandHeader) << ", was " << length;
return RDM_PACKET_TOO_SHORT;
}

Expand All @@ -207,35 +208,35 @@ RDMStatusCode RDMCommand::VerifyData(const uint8_t *data,
sizeof(*command_header));

if (command_header->sub_start_code != SUB_START_CODE) {
OLA_WARN << "Sub start code mis match, was 0x" << std::hex <<
static_cast<int>(command_header->sub_start_code) << ", required 0x"
<< static_cast<int>(SUB_START_CODE);
OLA_WARN << "Sub start code mis match, was "
<< ToHex(command_header->sub_start_code) << ", required "
<< ToHex(SUB_START_CODE);
return RDM_WRONG_SUB_START_CODE;
}

unsigned int message_length = command_header->message_length;
if (length < message_length + 1) {
OLA_WARN << "RDM message is too small, needs to be " <<
message_length + 1 << ", was " << length;
OLA_WARN << "RDM message is too small, needs to be "
<< message_length + 1 << ", was " << length;
return RDM_PACKET_LENGTH_MISMATCH;
}

uint16_t checksum = CalculateChecksum(data, message_length - 1);
uint16_t actual_checksum = (data[message_length - 1] << 8) +
data[message_length];
uint16_t actual_checksum = JoinUInt8(data[message_length - 1],
data[message_length]);

if (actual_checksum != checksum) {
OLA_WARN << "RDM checksum mismatch, was " << actual_checksum <<
" but was supposed to be " << checksum;
OLA_WARN << "RDM checksum mismatch, was " << actual_checksum
<< " but was supposed to be " << checksum;
return RDM_CHECKSUM_INCORRECT;
}

// check param length is valid here
unsigned int block_size = length - sizeof(RDMCommandHeader) - 2;
if (command_header->param_data_length > block_size) {
OLA_WARN << "Param length " <<
static_cast<int>(command_header->param_data_length) <<
" exceeds remaining RDM message size of " << block_size;
OLA_WARN << "Param length "
<< static_cast<int>(command_header->param_data_length)
<< " exceeds remaining RDM message size of " << block_size;
return RDM_PARAM_LENGTH_MISMATCH;
}
return RDM_COMPLETED_OK;
Expand All @@ -248,8 +249,9 @@ RDMStatusCode RDMCommand::VerifyData(const uint8_t *data,
uint16_t RDMCommand::CalculateChecksum(const uint8_t *data,
unsigned int packet_length) {
unsigned int checksum_value = START_CODE;
for (unsigned int i = 0; i < packet_length; i++)
for (unsigned int i = 0; i < packet_length; i++) {
checksum_value += data[i];
}
return static_cast<uint16_t>(checksum_value);
}

Expand Down Expand Up @@ -387,8 +389,8 @@ RDMResponse* RDMResponse::InflateFromData(const uint8_t *data,

UID source_uid(command_message.source_uid);
UID destination_uid(command_message.destination_uid);
uint16_t sub_device = ((command_message.sub_device[0] << 8) +
command_message.sub_device[1]);
uint16_t sub_device = JoinUInt8(command_message.sub_device[0],
command_message.sub_device[1]);
RDMCommandClass command_class = ConvertCommandClass(
command_message.command_class);

Expand Down Expand Up @@ -520,7 +522,7 @@ RDMResponse* RDMResponse::CombineResponses(const RDMResponse *response1,
// do some sort of checking
if (combined_length > MAX_OVERFLOW_SIZE) {
OLA_WARN << "ACK_OVERFLOW buffer size hit! Limit is " << MAX_OVERFLOW_SIZE
<< ", request size is " << combined_length;
<< ", request size is " << combined_length;
return NULL;
} else if (response1->SourceUID() != response2->SourceUID()) {
OLA_WARN << "Source UIDs don't match";
Expand Down Expand Up @@ -559,8 +561,8 @@ RDMResponse* RDMResponse::CombineResponses(const RDMResponse *response1,
combined_data,
combined_length);
} else {
OLA_WARN << "Expected a RDM request command but got " <<
std::hex << response1->CommandClass();
OLA_WARN << "Expected a RDM request command but got "
<< ToHex(response1->CommandClass());
}
delete[] combined_data;
return response;
Expand Down Expand Up @@ -754,16 +756,17 @@ RDMDiscoveryResponse* RDMDiscoveryResponse::InflateFromData(
unsigned int length) {
RDMCommandHeader command_message;
RDMStatusCode code = VerifyData(data, length, &command_message);
if (code != RDM_COMPLETED_OK)
if (code != RDM_COMPLETED_OK) {
return NULL;
}

uint16_t sub_device = ((command_message.sub_device[0] << 8) +
command_message.sub_device[1]);
uint16_t param_id = ((command_message.param_id[0] << 8) +
command_message.param_id[1]);
uint16_t sub_device = JoinUInt8(command_message.sub_device[0],
command_message.sub_device[1]);
uint16_t param_id = JoinUInt8(command_message.param_id[0],
command_message.param_id[1]);

RDMCommandClass command_class = ConvertCommandClass(
command_message.command_class);
command_message.command_class);

if (command_class == DISCOVER_COMMAND_RESPONSE) {
return new RDMDiscoveryResponse(
Expand Down
21 changes: 15 additions & 6 deletions doxygen/namespaces.dox
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
* @namespace ola::e133
* @brief E1.33 (RDMNet)
*
* @namespace ola::file
* @brief File helper functions.
*
* @namespace ola::io
* @brief Classes for general I/O and event handling.
*
Expand Down Expand Up @@ -95,9 +98,6 @@
* @namespace ola::plugin::usbdmx
* @brief The plugin for hardware using libusb.
*
* @namespace ola::plugin::usbdmx::jarule
* @brief Ja Rule code.
*
* @namespace ola::plugin::usbpro
* @brief Code for Enttec USB Pro devices and others using the same protocol.
*
Expand All @@ -110,6 +110,12 @@
* @namespace ola::stl
* @brief STL Helper functions.
*
* @namespace ola::strings
* @brief String helper and formatting functions.
*
* @namespace ola::system
* @brief System helper functions (Load Average).
*
* @namespace ola::testing
* @brief Code used for unit testing.
*
Expand All @@ -119,9 +125,12 @@
* @namespace ola::timecode
* @brief Timecode
*
* @namespace ola::usb
* @brief USB %device drivers.
*
* @namespace ola::utils
* @brief General numeric helper functions.
*
* @namespace ola::web
* @brief Classes to deal with web services.
*
* @namespace ola::usb
* @brief USB Device drivers.
*/
2 changes: 1 addition & 1 deletion include/ola/base/SysExits.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
/**
* @defgroup sysexit System Exit Values
* @brief Exit codes
* @details Some platforms (android) don't provide sysexits.h. To work around
* @details Some platforms (Android) don't provide sysexits.h. To work around
* this we define our own exit codes, which use the system values if provided
* or otherwise our default values.
*/
Expand Down
4 changes: 4 additions & 0 deletions plugins/spi/SPIDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ SPIDevice::SPIDevice(SPIPlugin *owner,
m_spi_device_name(spi_device) {
m_spi_device_name = ola::file::FilenameFromPathOrPath(m_spi_device_name);

ostringstream str;
str << SPI_DEVICE_NAME << " " << m_spi_device_name;
SetName(str.str());

SetDefaults();
unsigned int port_count = 0;

Expand Down
18 changes: 11 additions & 7 deletions plugins/spi/SPIOutput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,7 @@ bool SPIOutput::SetStartAddress(uint16_t address) {

string SPIOutput::Description() const {
std::ostringstream str;
str << m_spi_device_name << ", output "
<< static_cast<int>(m_output_number) << ", "
str << "Output " << static_cast<int>(m_output_number) << ", "
<< m_personality_manager->ActivePersonalityDescription() << ", "
<< m_personality_manager->ActivePersonalityFootprint()
<< " slots @ " << m_start_address << ". (" << m_uid << ")";
Expand All @@ -263,8 +262,9 @@ string SPIOutput::Description() const {
* Send DMX data over SPI.
*/
bool SPIOutput::WriteDMX(const DmxBuffer &buffer) {
if (m_identify_mode)
if (m_identify_mode) {
return true;
}
return InternalWriteDMX(buffer);
}

Expand Down Expand Up @@ -327,8 +327,9 @@ void SPIOutput::IndividualWS2801Control(const DmxBuffer &buffer) {
// for part of it
const unsigned int output_length = m_pixel_count * LPD8806_SLOTS_PER_PIXEL;
uint8_t *output = m_backend->Checkout(m_output_number, output_length);
if (!output)
if (!output) {
return;
}

unsigned int new_length = output_length;
buffer.GetRange(m_start_address - 1, output, &new_length);
Expand All @@ -347,8 +348,9 @@ void SPIOutput::CombinedWS2801Control(const DmxBuffer &buffer) {

const unsigned int length = m_pixel_count * WS2801_SLOTS_PER_PIXEL;
uint8_t *output = m_backend->Checkout(m_output_number, length);
if (!output)
if (!output) {
return;
}

for (unsigned int i = 0; i < m_pixel_count; i++) {
memcpy(output + (i * WS2801_SLOTS_PER_PIXEL), pixel_data,
Expand Down Expand Up @@ -435,8 +437,9 @@ void SPIOutput::IndividualP9813Control(const DmxBuffer &buffer) {
uint8_t *output = m_backend->Checkout(m_output_number, output_length,
latch_bytes);

if (!output)
if (!output) {
return;
}

for (unsigned int i = 0; i < m_pixel_count; i++) {
// Convert RGB to P9813 Pixel
Expand Down Expand Up @@ -479,8 +482,9 @@ void SPIOutput::CombinedP9813Control(const DmxBuffer &buffer) {

const unsigned int length = m_pixel_count * P9813_SPI_BYTES_PER_PIXEL;
uint8_t *output = m_backend->Checkout(m_output_number, length, latch_bytes);
if (!output)
if (!output) {
return;
}

for (unsigned int i = 0; i < m_pixel_count; i++) {
memcpy(&output[(i + 1) * P9813_SPI_BYTES_PER_PIXEL], pixel_data,
Expand Down
6 changes: 3 additions & 3 deletions plugins/spi/SPIOutputTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,21 +88,21 @@ void SPIOutputTest::testDescription() {
SPIOutput output2(m_uid, &backend, options);

OLA_ASSERT_EQ(
string("test, output 0, WS2801 Individual Control, 75 slots @ 1."
string("Output 0, WS2801 Individual Control, 75 slots @ 1."
" (707a:00000000)"),
output1.Description());
OLA_ASSERT_EQ(static_cast<uint16_t>(1), output1.GetStartAddress());
OLA_ASSERT_EQ(static_cast<uint8_t>(1), output1.GetPersonality());
OLA_ASSERT_EQ(
string("test, output 1, WS2801 Individual Control, 96 slots @ 1."
string("Output 1, WS2801 Individual Control, 96 slots @ 1."
" (707a:00000000)"),
output2.Description());

// change the start address & personality
output1.SetStartAddress(10);
output1.SetPersonality(3);
OLA_ASSERT_EQ(
string("test, output 0, LPD8806 Individual Control, 75 slots @ 10."
string("Output 0, LPD8806 Individual Control, 75 slots @ 10."
" (707a:00000000)"),
output1.Description());
OLA_ASSERT_EQ(static_cast<uint16_t>(10), output1.GetStartAddress());
Expand Down
10 changes: 6 additions & 4 deletions plugins/usbpro/UsbProDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,9 @@ UsbProDevice::UsbProDevice(ola::PluginAdaptor *plugin_adaptor,
m_pro_widget(widget),
m_serial(SerialToString(serial)) {
ostringstream str;
str << "Serial #: " << m_serial << ", firmware "
str << name << ", Serial #: " << m_serial << ", firmware "
<< (firmware_version >> 8) << "." << (firmware_version & 0xff);
SetName(str.str());

for (unsigned int i = 0; i < widget->PortCount(); i++) {
EnttecPort *enttec_port = widget->GetPort(i);
Expand All @@ -71,14 +72,14 @@ UsbProDevice::UsbProDevice(ola::PluginAdaptor *plugin_adaptor,
}

UsbProInputPort *input_port = new UsbProInputPort(
this, enttec_port, i, plugin_adaptor, str.str());
this, enttec_port, i, plugin_adaptor);
enttec_port->SetDMXCallback(
NewCallback(static_cast<InputPort*>(input_port),
&InputPort::DmxChanged));
AddPort(input_port);

OutputPort *output_port = new UsbProOutputPort(
this, enttec_port, i, str.str(),
this, enttec_port, i, "",
plugin_adaptor->WakeUpTime(),
5, // allow up to 5 burst frames
fps_limit); // 200 frames per second seems to be the limit
Expand Down Expand Up @@ -140,8 +141,9 @@ void UsbProDevice::Configure(RpcController *controller,
*/
void UsbProDevice::UpdateParams(unsigned int port_id, bool status,
const usb_pro_parameters &params) {
if (port_id >= m_port_params.size())
if (port_id >= m_port_params.size()) {
return;
}

if (status) {
PortParams &port_params = m_port_params[port_id];
Expand Down
10 changes: 6 additions & 4 deletions plugins/usbpro/UsbProDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ class UsbProInputPort: public BasicInputPort {
EnttecPort *port,
unsigned int id,
ola::PluginAdaptor *plugin_adaptor,
const std::string &description)
const std::string &description = "")
: BasicInputPort(parent, id, plugin_adaptor),
m_description(description),
m_port(port) {}
Expand Down Expand Up @@ -156,16 +156,18 @@ class UsbProOutputPort: public BasicOutputPort {
m_wake_time(wake_time) {}

bool WriteDMX(const DmxBuffer &buffer, uint8_t) {
if (m_bucket.GetToken(*m_wake_time))
if (m_bucket.GetToken(*m_wake_time)) {
return m_port->SendDMX(buffer);
else
} else {
OLA_INFO << "Port rated limited, dropping frame";
}
return true;
}

void PostSetUniverse(Universe*, Universe *new_universe) {
if (!new_universe)
if (!new_universe) {
m_port->ChangeToReceiveMode(false);
}
}

void SendRDMRequest(ola::rdm::RDMRequest *request,
Expand Down