Refactor
This commit is contained in:
23
experiments/can/can_send.h
Normal file
23
experiments/can/can_send.h
Normal file
@@ -0,0 +1,23 @@
|
||||
#ifndef MULTITHREAD_EXPERIMENTS_CAN_SEND_H
|
||||
#define MULTITHREAD_EXPERIMENTS_CAN_SEND_H
|
||||
|
||||
#include "pcan/peakcandevice.h"
|
||||
#include <chrono>
|
||||
|
||||
float test_send(int device_id) {
|
||||
PeakCANDevice canDevice(PeakCANDevice::CAN_SPEED_500K, device_id);
|
||||
if (!canDevice.open()) {
|
||||
return 0.f;
|
||||
}
|
||||
|
||||
auto start = std::chrono::high_resolution_clock::now();
|
||||
CAN_Raw msg = { .Id = 0x72, .Size = 8, .Data = { 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7 } };
|
||||
for (int i = 0; i < 30 * 1000; ++i) {
|
||||
canDevice.send(msg);
|
||||
}
|
||||
auto end = std::chrono::high_resolution_clock::now();
|
||||
|
||||
return std::chrono::duration_cast<std::chrono::microseconds>(end - start).count() / 1000.f;
|
||||
}
|
||||
|
||||
#endif //MULTITHREAD_EXPERIMENTS_CAN_SEND_H
|
||||
Reference in New Issue
Block a user