diff options
Diffstat (limited to 'indi-celestronaux/auxproto.cpp')
-rw-r--r-- | indi-celestronaux/auxproto.cpp | 71 |
1 files changed, 54 insertions, 17 deletions
diff --git a/indi-celestronaux/auxproto.cpp b/indi-celestronaux/auxproto.cpp index 0ba7a92..eca66a5 100644 --- a/indi-celestronaux/auxproto.cpp +++ b/indi-celestronaux/auxproto.cpp @@ -211,6 +211,32 @@ const char * AUXCommand::commandName(AUXCommands command) const return nullptr; } } + else if (m_Source == HEATER_17 || m_Destination == HEATER_17 || m_Source ==HEATER_BB || m_Destination==HEATER_BB) + { + switch (command) + { + case HEATER_GET_INPUT: + return "HEATER_GET_INPUT"; + case HEATER_GET_NPORTS: + return "HEATER_GET_NPORTS"; + case HEATER_GET_PORT_TYPE: + return "HEATER_GET_PORT_TYPE"; + case HEATER_GET_AMBIENT: + return "HEATER_GET_AMBIENT"; + case HEATER_SET_AGRESSIVENESS: + return "HEATER_SET_AGRESSIVENESS"; + case HEATER_SET_MANUAL: + return "HEATER_SET_MANUAL"; + case HEATER_GET_HEATER_STATUS: + return "HEATER_GET_HEATER_STATUS"; + case HEATER_SET_LED: + return "HEATER_SET_LED"; + case HEATER_GET_LED: + return "HEATER_GET_LED"; + default : + return nullptr; + } + } else { switch (command) @@ -416,54 +442,65 @@ unsigned char AUXCommand::checksum(AUXBuffer buf) return (unsigned char)(((~cs) + 1) & 0xFF); } +size_t AUXCommand::getDataSize(void) +{ + return m_Data.size(); +} + ///////////////////////////////////////////////////////////////////////////////////// /// Return 8, 16, or 24bit value as dictacted by the data response size. ///////////////////////////////////////////////////////////////////////////////////// -uint32_t AUXCommand::getData() +uint32_t AUXCommand::getData(size_t size, size_t offset) { - uint32_t value = 0; - switch (m_Data.size()) + uint32_t value=0; + if (!size) size=m_Data.size(); + switch (size) { + case 4: + value = (m_Data[offset] << 24) | (m_Data[offset+1] << 16) | (m_Data[offset+2] << 8) | m_Data[offset+3]; + break; + case 3: - value = (m_Data[0] << 16) | (m_Data[1] << 8) | m_Data[2]; + value = (m_Data[offset] << 16) | (m_Data[offset+1] << 8) | m_Data[offset+2]; break; case 2: - value = (m_Data[0] << 8) | m_Data[1]; + value = (m_Data[offset] << 8) | m_Data[offset+1]; break; case 1: - value = m_Data[0]; + value = m_Data[offset]; break; } return value; } + ///////////////////////////////////////////////////////////////////////////////////// /// Set encoder position in steps. ///////////////////////////////////////////////////////////////////////////////////// -void AUXCommand::setData(uint32_t value, uint8_t bytes) +void AUXCommand::setData(uint32_t value, uint8_t bytes,size_t offset) { - m_Data.resize(bytes); + m_Data.resize(bytes+offset); switch (bytes) { case 1: - len = 4; - m_Data[0] = static_cast<uint8_t>(value >> 0 & 0xff); + len = offset+4; + m_Data[offset] = static_cast<uint8_t>(value >> 0 & 0xff); break; case 2: - len = 5; - m_Data[1] = static_cast<uint8_t>(value >> 0 & 0xff); - m_Data[0] = static_cast<uint8_t>(value >> 8 & 0xff); + len = offset+5; + m_Data[offset + 1] = static_cast<uint8_t>(value >> 0 & 0xff); + m_Data[offset] = static_cast<uint8_t>(value >> 8 & 0xff); break; case 3: default: - len = 6; - m_Data[2] = static_cast<uint8_t>(value >> 0 & 0xff); - m_Data[1] = static_cast<uint8_t>(value >> 8 & 0xff); - m_Data[0] = static_cast<uint8_t>(value >> 16 & 0xff); + len = offset+6; + m_Data[offset + 2] = static_cast<uint8_t>(value >> 0 & 0xff); + m_Data[offset + 1] = static_cast<uint8_t>(value >> 8 & 0xff); + m_Data[offset] = static_cast<uint8_t>(value >> 16 & 0xff); break; } } |