Changeset View
Changeset View
Standalone View
Standalone View
src/plugins/marlinplugin.cpp
Show All 39 Lines | 39 | { | |||
---|---|---|---|---|---|
40 | return true; | 40 | return true; | ||
41 | } | 41 | } | ||
42 | 42 | | |||
43 | MarlinPlugin::MarlinPlugin() | 43 | MarlinPlugin::MarlinPlugin() | ||
44 | { | 44 | { | ||
45 | qCDebug(MARLIN_PLUGIN) << name() << " plugin loaded!"; | 45 | qCDebug(MARLIN_PLUGIN) << name() << " plugin loaded!"; | ||
46 | } | 46 | } | ||
47 | 47 | | |||
48 | QByteArray MarlinPlugin::translate(const QString &command) | ||||
49 | { | ||||
50 | QString temp = command; | ||||
51 | if (command.contains(QStringLiteral("M28"))) { | ||||
patrickelectric: M280 is a valid gcode. | |||||
Good point I will change it to a Regex that looks for M28 <string> rizzitello: Good point I will change it to a Regex that looks for M28 <string> | |||||
52 | QString filename = temp.mid(4, temp.length()); | ||||
53 | filename = to83(filename); | ||||
54 | temp = QStringLiteral("M28 %1").arg(filename); | ||||
55 | | ||||
56 | } else if (command.contains(QStringLiteral("M29"))) { | ||||
57 | QString filename = temp.mid(4, temp.length()); | ||||
58 | filename = to83(filename); | ||||
59 | temp = QStringLiteral("M29 %1").arg(filename); | ||||
60 | } | ||||
61 | | ||||
62 | return temp.toLocal8Bit(); | ||||
63 | } | ||||
64 | | ||||
48 | void MarlinPlugin::validateCommand(const QString &lastMessage) | 65 | void MarlinPlugin::validateCommand(const QString &lastMessage) | ||
49 | { | 66 | { | ||
50 | if (lastMessage.contains(QStringLiteral("End file list"))) { | 67 | if (lastMessage.contains(QStringLiteral("End file list"))) { | ||
51 | core()->setReadingSdCardList(false); | 68 | core()->setReadingSdCardList(false); | ||
52 | } else if (core()->isReadingSdCardList()) { | 69 | } else if (core()->isReadingSdCardList()) { | ||
temp = QStringLiteral("M29"); tcanabrava: temp = QStringLiteral("M29");
if (temp.length()) {
...
temp += " " + filename;
} ? | |||||
53 | // Below is to not add directories | 70 | // Below is to not add directories | ||
54 | if (!lastMessage.endsWith(QChar::fromLatin1('/'))) { | 71 | if (!lastMessage.endsWith(QChar::fromLatin1('/'))) { | ||
55 | QString fileName = lastMessage; | 72 | QString fileName = lastMessage; | ||
56 | fileName.chop(fileName.length() - fileName.lastIndexOf(QChar::fromLatin1(' '))); | 73 | fileName.chop(fileName.length() - fileName.lastIndexOf(QChar::fromLatin1(' '))); | ||
57 | core()->appendSdCardFileList(fileName); | 74 | core()->appendSdCardFileList(fileName); | ||
58 | } | 75 | } | ||
59 | } else { | 76 | } else { | ||
60 | if (lastMessage.contains(QStringLiteral("SD card ok"))) { | 77 | if (lastMessage.contains(QStringLiteral("SD card ok"))) { | ||
Show All 30 Lines | 106 | } else { | |||
91 | core()->setState(AtCore::IDLE); | 108 | core()->setState(AtCore::IDLE); | ||
92 | } | 109 | } | ||
93 | } | 110 | } | ||
94 | if (lastMessage.contains(QStringLiteral("ok"))) { | 111 | if (lastMessage.contains(QStringLiteral("ok"))) { | ||
95 | emit readyForCommand(); | 112 | emit readyForCommand(); | ||
96 | } | 113 | } | ||
97 | } | 114 | } | ||
98 | } | 115 | } | ||
116 | | ||||
117 | QString MarlinPlugin::to83(const QString &fileName) | ||||
118 | { | ||||
119 | //Generate an 8.3 Like FileName. | ||||
120 | QString newName; | ||||
tcanabrava: QLatin1Char('.') ? | |||||
121 | if (fileName.lastIndexOf(QStringLiteral(".") < 9)) { | ||||
patrickelectric: Check qfileinfo | |||||
This class does not currently include QFileInfo is that lighter then doing this one call? rizzitello: This class does not currently include QFileInfo is that lighter then doing this one call? | |||||
patrickelectric: There is at least 3 places to use qfileinfo in this patch. | |||||
Sorry, about this file, I do see why not, and this will be only be called once. patrickelectric: Sorry, about this file, I do see why not, and this will be only be called once. | |||||
122 | newName = fileName.mid(0, fileName.lastIndexOf(QStringLiteral("."))); | ||||
123 | } else { | ||||
124 | newName = fileName.mid(0, 8); | ||||
125 | } | ||||
126 | if (newName.length() > 8) { | ||||
127 | newName.resize(8); | ||||
128 | } | ||||
129 | newName = newName.append(fileName.mid(fileName.lastIndexOf(QStringLiteral(".")), 4)); | ||||
130 | return newName.toUpper(); | ||||
131 | } |
M280 is a valid gcode.