32#define BUFFER_SIZE 512
44void logBytes(
unsigned char *buf,
int n,
const char *deviceName, uint32_t debugLevel)
47 for (
int i = 0; i < n; i++)
48 sprintf(hex_buffer + 3 * i,
"%02X ", buf[i]);
51 hex_buffer[3 * n - 1] =
'\0';
53 DEBUGFDEVICE(deviceName, debugLevel,
"[%s]", hex_buffer);
62 for (
size_t i = 0; i < m_Data.size(); i++)
63 sprintf(hex_buffer + 3 * i,
"%02X ", m_Data[i]);
65 if (m_Data.size() > 0)
66 hex_buffer[3 * m_Data.size() - 1] =
'\0';
85 snprintf(part3,
BUFFER_SIZE,
"%02x", m_Destination);
87 if (m_Data.size() > 0)
99 for (
size_t i = 0; i < m_Data.size(); i++)
100 sprintf(hex_buffer + 3 * i,
"%02X ", m_Data[i]);
102 if (m_Data.size() > 0)
103 hex_buffer[3 * m_Data.size() - 1] =
'\0';
122 snprintf(part3,
BUFFER_SIZE,
"%02x", m_Destination);
124 if (m_Data.size() > 0)
166 len = 3 + m_Data.size();
178 len = 3 + m_Data.size();
189 return "PORTCTRL_GET_INPUT_POWER";
191 return "PORTCTRL_SET_POWER_ENABLED";
193 return "PORTCTRL_GET_POWER_ENABLED";
195 return "PORTCTRL_SET_EXT_CURRENT_LIMIT";
197 return "PORTCTRL_GET_EXT_CURRENT_LIMIT";
199 return "PORTCTRL_GET_NUMBER_OF_PORTS";
201 return "PORTCTRL_GET_PORT_INFO";
203 return "PORTCTRL_GET_DH_PORT_INFO";
205 return "PORTCTRL_RESET_FUSE";
207 return "PORTCTRL_SET_PORT_ENABLED";
209 return "PORTCTRL_SET_PORT_VOLTAGE";
211 return "PORTCTRL_DH_ENABLE_AUTO";
213 return "PORTCTRL_DH_ENABLE_MANUAL";
215 return "PORTCTRL_GET_ENVIRONMENT";
217 return "PORTCTRL_ENABLE_SELF_HEATER";
219 return "PORTCTRL_SELF_HEATER_STATUS";
221 return "PORTCTRL_GET_HEATER_LEVEL";
223 return "PORTCTRL_FACTORY_RESET";
225 return "PORTCTRL_GET_VERSION";
227 return "PORTCTRL_SET_LED_BRIGHTNESS";
229 return "PORTCTRL_GET_LED_BRIGHTNESS";
231 return "PORTCTRL_NAK";
301 return "DEW_POWER_CTRL";
317 buf[3] = m_Destination;
319 for (uint32_t i = 0; i < m_Data.size(); i++)
321 buf[i + 5] = m_Data[i];
335 m_Data =
AUXBuffer(buf.begin() + 5, buf.end() - 1);
336 valid = (
checksum(buf) == buf.back());
355 m_Data =
AUXBuffer(buf.begin() + 5, buf.end());
365 for (
int i = 1; i < l + 2; i++)
369 return (
unsigned char)(((~cs) + 1) & 0xFF);
378 switch (m_Data.size())
381 value = (m_Data[0] << 16) | (m_Data[1] << 8) | m_Data[2];
385 value = (m_Data[0] << 8) | m_Data[1];
401 m_Data.resize(bytes);
406 m_Data[0] =
static_cast<uint8_t
>(value >> 0 & 0xff);
410 m_Data[1] =
static_cast<uint8_t
>(value >> 0 & 0xff);
411 m_Data[0] =
static_cast<uint8_t
>(value >> 8 & 0xff);
417 m_Data[2] =
static_cast<uint8_t
>(value >> 0 & 0xff);
418 m_Data[1] =
static_cast<uint8_t
>(value >> 8 & 0xff);
419 m_Data[0] =
static_cast<uint8_t
>(value >> 16 & 0xff);
void logBytes(unsigned char *buf, int n, const char *deviceName, uint32_t debugLevel)
std::vector< uint8_t > AUXBuffer
@ PORTCTRL_SET_LED_BRIGHTNESS
@ PORTCTRL_GET_HEATER_LEVEL
@ PORTCTRL_SET_PORT_VOLTAGE
@ PORTCTRL_SET_PORT_ENABLED
@ PORTCTRL_DH_ENABLE_MANUAL
@ PORTCTRL_GET_NUMBER_OF_PORTS
@ PORTCTRL_DH_ENABLE_AUTO
@ PORTCTRL_ENABLE_SELF_HEATER
@ PORTCTRL_GET_DH_PORT_INFO
@ PORTCTRL_SET_EXT_CURRENT_LIMIT
@ PORTCTRL_GET_LED_BRIGHTNESS
@ PORTCTRL_GET_EXT_CURRENT_LIMIT
@ PORTCTRL_GET_ENVIRONMENT
@ PORTCTRL_SET_POWER_ENABLED
@ PORTCTRL_GET_POWER_ENABLED
@ PORTCTRL_SELF_HEATER_STATUS
@ PORTCTRL_GET_INPUT_POWER
AUXCommands command() const
uint8_t checksum(AUXBuffer buf)
Check sum.
uint32_t getData()
Set and Get data.
const char * commandName() const
void parseBuf(AUXBuffer buf)
const char * moduleName(AUXTargets n)
const AUXTargets & source() const
Getters.
static uint8_t DEBUG_LEVEL
const AUXBuffer & data() const
static char DEVICE_NAME[64]
static void setDebugInfo(const char *deviceName, uint8_t debugLevel)
void fillBuf(AUXBuffer &buf)
Buffer Management.
void setData(uint32_t value, uint8_t bytes=3)
Set encoder position in steps.
const AUXTargets & destination() const
#define DEBUGFDEVICE(device, priority, msg,...)