Changeset View
Changeset View
Standalone View
Standalone View
src/core/ifirmware.cpp
Show First 20 Lines • Show All 65 Lines • ▼ Show 20 Line(s) | 65 | if (lastMessage.contains(IFirmwarePrivate::_ok)) { | |||
---|---|---|---|---|---|
66 | emit readyForCommand(); | 66 | emit readyForCommand(); | ||
67 | } | 67 | } | ||
68 | } | 68 | } | ||
69 | 69 | | |||
70 | QByteArray IFirmware::translate(const QString &command) | 70 | QByteArray IFirmware::translate(const QString &command) | ||
71 | { | 71 | { | ||
72 | return command.toLocal8Bit(); | 72 | return command.toLocal8Bit(); | ||
73 | } | 73 | } | ||
74 | | ||||
75 | uint8_t IFirmware::checksum(QString line) | ||||
76 | { | ||||
77 | uint8_t sum = 0; | ||||
78 | if (line.contains(QStringLiteral("*"))) { | ||||
79 | line.chop(line.indexOf(QStringLiteral("*"))); | ||||
80 | } | ||||
81 | if (line.contains(QStringLiteral(";"))) { | ||||
82 | line.chop(line.indexOf(QStringLiteral(";"))); | ||||
83 | } | ||||
84 | int count = line.length(); | ||||
85 | while (count) { | ||||
86 | sum ^= line.at(--count).toLatin1(); | ||||
87 | } | ||||
88 | return sum; | ||||
89 | } |