Merge branch 'master' of github.com:collin80/SavvyCAN
This commit is contained in:
@@ -53,7 +53,7 @@ void ISOTP_HANDLER::sendISOTPFrame(int bus, int ID, QByteArray data)
|
||||
CANFrame frame;
|
||||
frame.setFrameType(QCanBusFrame::DataFrame);
|
||||
int currByte = 0;
|
||||
int index = 0;
|
||||
int sequence = 1; //Initial Sequence number is 1
|
||||
if (bus < 0) return;
|
||||
if (bus >= CANConManager::getInstance()->getNumBuses()) return;
|
||||
|
||||
@@ -90,8 +90,8 @@ void ISOTP_HANDLER::sendISOTPFrame(int bus, int ID, QByteArray data)
|
||||
while (currByte < data.length())
|
||||
{
|
||||
for (int b = 0; b < 8; b++) bytes[b] = 0x00;
|
||||
bytes[0] = 0x20 + index;
|
||||
index = (index + 1) & 0xF;
|
||||
bytes[0] = 0x20 + sequence; //Consecutive Frame starts from 0x20 + 1 (2: Frame type, 1: Sequence number)
|
||||
sequence = (sequence + 1) & 0xF;
|
||||
int bytesToGo = data.length() - currByte;
|
||||
if (bytesToGo > 7) bytesToGo = 7;
|
||||
for (int i = 0; i < bytesToGo; i++) bytes[1 + i] = data[currByte++];
|
||||
|
||||
+17
-2
@@ -78,6 +78,7 @@ JSHighlighter::JSHighlighter(QTextDocument *parent)
|
||||
m_keywords << "break";
|
||||
m_keywords << "case";
|
||||
m_keywords << "catch";
|
||||
m_keywords << "const";
|
||||
m_keywords << "continue";
|
||||
m_keywords << "default";
|
||||
m_keywords << "delete";
|
||||
@@ -89,6 +90,7 @@ JSHighlighter::JSHighlighter(QTextDocument *parent)
|
||||
m_keywords << "if";
|
||||
m_keywords << "in";
|
||||
m_keywords << "instanceof";
|
||||
m_keywords << "let";
|
||||
m_keywords << "new";
|
||||
m_keywords << "return";
|
||||
m_keywords << "switch";
|
||||
@@ -137,7 +139,6 @@ JSHighlighter::JSHighlighter(QTextDocument *parent)
|
||||
m_knownIds << "arguments";
|
||||
m_knownIds << "arity";
|
||||
m_knownIds << "caller";
|
||||
m_knownIds << "constructor";
|
||||
m_knownIds << "length";
|
||||
m_knownIds << "name";
|
||||
m_knownIds << "apply";
|
||||
@@ -265,7 +266,8 @@ void JSHighlighter::highlightBlock(const QString &text)
|
||||
Identifier = 2,
|
||||
String = 3,
|
||||
Comment = 4,
|
||||
Regex = 5
|
||||
Regex = 5,
|
||||
HexNumber = 6
|
||||
};
|
||||
|
||||
QList<int> bracketPositions;
|
||||
@@ -290,6 +292,10 @@ void JSHighlighter::highlightBlock(const QString &text)
|
||||
start = i;
|
||||
if (ch.isSpace()) {
|
||||
++i;
|
||||
} else if (ch == '0' && (next == 'x' || next == 'X')) {
|
||||
++i;
|
||||
++i;
|
||||
state = HexNumber;
|
||||
} else if (ch.isDigit()) {
|
||||
++i;
|
||||
state = Number;
|
||||
@@ -333,6 +339,15 @@ void JSHighlighter::highlightBlock(const QString &text)
|
||||
}
|
||||
break;
|
||||
|
||||
case HexNumber:
|
||||
if (ch.isSpace() || !(ch.isDigit() || QString("ABCDEF").contains(ch.toUpper()))) {
|
||||
setFormat(start, i - start, m_colors[JSEdit::Number]);
|
||||
state = Start;
|
||||
} else {
|
||||
++i;
|
||||
}
|
||||
break;
|
||||
|
||||
case Identifier:
|
||||
if (ch.isSpace() || !(ch.isDigit() || ch.isLetter() || ch == '_')) {
|
||||
QString token = text.mid(start, i - start).trimmed();
|
||||
|
||||
+19
-18
@@ -145,12 +145,12 @@ void ScriptContainer::addParameter(QJSValue name)
|
||||
|
||||
void ScriptContainer::updateValuesTable(QTableWidget *widget)
|
||||
{
|
||||
QString valu;
|
||||
QString value;
|
||||
|
||||
foreach (QString paramName, scriptParams)
|
||||
{
|
||||
valu = scriptEngine->globalObject().property(paramName).toString();
|
||||
qDebug() << paramName << " - " << valu;
|
||||
value = scriptEngine->globalObject().property(paramName).toString();
|
||||
qDebug() << paramName << " - " << value;
|
||||
bool found = false;
|
||||
for (int i = 0; i < widget->rowCount(); i++)
|
||||
{
|
||||
@@ -159,7 +159,7 @@ void ScriptContainer::updateValuesTable(QTableWidget *widget)
|
||||
found = true;
|
||||
if (!widget->item(i, 1)->isSelected())
|
||||
{
|
||||
widget->item(i,1)->setText(valu);
|
||||
widget->item(i,1)->setText(value);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -174,7 +174,7 @@ void ScriptContainer::updateValuesTable(QTableWidget *widget)
|
||||
item->setFlags(Qt::ItemIsEnabled);
|
||||
widget->setItem(row, 0, item);
|
||||
item = new QTableWidgetItem();
|
||||
item->setText(valu);
|
||||
item->setText(value);
|
||||
widget->setItem(row, 1, item);
|
||||
}
|
||||
}
|
||||
@@ -297,7 +297,7 @@ void ISOTPScriptHelper::setFilter(QJSValue id, QJSValue mask, QJSValue bus)
|
||||
uint32_t idVal = id.toUInt();
|
||||
uint32_t maskVal = mask.toUInt();
|
||||
int busVal = bus.toInt();
|
||||
qDebug() << "Called isotp set filter";
|
||||
qDebug() << "Called ISOTP set filter";
|
||||
qDebug() << idVal << "*" << maskVal << "*" << busVal;
|
||||
|
||||
handler->addFilter(busVal, idVal, maskVal);
|
||||
@@ -306,18 +306,17 @@ void ISOTPScriptHelper::setFilter(QJSValue id, QJSValue mask, QJSValue bus)
|
||||
void ISOTPScriptHelper::sendISOTP(QJSValue bus, QJSValue id, QJSValue length, QJSValue dataBytes)
|
||||
{
|
||||
ISOTP_MESSAGE msg;
|
||||
QByteArray dataArray;
|
||||
msg.setExtendedFrameFormat(false);
|
||||
msg.setFrameId(id.toUInt());
|
||||
dataArray.resize(length.toInt());
|
||||
QByteArray dataArray(length.toUInt(), 0);
|
||||
|
||||
int dataLen = msg.payload().length();
|
||||
int dataLen = dataArray.length();
|
||||
|
||||
if (!dataBytes.isArray()) qDebug() << "data isn't an array";
|
||||
|
||||
for (int i = 0; i < dataLen; i++)
|
||||
{
|
||||
dataArray[i] = static_cast<int8_t>(dataBytes.property(i).toInt());
|
||||
dataArray[i] = static_cast<uint8_t>(dataBytes.property(i).toInt());
|
||||
}
|
||||
msg.setPayload(dataArray);
|
||||
|
||||
@@ -325,7 +324,8 @@ void ISOTPScriptHelper::sendISOTP(QJSValue bus, QJSValue id, QJSValue length, QJ
|
||||
|
||||
if (msg.frameId() > 0x7FF) msg.setExtendedFrameFormat(true);
|
||||
|
||||
qDebug() << "sending isotp message from script";
|
||||
qDebug() << "sending ISOTP message from script";
|
||||
|
||||
handler->sendISOTPFrame(msg.bus, msg.frameId(), msg.payload());
|
||||
}
|
||||
|
||||
@@ -372,28 +372,29 @@ void UDSScriptHelper::setFilter(QJSValue id, QJSValue mask, QJSValue bus)
|
||||
uint32_t idVal = id.toUInt();
|
||||
uint32_t maskVal = mask.toUInt();
|
||||
int busVal = bus.toInt();
|
||||
qDebug() << "Called uds set filter";
|
||||
qDebug() << "Called UDS set filter";
|
||||
qDebug() << idVal << "*" << maskVal << "*" << busVal;
|
||||
|
||||
handler->addFilter(busVal, idVal, maskVal);
|
||||
}
|
||||
|
||||
void UDSScriptHelper::sendUDS(QJSValue bus, QJSValue id, QJSValue service, QJSValue sublen, QJSValue subFunc, QJSValue length, QJSValue data)
|
||||
void UDSScriptHelper::sendUDS(QJSValue bus, QJSValue id, QJSValue service, QJSValue sublen, QJSValue subFunc, QJSValue length, QJSValue dataBytes)
|
||||
{
|
||||
UDS_MESSAGE msg;
|
||||
QByteArray dataArray;
|
||||
msg.setExtendedFrameFormat(false);
|
||||
msg.setFrameId(id.toUInt());
|
||||
dataArray.resize(length.toUInt());
|
||||
QByteArray dataArray(length.toUInt(), 0);
|
||||
msg.service = service.toUInt();
|
||||
msg.subFuncLen = sublen.toUInt();
|
||||
msg.subFunc = subFunc.toUInt();
|
||||
|
||||
if (!data.isArray()) qDebug() << "data isn't an array";
|
||||
int dataLen = dataArray.length();
|
||||
|
||||
for (int i = 0; i < msg.payload().length(); i++)
|
||||
if (!dataBytes.isArray()) qDebug() << "data isn't an array";
|
||||
|
||||
for (int i = 0; i < dataLen; i++)
|
||||
{
|
||||
dataArray[i] = (static_cast<uint8_t>(data.property(static_cast<quint32>(i)).toInt()));
|
||||
dataArray[i] = static_cast<uint8_t>(dataBytes.property(i).toInt());
|
||||
}
|
||||
msg.setPayload(dataArray);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user