RawTxWindow.cpp 37 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048
  1. /*
  2. Copyright (c) 2015, 2016 Hubert Denkmair <hubert@denkmair.de>
  3. This file is part of cangaroo.
  4. cangaroo is free software: you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation, either version 2 of the License, or
  7. (at your option) any later version.
  8. cangaroo is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with cangaroo. If not, see <http://www.gnu.org/licenses/>.
  14. */
  15. #include "RawTxWindow.h"
  16. #include "ui_RawTxWindow.h"
  17. #include <QDomDocument>
  18. #include <QTimer>
  19. #include <core/Backend.h>
  20. #include <driver/CanInterface.h>
  21. #include <QFileInfo>
  22. #include <QFileDialog>
  23. #include <QFile>
  24. #include <QTextStream>
  25. #include <QList>
  26. #define DriverCmdSendEN 1 //shifou pingbi qudong zhiling,1 bu pingbi ,0 ppingbi
  27. QList <uint32_t>drivercmdID = {0x1c4,0x24e,0x30b};
  28. static uint64_t sendnum=0;
  29. RawTxWindow::RawTxWindow(QWidget *parent, Backend &backend) :
  30. ConfigurableWidget(parent),
  31. ui(new Ui::RawTxWindow),
  32. _backend(backend)
  33. {
  34. ui->setupUi(this);
  35. connect(ui->singleSendButton, SIGNAL(released()), this, SLOT(sendRawMessage()));
  36. connect(ui->repeatSendButton, SIGNAL(toggled(bool)), this, SLOT(sendRepeatMessage(bool)));
  37. connect(ui->spinBox_RepeatRate, SIGNAL(valueChanged(int)), this, SLOT(changeRepeatRate(int)));
  38. connect(ui->comboBoxInterface, SIGNAL(currentIndexChanged(int)), this, SLOT(updateCapabilities()));
  39. connect(ui->checkbox_FD, SIGNAL(stateChanged(int)), this, SLOT(updateCapabilities()));
  40. connect(&backend, SIGNAL(beginMeasurement()), this, SLOT(refreshInterfaces()));
  41. // Timer for repeating messages
  42. repeatmsg_timer = new QTimer(this);
  43. connect(repeatmsg_timer, SIGNAL(timeout()), this, SLOT(sendRawMessage()));
  44. // TODO: Grey out checkboxes that are invalid depending on DLC spinbox state
  45. //connect(ui->fieldDLC, SIGNAL(valueChanged(int)), this, SLOT(changeDLC(int)));
  46. connect(ui->comboBoxDLC, SIGNAL(currentIndexChanged(int)), this, SLOT(changeDLC()));
  47. //文件发送
  48. connect(ui->fileAddButton,SIGNAL(released()),this,SLOT(fileAdd()));
  49. connect(ui->fileSendButton,SIGNAL(toggled(bool)),this,SLOT(fileSend(bool)));
  50. // Disable TX until interfaces are present
  51. this->setDisabled(1);
  52. }
  53. RawTxWindow::~RawTxWindow()
  54. {
  55. delete ui;
  56. filesenddata.squeeze();
  57. }
  58. void RawTxWindow::changeDLC()
  59. {
  60. ui->fieldByte0_0->setEnabled(true);
  61. ui->fieldByte1_0->setEnabled(true);
  62. ui->fieldByte2_0->setEnabled(true);
  63. ui->fieldByte3_0->setEnabled(true);
  64. ui->fieldByte4_0->setEnabled(true);
  65. ui->fieldByte5_0->setEnabled(true);
  66. ui->fieldByte6_0->setEnabled(true);
  67. ui->fieldByte7_0->setEnabled(true);
  68. ui->fieldByte0_1->setEnabled(true);
  69. ui->fieldByte1_1->setEnabled(true);
  70. ui->fieldByte2_1->setEnabled(true);
  71. ui->fieldByte3_1->setEnabled(true);
  72. ui->fieldByte4_1->setEnabled(true);
  73. ui->fieldByte5_1->setEnabled(true);
  74. ui->fieldByte6_1->setEnabled(true);
  75. ui->fieldByte7_1->setEnabled(true);
  76. ui->fieldByte0_2->setEnabled(true);
  77. ui->fieldByte1_2->setEnabled(true);
  78. ui->fieldByte2_2->setEnabled(true);
  79. ui->fieldByte3_2->setEnabled(true);
  80. ui->fieldByte4_2->setEnabled(true);
  81. ui->fieldByte5_2->setEnabled(true);
  82. ui->fieldByte6_2->setEnabled(true);
  83. ui->fieldByte7_2->setEnabled(true);
  84. ui->fieldByte0_3->setEnabled(true);
  85. ui->fieldByte1_3->setEnabled(true);
  86. ui->fieldByte2_3->setEnabled(true);
  87. ui->fieldByte3_3->setEnabled(true);
  88. ui->fieldByte4_3->setEnabled(true);
  89. ui->fieldByte5_3->setEnabled(true);
  90. ui->fieldByte6_3->setEnabled(true);
  91. ui->fieldByte7_3->setEnabled(true);
  92. ui->fieldByte0_4->setEnabled(true);
  93. ui->fieldByte1_4->setEnabled(true);
  94. ui->fieldByte2_4->setEnabled(true);
  95. ui->fieldByte3_4->setEnabled(true);
  96. ui->fieldByte4_4->setEnabled(true);
  97. ui->fieldByte5_4->setEnabled(true);
  98. ui->fieldByte6_4->setEnabled(true);
  99. ui->fieldByte7_4->setEnabled(true);
  100. ui->fieldByte0_5->setEnabled(true);
  101. ui->fieldByte1_5->setEnabled(true);
  102. ui->fieldByte2_5->setEnabled(true);
  103. ui->fieldByte3_5->setEnabled(true);
  104. ui->fieldByte4_5->setEnabled(true);
  105. ui->fieldByte5_5->setEnabled(true);
  106. ui->fieldByte6_5->setEnabled(true);
  107. ui->fieldByte7_5->setEnabled(true);
  108. ui->fieldByte0_6->setEnabled(true);
  109. ui->fieldByte1_6->setEnabled(true);
  110. ui->fieldByte2_6->setEnabled(true);
  111. ui->fieldByte3_6->setEnabled(true);
  112. ui->fieldByte4_6->setEnabled(true);
  113. ui->fieldByte5_6->setEnabled(true);
  114. ui->fieldByte6_6->setEnabled(true);
  115. ui->fieldByte7_6->setEnabled(true);
  116. ui->fieldByte0_7->setEnabled(true);
  117. ui->fieldByte1_7->setEnabled(true);
  118. ui->fieldByte2_7->setEnabled(true);
  119. ui->fieldByte3_7->setEnabled(true);
  120. ui->fieldByte4_7->setEnabled(true);
  121. ui->fieldByte5_7->setEnabled(true);
  122. ui->fieldByte6_7->setEnabled(true);
  123. ui->fieldByte7_7->setEnabled(true);
  124. uint8_t dlc = ui->comboBoxDLC->currentData().toUInt();
  125. switch(dlc)
  126. {
  127. case 0:
  128. ui->fieldByte0_0->setEnabled(false);
  129. //fallthrough
  130. case 1:
  131. ui->fieldByte1_0->setEnabled(false);
  132. //fallthrough
  133. case 2:
  134. ui->fieldByte2_0->setEnabled(false);
  135. //fallthrough
  136. case 3:
  137. ui->fieldByte3_0->setEnabled(false);
  138. //fallthrough
  139. case 4:
  140. ui->fieldByte4_0->setEnabled(false);
  141. //fallthrough
  142. case 5:
  143. ui->fieldByte5_0->setEnabled(false);
  144. //fallthrough
  145. case 6:
  146. ui->fieldByte6_0->setEnabled(false);
  147. //fallthrough
  148. case 7:
  149. ui->fieldByte7_0->setEnabled(false);
  150. //fallthrough
  151. case 8:
  152. ui->fieldByte0_1->setEnabled(false);
  153. ui->fieldByte1_1->setEnabled(false);
  154. ui->fieldByte2_1->setEnabled(false);
  155. ui->fieldByte3_1->setEnabled(false);
  156. //fallthrough
  157. case 12:
  158. ui->fieldByte4_1->setEnabled(false);
  159. ui->fieldByte5_1->setEnabled(false);
  160. ui->fieldByte6_1->setEnabled(false);
  161. ui->fieldByte7_1->setEnabled(false);
  162. //fallthrough
  163. case 16:
  164. ui->fieldByte0_2->setEnabled(false);
  165. ui->fieldByte1_2->setEnabled(false);
  166. ui->fieldByte2_2->setEnabled(false);
  167. ui->fieldByte3_2->setEnabled(false);
  168. //fallthrough
  169. case 20:
  170. ui->fieldByte4_2->setEnabled(false);
  171. ui->fieldByte5_2->setEnabled(false);
  172. ui->fieldByte6_2->setEnabled(false);
  173. ui->fieldByte7_2->setEnabled(false);
  174. //fallthrough
  175. case 24:
  176. ui->fieldByte0_3->setEnabled(false);
  177. ui->fieldByte1_3->setEnabled(false);
  178. ui->fieldByte2_3->setEnabled(false);
  179. ui->fieldByte3_3->setEnabled(false);
  180. ui->fieldByte4_3->setEnabled(false);
  181. ui->fieldByte5_3->setEnabled(false);
  182. ui->fieldByte6_3->setEnabled(false);
  183. ui->fieldByte7_3->setEnabled(false);
  184. //fallthrough
  185. case 32:
  186. ui->fieldByte0_4->setEnabled(false);
  187. ui->fieldByte1_4->setEnabled(false);
  188. ui->fieldByte2_4->setEnabled(false);
  189. ui->fieldByte3_4->setEnabled(false);
  190. ui->fieldByte4_4->setEnabled(false);
  191. ui->fieldByte5_4->setEnabled(false);
  192. ui->fieldByte6_4->setEnabled(false);
  193. ui->fieldByte7_4->setEnabled(false);
  194. ui->fieldByte0_5->setEnabled(false);
  195. ui->fieldByte1_5->setEnabled(false);
  196. ui->fieldByte2_5->setEnabled(false);
  197. ui->fieldByte3_5->setEnabled(false);
  198. ui->fieldByte4_5->setEnabled(false);
  199. ui->fieldByte5_5->setEnabled(false);
  200. ui->fieldByte6_5->setEnabled(false);
  201. ui->fieldByte7_5->setEnabled(false);
  202. //fallthrough
  203. case 48:
  204. ui->fieldByte0_6->setEnabled(false);
  205. ui->fieldByte1_6->setEnabled(false);
  206. ui->fieldByte2_6->setEnabled(false);
  207. ui->fieldByte3_6->setEnabled(false);
  208. ui->fieldByte4_6->setEnabled(false);
  209. ui->fieldByte5_6->setEnabled(false);
  210. ui->fieldByte6_6->setEnabled(false);
  211. ui->fieldByte7_6->setEnabled(false);
  212. ui->fieldByte0_7->setEnabled(false);
  213. ui->fieldByte1_7->setEnabled(false);
  214. ui->fieldByte2_7->setEnabled(false);
  215. ui->fieldByte3_7->setEnabled(false);
  216. ui->fieldByte4_7->setEnabled(false);
  217. ui->fieldByte5_7->setEnabled(false);
  218. ui->fieldByte6_7->setEnabled(false);
  219. ui->fieldByte7_7->setEnabled(false);
  220. }
  221. // repeatmsg_timer->setInterval(ms);
  222. }
  223. void RawTxWindow::updateCapabilities()
  224. {
  225. // check if intf suports fd, if, enable, else dis
  226. //CanInterface *intf = _backend.getInterfaceById(idx);
  227. if(ui->comboBoxInterface->count() > 0)
  228. {
  229. // By default BRS should be available
  230. CanInterface *intf = _backend.getInterfaceById((CanInterfaceId)ui->comboBoxInterface->currentData().toUInt());
  231. if(intf == NULL)
  232. {
  233. return;
  234. }
  235. int idx_restore = ui->comboBoxDLC->currentIndex();
  236. // If CANFD is available
  237. if(intf->getCapabilities() & intf->capability_canfd)
  238. {
  239. ui->comboBoxDLC->clear();
  240. ui->comboBoxDLC->addItem("0", 0);
  241. ui->comboBoxDLC->addItem("1", 1);
  242. ui->comboBoxDLC->addItem("2", 2);
  243. ui->comboBoxDLC->addItem("3", 3);
  244. ui->comboBoxDLC->addItem("4", 4);
  245. ui->comboBoxDLC->addItem("5", 5);
  246. ui->comboBoxDLC->addItem("6", 6);
  247. ui->comboBoxDLC->addItem("7", 7);
  248. ui->comboBoxDLC->addItem("8", 8);
  249. ui->comboBoxDLC->addItem("12", 12);
  250. ui->comboBoxDLC->addItem("16", 16);
  251. ui->comboBoxDLC->addItem("20", 20);
  252. ui->comboBoxDLC->addItem("24", 24);
  253. ui->comboBoxDLC->addItem("32", 32);
  254. ui->comboBoxDLC->addItem("48", 48);
  255. ui->comboBoxDLC->addItem("64", 64);
  256. // Restore previous selected DLC if available
  257. if(idx_restore > 1 && idx_restore < ui->comboBoxDLC->count())
  258. ui->comboBoxDLC->setCurrentIndex(idx_restore);
  259. ui->checkbox_FD->setDisabled(0);
  260. // Enable BRS if this is an FD frame
  261. if(ui->checkbox_FD->isChecked())
  262. {
  263. // Enable BRS if FD enabled
  264. ui->checkbox_BRS->setDisabled(0);
  265. // Disable RTR if FD enabled
  266. ui->checkBox_IsRTR->setDisabled(1);
  267. ui->checkBox_IsRTR->setChecked(false);
  268. }
  269. else
  270. {
  271. // Disable BRS if FD disabled
  272. ui->checkbox_BRS->setDisabled(1);
  273. ui->checkbox_BRS->setChecked(false);
  274. // Enable RTR if FD disabled
  275. ui->checkBox_IsRTR->setDisabled(0);
  276. }
  277. showFDFields();
  278. }
  279. else
  280. {
  281. // CANFD not available
  282. ui->comboBoxDLC->clear();
  283. ui->comboBoxDLC->addItem("0", 0);
  284. ui->comboBoxDLC->addItem("1", 1);
  285. ui->comboBoxDLC->addItem("2", 2);
  286. ui->comboBoxDLC->addItem("3", 3);
  287. ui->comboBoxDLC->addItem("4", 4);
  288. ui->comboBoxDLC->addItem("5", 5);
  289. ui->comboBoxDLC->addItem("6", 6);
  290. ui->comboBoxDLC->addItem("7", 7);
  291. ui->comboBoxDLC->addItem("8", 8);
  292. // Restore previous selected DLC if available
  293. if(idx_restore > 1 && idx_restore < ui->comboBoxDLC->count())
  294. ui->comboBoxDLC->setCurrentIndex(idx_restore);
  295. // Unset/disable FD / BRS checkboxes
  296. ui->checkbox_FD->setDisabled(1);
  297. ui->checkbox_BRS->setDisabled(1);
  298. ui->checkbox_FD->setChecked(false);
  299. ui->checkbox_BRS->setChecked(false);
  300. // Enable RTR (could be disabled by FD checkbox being set)
  301. ui->checkBox_IsRTR->setDisabled(0);
  302. hideFDFields();
  303. }
  304. }
  305. }
  306. void RawTxWindow::changeRepeatRate(int ms)
  307. {
  308. repeatmsg_timer->setInterval(ms);
  309. }
  310. void RawTxWindow::sendRepeatMessage(bool enable)
  311. {
  312. if(enable)
  313. {
  314. repeatmsg_timer->start(ui->spinBox_RepeatRate->value());
  315. }
  316. else
  317. {
  318. repeatmsg_timer->stop();
  319. }
  320. }
  321. void RawTxWindow::disableTxWindow(int disable)
  322. {
  323. if(disable)
  324. {
  325. this->setDisabled(1);
  326. }
  327. else
  328. {
  329. // Only enable if an interface is present
  330. if(_backend.getInterfaceList().count() > 0)
  331. this->setDisabled(0);
  332. else
  333. this->setDisabled(1);
  334. }
  335. }
  336. void RawTxWindow::refreshInterfaces()
  337. {
  338. ui->comboBoxInterface->clear();
  339. int cb_idx = 0;
  340. // TODO: Only show interfaces that are included in active MeasurementInterfaces!
  341. foreach (CanInterfaceId ifid, _backend.getInterfaceList()) {
  342. CanInterface *intf = _backend.getInterfaceById(ifid);
  343. if(intf->isOpen())
  344. {
  345. ui->comboBoxInterface->addItem(intf->getName() + " " + intf->getDriver()->getName());
  346. ui->comboBoxInterface->setItemData(cb_idx, QVariant(ifid));
  347. cb_idx++;
  348. }
  349. }
  350. if(cb_idx == 0)
  351. disableTxWindow(1);
  352. else
  353. disableTxWindow(0);
  354. updateCapabilities();
  355. }
  356. //void RawTxWindow::sendRawMessage()
  357. //{
  358. // CanMessage msg;
  359. // bool en_extended = ui->checkBox_IsExtended->isChecked();
  360. // bool en_rtr = ui->checkBox_IsRTR->isChecked();
  361. // uint8_t data_int[64];
  362. // int data_ctr = 0;
  363. // data_int[data_ctr++] = ui->fieldByte0_0->text().toUpper().toInt(NULL, 16);
  364. // data_int[data_ctr++] = ui->fieldByte1_0->text().toUpper().toInt(NULL, 16);
  365. // data_int[data_ctr++] = ui->fieldByte2_0->text().toUpper().toInt(NULL, 16);
  366. // data_int[data_ctr++] = ui->fieldByte3_0->text().toUpper().toInt(NULL, 16);
  367. // data_int[data_ctr++] = ui->fieldByte4_0->text().toUpper().toInt(NULL, 16);
  368. // data_int[data_ctr++] = ui->fieldByte5_0->text().toUpper().toInt(NULL, 16);
  369. // data_int[data_ctr++] = ui->fieldByte6_0->text().toUpper().toInt(NULL, 16);
  370. // data_int[data_ctr++] = ui->fieldByte7_0->text().toUpper().toInt(NULL, 16);
  371. // data_int[data_ctr++] = ui->fieldByte0_1->text().toUpper().toInt(NULL, 16);
  372. // data_int[data_ctr++] = ui->fieldByte1_1->text().toUpper().toInt(NULL, 16);
  373. // data_int[data_ctr++] = ui->fieldByte2_1->text().toUpper().toInt(NULL, 16);
  374. // data_int[data_ctr++] = ui->fieldByte3_1->text().toUpper().toInt(NULL, 16);
  375. // data_int[data_ctr++] = ui->fieldByte4_1->text().toUpper().toInt(NULL, 16);
  376. // data_int[data_ctr++] = ui->fieldByte5_1->text().toUpper().toInt(NULL, 16);
  377. // data_int[data_ctr++] = ui->fieldByte6_1->text().toUpper().toInt(NULL, 16);
  378. // data_int[data_ctr++] = ui->fieldByte7_1->text().toUpper().toInt(NULL, 16);
  379. // data_int[data_ctr++] = ui->fieldByte0_2->text().toUpper().toInt(NULL, 16);
  380. // data_int[data_ctr++] = ui->fieldByte1_2->text().toUpper().toInt(NULL, 16);
  381. // data_int[data_ctr++] = ui->fieldByte2_2->text().toUpper().toInt(NULL, 16);
  382. // data_int[data_ctr++] = ui->fieldByte3_2->text().toUpper().toInt(NULL, 16);
  383. // data_int[data_ctr++] = ui->fieldByte4_2->text().toUpper().toInt(NULL, 16);
  384. // data_int[data_ctr++] = ui->fieldByte5_2->text().toUpper().toInt(NULL, 16);
  385. // data_int[data_ctr++] = ui->fieldByte6_2->text().toUpper().toInt(NULL, 16);
  386. // data_int[data_ctr++] = ui->fieldByte7_2->text().toUpper().toInt(NULL, 16);
  387. // data_int[data_ctr++] = ui->fieldByte0_3->text().toUpper().toInt(NULL, 16);
  388. // data_int[data_ctr++] = ui->fieldByte1_3->text().toUpper().toInt(NULL, 16);
  389. // data_int[data_ctr++] = ui->fieldByte2_3->text().toUpper().toInt(NULL, 16);
  390. // data_int[data_ctr++] = ui->fieldByte3_3->text().toUpper().toInt(NULL, 16);
  391. // data_int[data_ctr++] = ui->fieldByte4_3->text().toUpper().toInt(NULL, 16);
  392. // data_int[data_ctr++] = ui->fieldByte5_3->text().toUpper().toInt(NULL, 16);
  393. // data_int[data_ctr++] = ui->fieldByte6_3->text().toUpper().toInt(NULL, 16);
  394. // data_int[data_ctr++] = ui->fieldByte7_3->text().toUpper().toInt(NULL, 16);
  395. // data_int[data_ctr++] = ui->fieldByte0_4->text().toUpper().toInt(NULL, 16);
  396. // data_int[data_ctr++] = ui->fieldByte1_4->text().toUpper().toInt(NULL, 16);
  397. // data_int[data_ctr++] = ui->fieldByte2_4->text().toUpper().toInt(NULL, 16);
  398. // data_int[data_ctr++] = ui->fieldByte3_4->text().toUpper().toInt(NULL, 16);
  399. // data_int[data_ctr++] = ui->fieldByte4_4->text().toUpper().toInt(NULL, 16);
  400. // data_int[data_ctr++] = ui->fieldByte5_4->text().toUpper().toInt(NULL, 16);
  401. // data_int[data_ctr++] = ui->fieldByte6_4->text().toUpper().toInt(NULL, 16);
  402. // data_int[data_ctr++] = ui->fieldByte7_4->text().toUpper().toInt(NULL, 16);
  403. // data_int[data_ctr++] = ui->fieldByte0_5->text().toUpper().toInt(NULL, 16);
  404. // data_int[data_ctr++] = ui->fieldByte1_5->text().toUpper().toInt(NULL, 16);
  405. // data_int[data_ctr++] = ui->fieldByte2_5->text().toUpper().toInt(NULL, 16);
  406. // data_int[data_ctr++] = ui->fieldByte3_5->text().toUpper().toInt(NULL, 16);
  407. // data_int[data_ctr++] = ui->fieldByte4_5->text().toUpper().toInt(NULL, 16);
  408. // data_int[data_ctr++] = ui->fieldByte5_5->text().toUpper().toInt(NULL, 16);
  409. // data_int[data_ctr++] = ui->fieldByte6_5->text().toUpper().toInt(NULL, 16);
  410. // data_int[data_ctr++] = ui->fieldByte7_5->text().toUpper().toInt(NULL, 16);
  411. // data_int[data_ctr++] = ui->fieldByte0_6->text().toUpper().toInt(NULL, 16);
  412. // data_int[data_ctr++] = ui->fieldByte1_6->text().toUpper().toInt(NULL, 16);
  413. // data_int[data_ctr++] = ui->fieldByte2_6->text().toUpper().toInt(NULL, 16);
  414. // data_int[data_ctr++] = ui->fieldByte3_6->text().toUpper().toInt(NULL, 16);
  415. // data_int[data_ctr++] = ui->fieldByte4_6->text().toUpper().toInt(NULL, 16);
  416. // data_int[data_ctr++] = ui->fieldByte5_6->text().toUpper().toInt(NULL, 16);
  417. // data_int[data_ctr++] = ui->fieldByte6_6->text().toUpper().toInt(NULL, 16);
  418. // data_int[data_ctr++] = ui->fieldByte7_6->text().toUpper().toInt(NULL, 16);
  419. // data_int[data_ctr++] = ui->fieldByte0_7->text().toUpper().toInt(NULL, 16);
  420. // data_int[data_ctr++] = ui->fieldByte1_7->text().toUpper().toInt(NULL, 16);
  421. // data_int[data_ctr++] = ui->fieldByte2_7->text().toUpper().toInt(NULL, 16);
  422. // data_int[data_ctr++] = ui->fieldByte3_7->text().toUpper().toInt(NULL, 16);
  423. // data_int[data_ctr++] = ui->fieldByte4_7->text().toUpper().toInt(NULL, 16);
  424. // data_int[data_ctr++] = ui->fieldByte5_7->text().toUpper().toInt(NULL, 16);
  425. // data_int[data_ctr++] = ui->fieldByte6_7->text().toUpper().toInt(NULL, 16);
  426. // data_int[data_ctr++] = ui->fieldByte7_7->text().toUpper().toInt(NULL, 16);
  427. // uint32_t address = ui->fieldAddress->text().toUpper().toUInt(NULL, 16);
  428. // // If address is beyond std address namespace, force extended
  429. // if(address > 0x7ff)
  430. // {
  431. // en_extended = true;
  432. // ui->checkBox_IsExtended->setChecked(true);
  433. // }
  434. // // If address is larger than max for extended, clip
  435. // if(address >= 0x1FFFFFFF)
  436. // {
  437. // address = address & 0x1FFFFFFF;
  438. // ui->fieldAddress->setText(QString::number( address, 16 ).toUpper());
  439. // }
  440. // uint8_t dlc =ui->comboBoxDLC->currentData().toUInt();
  441. // // If DLC > 8, must be FD
  442. // if(dlc > 8)
  443. // {
  444. // ui->checkbox_FD->setChecked(true);
  445. // }
  446. // // Set payload data
  447. // for(int i=0; i<dlc; i++)
  448. // {
  449. // msg.setDataAt(i, data_int[i]);
  450. // }
  451. // msg.setId(address);
  452. // msg.setLength(dlc);
  453. // msg.setExtended(en_extended);
  454. // msg.setRTR(en_rtr);
  455. // msg.setErrorFrame(false);
  456. // if(ui->checkbox_BRS->isChecked())
  457. // msg.setBRS(true);
  458. // if(ui->checkbox_FD->isChecked())
  459. // msg.setFD(true);
  460. // CanInterface *intf = _backend.getInterfaceById((CanInterfaceId)ui->comboBoxInterface->currentData().toUInt());
  461. // intf->sendMessage(msg);
  462. // char outmsg[256];
  463. // snprintf(outmsg, 256, "Send [%s] to %d on port %s [ext=%u rtr=%u err=%u fd=%u brs=%u]",
  464. // msg.getDataHexString().toLocal8Bit().constData(), msg.getId(), intf->getName().toLocal8Bit().constData(),
  465. // msg.isExtended(), msg.isRTR(), msg.isErrorFrame(), msg.isFD(), msg.isBRS());
  466. // log_info(outmsg);
  467. //}
  468. void RawTxWindow::sendRawMessage()
  469. {
  470. CanMessage msg;
  471. // static uint64_t sendnum=0;
  472. if(filesend_en&&(filesenddata.size()>0)){
  473. if(sendnum<filesenddata.size()){
  474. bool brs=filesenddata[sendnum].isBRS();
  475. msg.setBRS(brs);
  476. bool fd=filesenddata[sendnum].isFD();
  477. msg.setFD(fd);
  478. bool extended=filesenddata[sendnum].isExtended();
  479. msg.setExtended(extended);
  480. bool rtr =filesenddata[sendnum].isRTR();
  481. msg.setRTR(rtr);
  482. bool err = filesenddata[sendnum].isErrorFrame();
  483. msg.setErrorFrame(err);
  484. uint32_t address =filesenddata[sendnum].getId();
  485. msg.setId(address);
  486. uint8_t dlc =filesenddata[sendnum].getLength();
  487. msg.setLength(dlc);
  488. for(int i=0; i<64; i++)
  489. {
  490. msg.setDataAt(i, filesenddata[sendnum].getByte(i));
  491. }
  492. sendnum++;
  493. CanInterface *intf = _backend.getInterfaceById((CanInterfaceId)ui->comboBoxInterface->currentData().toUInt());
  494. // intf->sendMessage(msg);
  495. if((!DriverCmdSendEN)&&(drivercmdID.contains(address))){
  496. }
  497. else{
  498. intf->sendMessage(msg);
  499. }
  500. char outmsg[256];
  501. snprintf(outmsg, 256, "Send [%s] to %d on port %s [ext=%u rtr=%u err=%u fd=%u brs=%u]",
  502. msg.getDataHexString().toLocal8Bit().constData(), msg.getId(), intf->getName().toLocal8Bit().constData(),
  503. msg.isExtended(), msg.isRTR(), msg.isErrorFrame(), msg.isFD(), msg.isBRS());
  504. log_info(outmsg);
  505. }
  506. }
  507. else{
  508. bool en_extended = ui->checkBox_IsExtended->isChecked();
  509. bool en_rtr = ui->checkBox_IsRTR->isChecked();
  510. uint8_t data_int[64];
  511. int data_ctr = 0;
  512. data_int[data_ctr++] = ui->fieldByte0_0->text().toUpper().toInt(NULL, 16);
  513. data_int[data_ctr++] = ui->fieldByte1_0->text().toUpper().toInt(NULL, 16);
  514. data_int[data_ctr++] = ui->fieldByte2_0->text().toUpper().toInt(NULL, 16);
  515. data_int[data_ctr++] = ui->fieldByte3_0->text().toUpper().toInt(NULL, 16);
  516. data_int[data_ctr++] = ui->fieldByte4_0->text().toUpper().toInt(NULL, 16);
  517. data_int[data_ctr++] = ui->fieldByte5_0->text().toUpper().toInt(NULL, 16);
  518. data_int[data_ctr++] = ui->fieldByte6_0->text().toUpper().toInt(NULL, 16);
  519. data_int[data_ctr++] = ui->fieldByte7_0->text().toUpper().toInt(NULL, 16);
  520. data_int[data_ctr++] = ui->fieldByte0_1->text().toUpper().toInt(NULL, 16);
  521. data_int[data_ctr++] = ui->fieldByte1_1->text().toUpper().toInt(NULL, 16);
  522. data_int[data_ctr++] = ui->fieldByte2_1->text().toUpper().toInt(NULL, 16);
  523. data_int[data_ctr++] = ui->fieldByte3_1->text().toUpper().toInt(NULL, 16);
  524. data_int[data_ctr++] = ui->fieldByte4_1->text().toUpper().toInt(NULL, 16);
  525. data_int[data_ctr++] = ui->fieldByte5_1->text().toUpper().toInt(NULL, 16);
  526. data_int[data_ctr++] = ui->fieldByte6_1->text().toUpper().toInt(NULL, 16);
  527. data_int[data_ctr++] = ui->fieldByte7_1->text().toUpper().toInt(NULL, 16);
  528. data_int[data_ctr++] = ui->fieldByte0_2->text().toUpper().toInt(NULL, 16);
  529. data_int[data_ctr++] = ui->fieldByte1_2->text().toUpper().toInt(NULL, 16);
  530. data_int[data_ctr++] = ui->fieldByte2_2->text().toUpper().toInt(NULL, 16);
  531. data_int[data_ctr++] = ui->fieldByte3_2->text().toUpper().toInt(NULL, 16);
  532. data_int[data_ctr++] = ui->fieldByte4_2->text().toUpper().toInt(NULL, 16);
  533. data_int[data_ctr++] = ui->fieldByte5_2->text().toUpper().toInt(NULL, 16);
  534. data_int[data_ctr++] = ui->fieldByte6_2->text().toUpper().toInt(NULL, 16);
  535. data_int[data_ctr++] = ui->fieldByte7_2->text().toUpper().toInt(NULL, 16);
  536. data_int[data_ctr++] = ui->fieldByte0_3->text().toUpper().toInt(NULL, 16);
  537. data_int[data_ctr++] = ui->fieldByte1_3->text().toUpper().toInt(NULL, 16);
  538. data_int[data_ctr++] = ui->fieldByte2_3->text().toUpper().toInt(NULL, 16);
  539. data_int[data_ctr++] = ui->fieldByte3_3->text().toUpper().toInt(NULL, 16);
  540. data_int[data_ctr++] = ui->fieldByte4_3->text().toUpper().toInt(NULL, 16);
  541. data_int[data_ctr++] = ui->fieldByte5_3->text().toUpper().toInt(NULL, 16);
  542. data_int[data_ctr++] = ui->fieldByte6_3->text().toUpper().toInt(NULL, 16);
  543. data_int[data_ctr++] = ui->fieldByte7_3->text().toUpper().toInt(NULL, 16);
  544. data_int[data_ctr++] = ui->fieldByte0_4->text().toUpper().toInt(NULL, 16);
  545. data_int[data_ctr++] = ui->fieldByte1_4->text().toUpper().toInt(NULL, 16);
  546. data_int[data_ctr++] = ui->fieldByte2_4->text().toUpper().toInt(NULL, 16);
  547. data_int[data_ctr++] = ui->fieldByte3_4->text().toUpper().toInt(NULL, 16);
  548. data_int[data_ctr++] = ui->fieldByte4_4->text().toUpper().toInt(NULL, 16);
  549. data_int[data_ctr++] = ui->fieldByte5_4->text().toUpper().toInt(NULL, 16);
  550. data_int[data_ctr++] = ui->fieldByte6_4->text().toUpper().toInt(NULL, 16);
  551. data_int[data_ctr++] = ui->fieldByte7_4->text().toUpper().toInt(NULL, 16);
  552. data_int[data_ctr++] = ui->fieldByte0_5->text().toUpper().toInt(NULL, 16);
  553. data_int[data_ctr++] = ui->fieldByte1_5->text().toUpper().toInt(NULL, 16);
  554. data_int[data_ctr++] = ui->fieldByte2_5->text().toUpper().toInt(NULL, 16);
  555. data_int[data_ctr++] = ui->fieldByte3_5->text().toUpper().toInt(NULL, 16);
  556. data_int[data_ctr++] = ui->fieldByte4_5->text().toUpper().toInt(NULL, 16);
  557. data_int[data_ctr++] = ui->fieldByte5_5->text().toUpper().toInt(NULL, 16);
  558. data_int[data_ctr++] = ui->fieldByte6_5->text().toUpper().toInt(NULL, 16);
  559. data_int[data_ctr++] = ui->fieldByte7_5->text().toUpper().toInt(NULL, 16);
  560. data_int[data_ctr++] = ui->fieldByte0_6->text().toUpper().toInt(NULL, 16);
  561. data_int[data_ctr++] = ui->fieldByte1_6->text().toUpper().toInt(NULL, 16);
  562. data_int[data_ctr++] = ui->fieldByte2_6->text().toUpper().toInt(NULL, 16);
  563. data_int[data_ctr++] = ui->fieldByte3_6->text().toUpper().toInt(NULL, 16);
  564. data_int[data_ctr++] = ui->fieldByte4_6->text().toUpper().toInt(NULL, 16);
  565. data_int[data_ctr++] = ui->fieldByte5_6->text().toUpper().toInt(NULL, 16);
  566. data_int[data_ctr++] = ui->fieldByte6_6->text().toUpper().toInt(NULL, 16);
  567. data_int[data_ctr++] = ui->fieldByte7_6->text().toUpper().toInt(NULL, 16);
  568. data_int[data_ctr++] = ui->fieldByte0_7->text().toUpper().toInt(NULL, 16);
  569. data_int[data_ctr++] = ui->fieldByte1_7->text().toUpper().toInt(NULL, 16);
  570. data_int[data_ctr++] = ui->fieldByte2_7->text().toUpper().toInt(NULL, 16);
  571. data_int[data_ctr++] = ui->fieldByte3_7->text().toUpper().toInt(NULL, 16);
  572. data_int[data_ctr++] = ui->fieldByte4_7->text().toUpper().toInt(NULL, 16);
  573. data_int[data_ctr++] = ui->fieldByte5_7->text().toUpper().toInt(NULL, 16);
  574. data_int[data_ctr++] = ui->fieldByte6_7->text().toUpper().toInt(NULL, 16);
  575. data_int[data_ctr++] = ui->fieldByte7_7->text().toUpper().toInt(NULL, 16);
  576. uint32_t address = ui->fieldAddress->text().toUpper().toUInt(NULL, 16);
  577. // If address is beyond std address namespace, force extended
  578. if(address > 0x7ff)
  579. {
  580. en_extended = true;
  581. ui->checkBox_IsExtended->setChecked(true);
  582. }
  583. // If address is larger than max for extended, clip
  584. if(address >= 0x1FFFFFFF)
  585. {
  586. address = address & 0x1FFFFFFF;
  587. ui->fieldAddress->setText(QString::number( address, 16 ).toUpper());
  588. }
  589. uint8_t dlc =ui->comboBoxDLC->currentData().toUInt();
  590. // If DLC > 8, must be FD
  591. if(dlc > 8)
  592. {
  593. ui->checkbox_FD->setChecked(true);
  594. }
  595. // Set payload data
  596. for(int i=0; i<dlc; i++)
  597. {
  598. msg.setDataAt(i, data_int[i]);
  599. }
  600. msg.setId(address);
  601. msg.setLength(dlc);
  602. #ifdef CHECK_FOR_CHERRY
  603. setcheck(msg);
  604. #endif
  605. msg.setExtended(en_extended);
  606. msg.setRTR(en_rtr);
  607. msg.setErrorFrame(false);
  608. if(ui->checkbox_BRS->isChecked())
  609. msg.setBRS(true);
  610. if(ui->checkbox_FD->isChecked())
  611. msg.setFD(true);
  612. CanInterface *intf = _backend.getInterfaceById((CanInterfaceId)ui->comboBoxInterface->currentData().toUInt());
  613. if((!DriverCmdSendEN)&&(drivercmdID.contains(address))){
  614. }
  615. else{
  616. intf->sendMessage(msg);
  617. }
  618. char outmsg[256];
  619. snprintf(outmsg, 256, "Send [%s] to %d on port %s [ext=%u rtr=%u err=%u fd=%u brs=%u]",
  620. msg.getDataHexString().toLocal8Bit().constData(), msg.getId(), intf->getName().toLocal8Bit().constData(),
  621. msg.isExtended(), msg.isRTR(), msg.isErrorFrame(), msg.isFD(), msg.isBRS());
  622. log_info(outmsg);
  623. }
  624. }
  625. bool RawTxWindow::saveXML(Backend &backend, QDomDocument &xml, QDomElement &root)
  626. {
  627. if (!ConfigurableWidget::saveXML(backend, xml, root)) { return false; }
  628. root.setAttribute("type", "RawTxWindow");
  629. return true;
  630. }
  631. bool RawTxWindow::loadXML(Backend &backend, QDomElement &el)
  632. {
  633. if (!ConfigurableWidget::loadXML(backend, el)) { return false; }
  634. return true;
  635. }
  636. void RawTxWindow::hideFDFields()
  637. {
  638. ui->label_col21->hide();
  639. ui->label_col22->hide();
  640. ui->label_col23->hide();
  641. ui->label_col24->hide();
  642. ui->label_col25->hide();
  643. ui->label_col26->hide();
  644. ui->label_col27->hide();
  645. ui->label_col28->hide();
  646. ui->label_pay2->hide();
  647. ui->label_pay3->hide();
  648. ui->label_pay4->hide();
  649. ui->label_pay5->hide();
  650. ui->label_pay6->hide();
  651. ui->label_pay7->hide();
  652. ui->label_pay8->hide();
  653. ui->fieldByte0_1->hide();
  654. ui->fieldByte1_1->hide();
  655. ui->fieldByte2_1->hide();
  656. ui->fieldByte3_1->hide();
  657. ui->fieldByte4_1->hide();
  658. ui->fieldByte5_1->hide();
  659. ui->fieldByte6_1->hide();
  660. ui->fieldByte7_1->hide();
  661. ui->fieldByte0_2->hide();
  662. ui->fieldByte1_2->hide();
  663. ui->fieldByte2_2->hide();
  664. ui->fieldByte3_2->hide();
  665. ui->fieldByte4_2->hide();
  666. ui->fieldByte5_2->hide();
  667. ui->fieldByte6_2->hide();
  668. ui->fieldByte7_2->hide();
  669. ui->fieldByte0_3->hide();
  670. ui->fieldByte1_3->hide();
  671. ui->fieldByte2_3->hide();
  672. ui->fieldByte3_3->hide();
  673. ui->fieldByte4_3->hide();
  674. ui->fieldByte5_3->hide();
  675. ui->fieldByte6_3->hide();
  676. ui->fieldByte7_3->hide();
  677. ui->fieldByte0_4->hide();
  678. ui->fieldByte1_4->hide();
  679. ui->fieldByte2_4->hide();
  680. ui->fieldByte3_4->hide();
  681. ui->fieldByte4_4->hide();
  682. ui->fieldByte5_4->hide();
  683. ui->fieldByte6_4->hide();
  684. ui->fieldByte7_4->hide();
  685. ui->fieldByte0_5->hide();
  686. ui->fieldByte1_5->hide();
  687. ui->fieldByte2_5->hide();
  688. ui->fieldByte3_5->hide();
  689. ui->fieldByte4_5->hide();
  690. ui->fieldByte5_5->hide();
  691. ui->fieldByte6_5->hide();
  692. ui->fieldByte7_5->hide();
  693. ui->fieldByte0_6->hide();
  694. ui->fieldByte1_6->hide();
  695. ui->fieldByte2_6->hide();
  696. ui->fieldByte3_6->hide();
  697. ui->fieldByte4_6->hide();
  698. ui->fieldByte5_6->hide();
  699. ui->fieldByte6_6->hide();
  700. ui->fieldByte7_6->hide();
  701. ui->fieldByte0_7->hide();
  702. ui->fieldByte1_7->hide();
  703. ui->fieldByte2_7->hide();
  704. ui->fieldByte3_7->hide();
  705. ui->fieldByte4_7->hide();
  706. ui->fieldByte5_7->hide();
  707. ui->fieldByte6_7->hide();
  708. ui->fieldByte7_7->hide();
  709. }
  710. void RawTxWindow::showFDFields()
  711. {
  712. ui->label_col21->show();
  713. ui->label_col22->show();
  714. ui->label_col23->show();
  715. ui->label_col24->show();
  716. ui->label_col25->show();
  717. ui->label_col26->show();
  718. ui->label_col27->show();
  719. ui->label_col28->show();
  720. ui->label_pay2->show();
  721. ui->label_pay3->show();
  722. ui->label_pay4->show();
  723. ui->label_pay5->show();
  724. ui->label_pay6->show();
  725. ui->label_pay7->show();
  726. ui->label_pay8->show();
  727. ui->fieldByte0_1->show();
  728. ui->fieldByte1_1->show();
  729. ui->fieldByte2_1->show();
  730. ui->fieldByte3_1->show();
  731. ui->fieldByte4_1->show();
  732. ui->fieldByte5_1->show();
  733. ui->fieldByte6_1->show();
  734. ui->fieldByte7_1->show();
  735. ui->fieldByte0_2->show();
  736. ui->fieldByte1_2->show();
  737. ui->fieldByte2_2->show();
  738. ui->fieldByte3_2->show();
  739. ui->fieldByte4_2->show();
  740. ui->fieldByte5_2->show();
  741. ui->fieldByte6_2->show();
  742. ui->fieldByte7_2->show();
  743. ui->fieldByte0_3->show();
  744. ui->fieldByte1_3->show();
  745. ui->fieldByte2_3->show();
  746. ui->fieldByte3_3->show();
  747. ui->fieldByte4_3->show();
  748. ui->fieldByte5_3->show();
  749. ui->fieldByte6_3->show();
  750. ui->fieldByte7_3->show();
  751. ui->fieldByte0_4->show();
  752. ui->fieldByte1_4->show();
  753. ui->fieldByte2_4->show();
  754. ui->fieldByte3_4->show();
  755. ui->fieldByte4_4->show();
  756. ui->fieldByte5_4->show();
  757. ui->fieldByte6_4->show();
  758. ui->fieldByte7_4->show();
  759. ui->fieldByte0_5->show();
  760. ui->fieldByte1_5->show();
  761. ui->fieldByte2_5->show();
  762. ui->fieldByte3_5->show();
  763. ui->fieldByte4_5->show();
  764. ui->fieldByte5_5->show();
  765. ui->fieldByte6_5->show();
  766. ui->fieldByte7_5->show();
  767. ui->fieldByte0_6->show();
  768. ui->fieldByte1_6->show();
  769. ui->fieldByte2_6->show();
  770. ui->fieldByte3_6->show();
  771. ui->fieldByte4_6->show();
  772. ui->fieldByte5_6->show();
  773. ui->fieldByte6_6->show();
  774. ui->fieldByte7_6->show();
  775. ui->fieldByte0_7->show();
  776. ui->fieldByte1_7->show();
  777. ui->fieldByte2_7->show();
  778. ui->fieldByte3_7->show();
  779. ui->fieldByte4_7->show();
  780. ui->fieldByte5_7->show();
  781. ui->fieldByte6_7->show();
  782. ui->fieldByte7_7->show();
  783. }
  784. void RawTxWindow::fileAdd()
  785. {
  786. CanMessage msg;//
  787. // QVector<CanMessage> senddata;
  788. filesenddata.clear();
  789. QString filename = QFileDialog::getOpenFileName(this, "添加待发送的文件", "", "(*.txt)");
  790. if (!filename.isNull())
  791. {
  792. ui->filePathlineEdit->setText(filename);
  793. QFile *sendfile = new QFile(filename);
  794. if(!sendfile->open(QFile::ReadOnly)){
  795. return;
  796. }
  797. QTextStream in(sendfile);
  798. QString line = in.readLine();
  799. while (!in.atEnd())
  800. {
  801. //发送使能1发送0不发送,是否CANFD1是0不是,打开位速率转换开关1打开0关闭,0标准帧1扩展帧,0数据帧1远程帧,帧ID(HEX),数据长度,数据1 数据2 数据3(hex)....
  802. //如果数据长度大于8默认是CANFD,CANFD一般没有远程帧,
  803. QString line = in.readLine();
  804. QStringList list =line.split(",",QString::SkipEmptyParts);
  805. if((list.size()==8)&&(list[0]=="1"))
  806. {
  807. //帧ID
  808. uint32_t address = list[5].toUpper().toUInt(NULL, 16);
  809. msg.setId(address); //一定要先设定ID,因为后面一些标志位的设置和ID有关,如果放到最后设置,导致某些标志位出错,后面数据拷贝也会出错,切记
  810. //使能FD
  811. if(list[1]=="1")
  812. msg.setFD(true);
  813. else
  814. msg.setFD(false);
  815. //FD的时候打开BRS
  816. if(list[2]=="1")
  817. msg.setBRS(true);
  818. else
  819. msg.setBRS(false);
  820. // //标准帧还是扩展帧
  821. if(list[3]=="1")
  822. msg.setExtended(true);
  823. else
  824. msg.setExtended(false);
  825. //数据帧还是远程帧
  826. if((list[4]=="1")&&(list[1]!="1"))
  827. msg.setRTR(true);
  828. else
  829. msg.setRTR(false);
  830. //数据长度
  831. uint8_t dlc =list[6].toUInt();
  832. msg.setLength(dlc);
  833. //数据
  834. QString dataString = list[7];
  835. QStringList datalist =dataString.split(" ",QString::SkipEmptyParts);
  836. if(datalist.size()!=dlc)
  837. {
  838. continue;
  839. }
  840. for(int i=0; i<datalist.size(); i++)
  841. {
  842. msg.setDataAt(i, datalist[i].toUpper().toUInt(NULL, 16));
  843. }
  844. }
  845. msg.setErrorFrame(false);
  846. filesenddata.push_back(msg);
  847. // char outmsg[256];
  848. // snprintf(outmsg, 256, "Send [%s] to %d on port %s [ext=%u rtr=%u err=%u fd=%u brs=%u]",
  849. // msg.getDataHexString().toLocal8Bit().constData(), msg.getId(), intf->getName().toLocal8Bit().constData(),
  850. // msg.isExtended(), msg.isRTR(), msg.isErrorFrame(), msg.isFD(), msg.isBRS());
  851. // log_info(outmsg);
  852. }
  853. sendfile->close();
  854. }
  855. else{
  856. }
  857. }
  858. void RawTxWindow::fileSend(bool enable)
  859. {
  860. //if(ui->fileSendButton->isCheckable()==true)
  861. if(enable)
  862. {
  863. // ui->filePathlineEdit->setText("OK");
  864. repeatmsg_timer->start(ui->spinBox_RepeatRate->value());
  865. filesend_en=true;
  866. sendnum=0;
  867. }
  868. else
  869. {
  870. // ui->filePathlineEdit->setText("close");
  871. repeatmsg_timer->stop();
  872. filesend_en=false;
  873. sendnum=0;
  874. }
  875. }
  876. #ifdef CHECK_FOR_CHERRY
  877. void RawTxWindow::setcheck(CanMessage &xmsg)
  878. {
  879. if(xmsg.getId() == 0x159)
  880. {
  881. }
  882. }
  883. #endif