added prepareSlave for answering requests
This commit is contained in:
@@ -244,7 +244,6 @@ result_t Message::prepareMaster(const unsigned char srcAddress, SymbolString& ma
|
|||||||
return RESULT_ERR_INVALID_ARG; // prepare not possible
|
return RESULT_ERR_INVALID_ARG; // prepare not possible
|
||||||
|
|
||||||
SymbolString master;
|
SymbolString master;
|
||||||
master.clear();
|
|
||||||
result_t result = master.push_back(srcAddress, false, false);
|
result_t result = master.push_back(srcAddress, false, false);
|
||||||
if (result != RESULT_OK)
|
if (result != RESULT_OK)
|
||||||
return result;
|
return result;
|
||||||
@@ -273,6 +272,24 @@ result_t Message::prepareMaster(const unsigned char srcAddress, SymbolString& ma
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
result_t Message::prepareSlave(SymbolString& slaveData)
|
||||||
|
{
|
||||||
|
if (m_isPassive == false || m_isSet == true)
|
||||||
|
return RESULT_ERR_INVALID_ARG; // prepare not possible
|
||||||
|
|
||||||
|
SymbolString slave;
|
||||||
|
unsigned char addData = m_data->getLength(pt_slaveData);
|
||||||
|
result_t result = slave.push_back(addData, false, false);
|
||||||
|
if (result != RESULT_OK)
|
||||||
|
return result;
|
||||||
|
istringstream input;
|
||||||
|
result = m_data->write(input, pt_slaveData, slave, 0);
|
||||||
|
if (result != RESULT_OK)
|
||||||
|
return result;
|
||||||
|
slaveData = SymbolString(slave, true);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
result_t Message::decode(const PartType partType, SymbolString& data,
|
result_t Message::decode(const PartType partType, SymbolString& data,
|
||||||
ostringstream& output, bool leadingSeparator, char separator)
|
ostringstream& output, bool leadingSeparator, char separator)
|
||||||
{
|
{
|
||||||
|
|||||||
+10
-1
@@ -126,8 +126,9 @@ public:
|
|||||||
* @return the polling priority, or 0 for no polling at all.
|
* @return the polling priority, or 0 for no polling at all.
|
||||||
*/
|
*/
|
||||||
unsigned char getPollPriority() const { return m_pollPriority; }
|
unsigned char getPollPriority() const { return m_pollPriority; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Prepare master @a SymbolString for sending to the bus.
|
* @brief Prepare the master @a SymbolString for sending a query or command to the bus.
|
||||||
* @param masterData the master data @a SymbolString for writing symbols to.
|
* @param masterData the master data @a SymbolString for writing symbols to.
|
||||||
* @param input the @a istringstream to parse the formatted value(s) from.
|
* @param input the @a istringstream to parse the formatted value(s) from.
|
||||||
* @param separator the separator character between multiple fields.
|
* @param separator the separator character between multiple fields.
|
||||||
@@ -135,6 +136,14 @@ public:
|
|||||||
*/
|
*/
|
||||||
result_t prepareMaster(const unsigned char srcAddress, SymbolString& masterData,
|
result_t prepareMaster(const unsigned char srcAddress, SymbolString& masterData,
|
||||||
istringstream& input, char separator=';');
|
istringstream& input, char separator=';');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Prepare the slave @a SymbolString for sending an answer to the bus.
|
||||||
|
* @param slaveData the slave data @a SymbolString for writing symbols to.
|
||||||
|
* @return @a RESULT_OK on success, or an error code.
|
||||||
|
*/
|
||||||
|
result_t prepareSlave(SymbolString& masterData);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Decode a received message.
|
* @brief Decode a received message.
|
||||||
* @param partType the @a PartType of the data.
|
* @param partType the @a PartType of the data.
|
||||||
|
|||||||
Reference in New Issue
Block a user