Ejemplo n.º 1
0
void EmsData::revertLocalRamBlockToDevice(unsigned short locationid)
{
	setLocalRamBlock(locationid,getDeviceRamBlock(locationid));
	if (isLocalRamDirty(locationid))
	{
		markLocalRamLocationClean(locationid);
	}
}
Ejemplo n.º 2
0
void EmsData::ramBytesLocalUpdate(unsigned short locationid,unsigned short offset,unsigned short size,QByteArray data)
{
	if (!hasLocalRamBlock(locationid))
	{
		QLOG_WARN() << "Write requested when there is no local ram block!";
		return;
	}
	if (getLocalRamBlock(locationid).mid(offset,size) == data)
	{
		QLOG_WARN() << "Data in application ram memory unchanged, no reason to send write for single value";
		return;
	}
	QLOG_TRACE() << "Updating ram locationid" << locationid << "with" << data.size() << "bytes at offset" << offset;
	setLocalRamBlock(locationid,getLocalRamBlock(locationid).replace(offset,size,data));
	//emit updateRequired(locationid);
	emit ramBlockUpdateRequest(locationid,offset,size,data);
}
Ejemplo n.º 3
0
void EmsData::ramBlockUpdate(unsigned short locationid, QByteArray header, QByteArray payload)
{
	Q_UNUSED(header)
	QLOG_TRACE() << "Ram Block retrieved:" << "0x" + QString::number(locationid,16).toUpper();
	QList<ConfigBlock> configlist = m_memoryMetaData->getConfigMetaData(QString::number(locationid,16).toUpper());
	for (int i=0;i<configlist.size();i++)
	{
		//configlist[i].offset()

		QString valstr = "";
		QString bytestr = "";
		for (int k=0;k<configlist[i].size();k++)
		{
			unsigned int value = 0;
			for (int j=0;j<configlist[i].elementSize();j++)
			{
				//QLOG_DEBUG() << (unsigned char)block[m_fieldConfigList[i].second.offset() + (k * m_fieldConfigList[i].second.elementSize()) + j];
				bytestr += QString::number((unsigned char)payload[configlist[i].offset() + (k * configlist[i].elementSize()) + j],16).toUpper() + ",";
				value += ((unsigned char)payload[configlist[i].offset() + (k * configlist[i].elementSize()) + j]) << (8 * (configlist[i].elementSize() - (j+1)));
			}
			//userValue = (ecuValue + translate) * scale

			valstr += QString::number(calcAxis(value,configlist[i].calc())) + ",";
		}
		valstr = valstr.mid(0,valstr.length()-1);
		QLOG_DEBUG() << "Pre value:" << "0x" + QString::number(locationid,16) << bytestr;
		//valstr == variable.
		emit configRecieved(configlist[i],QVariant(valstr));
	}

	if (!hasDeviceRamBlock(locationid))
	{
		//This should not happen
		/*RawDataBlock *block = new RawDataBlock();
		block->locationid = locationid;
		block->header = header;
		block->data = payload;
		//m_flashRawBlockList.append(block);
		m_deviceRamRawBlockList.append(block);*/
	}
	else
	{
		//Check to see if it's supposed to be a table, and if so, check size
		if (!verifyMemoryBlock(locationid,header,payload))
		{
			//QMessageBox::information(this,"Error","RAM Location ID 0x" + QString::number(locationid,16).toUpper() + " should be 1024 sized, but it is " + QString::number(payload.size()) + ". This should never happen");
			QLOG_ERROR() << "RAM Location ID 0x" + QString::number(locationid,16).toUpper() + " should be 1024 sized, but it is " + QString::number(payload.size()) + ". This should never happen";
			return;
		}
		if (getDeviceRamBlock(locationid).isEmpty())
		{
			//This should not happen
			QLOG_ERROR() << "Ram block on device while ram block on tuner is empty! This should not happen" << "0x" + QString::number(locationid,16).toUpper();
			QLOG_ERROR() << "Current block size:" << getDeviceRamBlock(locationid).size();
			setLocalRamBlock(locationid,payload);
			setDeviceRamBlock(locationid,payload);
		}
		else
		{
			if (m_interrogationInProgress)
			{
				//checkEmsData->setDeviceRamBlock(locationid,payload);
				for (int i=0;i<m_duplicateRamMemoryList.size();i++)
				{
					if (m_duplicateRamMemoryList[i]->locationid == locationid)
					{
						m_duplicateRamMemoryList[i]->setData(payload);
						break;
					}
				}
				m_checkEmsDataInUse = true;
			}
			else
			{
				if (getDeviceRamBlock(locationid) != payload)
				{
					QLOG_ERROR() << "Ram block on device does not match ram block on tuner! This should ONLY happen during a manual update!";
					QLOG_ERROR() << "Tuner ram size:" << getDeviceRamBlock(locationid).size();
					setDeviceRamBlock(locationid,payload);
				}
				if (payload != getLocalRamBlock(locationid))
				{
					//We need to prompt the user, local ram is out of date.
					setLocalRamBlock(locationid,payload);
				}
			}
		}
		//updateDataWindows(locationid);
		emit updateRequired(locationid);
	}
	return;
}