fixes for answer mode, fix for duplicate counting of own master address, fix for empty scan and missing seen state, added answer to scan message in answer mode, solved TODO
This commit is contained in:
+11
-10
@@ -378,11 +378,11 @@ result_t Message::create(vector<string>::iterator& it, const vector<string>::ite
|
||||
return RESULT_OK;
|
||||
}
|
||||
|
||||
Message* Message::derive(const unsigned char dstAddress)
|
||||
Message* Message::derive(const unsigned char dstAddress, unsigned char srcAddress=SYN)
|
||||
{
|
||||
return new Message(m_circuit, m_name, m_isWrite,
|
||||
m_isPassive, m_comment,
|
||||
m_srcAddress, dstAddress,
|
||||
srcAddress==SYN ? m_srcAddress : srcAddress, dstAddress,
|
||||
m_id, m_data, false,
|
||||
m_pollPriority, m_condition);
|
||||
}
|
||||
@@ -419,10 +419,10 @@ bool Message::checkId(SymbolString& master, unsigned char* index)
|
||||
bool Message::checkId(Message& other)
|
||||
{
|
||||
unsigned char idLen = getIdLength();
|
||||
if (idLen != other.getIdLength())
|
||||
if (idLen != other.getIdLength() || getCount() > 1) // not supported for chained messages
|
||||
return false;
|
||||
for (unsigned char pos = 0; pos < idLen; pos++) {
|
||||
if (m_id[2+pos] != other.m_id[2+pos])//TODO chain
|
||||
if (m_id[2+pos] != other.m_id[2+pos])
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -517,17 +517,16 @@ result_t Message::prepareMasterPart(SymbolString& master, istringstream& input,
|
||||
return m_data->write(input, pt_masterData, master, getIdLength(), separator);
|
||||
}
|
||||
|
||||
result_t Message::prepareSlave(SymbolString& slaveData)
|
||||
result_t Message::prepareSlave(istringstream& input, SymbolString& slaveData)
|
||||
{
|
||||
if (!m_isPassive || m_isWrite)
|
||||
return RESULT_ERR_INVALID_ARG; // prepare not possible
|
||||
if (m_isWrite)
|
||||
return RESULT_ERR_INVALID_ARG; // prepare not possible
|
||||
|
||||
SymbolString slave(false);
|
||||
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; // TODO create input from database of internal variables
|
||||
result = m_data->write(input, pt_slaveData, slave, 0);
|
||||
if (result != RESULT_OK)
|
||||
return result;
|
||||
@@ -1456,7 +1455,7 @@ deque<Message*> MessageMap::findAll(const string& circuit, const string& name, c
|
||||
return ret;
|
||||
}
|
||||
|
||||
Message* MessageMap::find(SymbolString& master)
|
||||
Message* MessageMap::find(SymbolString& master, bool anyDestination)
|
||||
{
|
||||
if (master.size() < 5)
|
||||
return NULL;
|
||||
@@ -1465,8 +1464,10 @@ Message* MessageMap::find(SymbolString& master)
|
||||
maxIdLength = m_maxIdLength;
|
||||
if (master.size() < 5+maxIdLength)
|
||||
return NULL;
|
||||
if (maxIdLength == 0 && anyDestination && master[2] == 0x07 && master[3] == 0x04)
|
||||
return m_scanMessage;
|
||||
unsigned long long baseKey = (unsigned long long)getMasterNumber(master[0]) << (8 * 7); // QQ address for passive message
|
||||
baseKey |= (unsigned long long)master[1] << (8 * 6); // ZZ address
|
||||
baseKey |= (unsigned long long)(anyDestination ? SYN : master[1]) << (8 * 6); // ZZ address
|
||||
baseKey |= (unsigned long long)master[2] << (8 * 5); // PB
|
||||
baseKey |= (unsigned long long)master[3] << (8 * 4); // SB
|
||||
for (unsigned char idLength = maxIdLength; true; idLength--) {
|
||||
|
||||
@@ -142,9 +142,10 @@ public:
|
||||
/**
|
||||
* Derive a new @a Message from this message.
|
||||
* @param dstAddress the new destination address.
|
||||
* @param srcAddress the new source address, or @a SYN to keep the current source address.
|
||||
* @return the derived @a Message instance.
|
||||
*/
|
||||
virtual Message* derive(const unsigned char dstAddress);
|
||||
virtual Message* derive(const unsigned char dstAddress, unsigned char srcAddress);
|
||||
|
||||
/**
|
||||
* Get the optional circuit name.
|
||||
@@ -227,7 +228,7 @@ public:
|
||||
* @param other the other @a Message to check against.
|
||||
* @return true if the ID matches, false otherwise.
|
||||
*/
|
||||
virtual bool checkId(Message& other);
|
||||
bool checkId(Message& other);
|
||||
|
||||
/**
|
||||
* Return the key for storing in @a MessageMap.
|
||||
@@ -315,10 +316,11 @@ public:
|
||||
|
||||
/**
|
||||
* Prepare the slave @a SymbolString for sending an answer to the bus.
|
||||
* @param input the @a istringstream to parse the formatted value(s) from.
|
||||
* @param slaveData the slave data @a SymbolString for writing symbols to.
|
||||
* @return @a RESULT_OK on success, or an error code.
|
||||
*/
|
||||
virtual result_t prepareSlave(SymbolString& slaveData);
|
||||
virtual result_t prepareSlave(istringstream& input, SymbolString& slaveData);
|
||||
|
||||
/**
|
||||
* Store the last seen master and slave data.
|
||||
@@ -917,10 +919,11 @@ public:
|
||||
/**
|
||||
* Find the @a Message instance for the specified master data.
|
||||
* @param master the master @a SymbolString for identifying the @a Message.
|
||||
* @param anyDestination true to only return messages without a particular destination.
|
||||
* @return the @a Message instance, or NULL.
|
||||
* Note: the caller may not free the returned instance.
|
||||
*/
|
||||
Message* find(SymbolString& master);
|
||||
Message* find(SymbolString& master, bool anyDestination=false);
|
||||
|
||||
/**
|
||||
* Invalidate cached data of the @a Message and all other instances with a matching name key.
|
||||
|
||||
Reference in New Issue
Block a user