51 if (
nullptr != device && device->isOpen)
57 bool allChannelsClosed =
true;
58 for (
int i = 0; i <
driverInstance->getInnoMakerDeviceCount(); i++)
63 allChannelsClosed =
false;
67 if (allChannelsClosed)
69 LOG_INFO(
"[InnoMaker-Windows] All channels closed, closing driver instance");
80 if (
nullptr != device)
91 InnoMakerUsb2CanLib::Innomaker_device_bittming bitTiming;
96 bitTiming.prop_seg = 6;
97 bitTiming.phase_seg1 = 7;
98 bitTiming.phase_seg2 = 2;
105 bitTiming.prop_seg = 3;
106 bitTiming.phase_seg1 = 3;
107 bitTiming.phase_seg2 = 1;
114 bitTiming.prop_seg = 6;
115 bitTiming.phase_seg1 = 7;
116 bitTiming.phase_seg2 = 2;
123 bitTiming.prop_seg = 6;
124 bitTiming.phase_seg1 = 7;
125 bitTiming.phase_seg2 = 2;
132 bitTiming.prop_seg = 3;
133 bitTiming.phase_seg1 = 3;
134 bitTiming.phase_seg2 = 1;
141 bitTiming.prop_seg = 3;
142 bitTiming.phase_seg1 = 3;
143 bitTiming.phase_seg2 = 1;
150 bitTiming.prop_seg = 3;
151 bitTiming.phase_seg1 = 3;
152 bitTiming.phase_seg2 = 1;
159 bitTiming.prop_seg = 6;
160 bitTiming.phase_seg1 = 7;
161 bitTiming.phase_seg2 = 2;
168 bitTiming.prop_seg = 6;
169 bitTiming.phase_seg1 = 7;
170 bitTiming.phase_seg2 = 2;
177 bitTiming.prop_seg = 6;
178 bitTiming.phase_seg1 = 7;
179 bitTiming.phase_seg2 = 2;
186 bitTiming.prop_seg = 6;
187 bitTiming.phase_seg1 = 7;
188 bitTiming.phase_seg2 = 2;
195 bitTiming.prop_seg = 3;
196 bitTiming.phase_seg1 = 3;
197 bitTiming.phase_seg2 = 1;
204 bitTiming.prop_seg = 6;
205 bitTiming.phase_seg1 = 7;
206 bitTiming.phase_seg2 = 2;
213 bitTiming.prop_seg = 3;
214 bitTiming.phase_seg1 = 3;
215 bitTiming.phase_seg2 = 2;
222 bitTiming.prop_seg = 7;
223 bitTiming.phase_seg1 = 8;
224 bitTiming.phase_seg2 = 4;
231 bitTiming.prop_seg = 5;
232 bitTiming.phase_seg1 = 6;
233 bitTiming.phase_seg2 = 4;
241 LOG_ERROR(
"[InnoMaker-Windows] Unsupported baudrate with index " + isobus::to_string(
baudrate) +
" in InnoMakerUSB2CANWindowsPlugin::Baudrate enum.");
251 LOG_ERROR(
"[InnoMaker-Windows] No device found on channel " + isobus::to_string(
channel));
259 if (
nullptr == device)
263 BYTE receiveBuffer[
sizeof(InnoMakerUsb2CanLib::innomaker_host_frame)];
264 bool success =
driverInstance->recvInnoMakerDeviceBuf(device, receiveBuffer,
sizeof(InnoMakerUsb2CanLib::innomaker_host_frame), 0xFFFFFFFF);
270 InnoMakerUsb2CanLib::innomaker_host_frame frame;
271 memcpy(&frame, receiveBuffer,
sizeof(InnoMakerUsb2CanLib::innomaker_host_frame));
273 if (0xFFFFFFFF != frame.echo_id)
275 InnoMakerUsb2CanLib::innomaker_tx_context *txc =
driverInstance->innomaker_get_tx_context(
txContexts.get(), frame.echo_id);
278 LOG_WARNING(
"[InnoMaker-Windows] Received frame with bad echo ID: " + isobus::to_string(
static_cast<int>(frame.echo_id)));
305 if (
nullptr == device)
311 if (0xFF == txc->echo_id)
313 LOG_DEBUG(
"[InnoMaker-Windows] No free transmission context");
317 InnoMakerUsb2CanLib::innomaker_host_frame frame;
318 memset(&frame, 0,
sizeof(InnoMakerUsb2CanLib::innomaker_host_frame));
320 frame.echo_id = txc->echo_id;
330 BYTE sendBuffer[
sizeof(InnoMakerUsb2CanLib::innomaker_host_frame)];
331 memcpy(sendBuffer, &frame,
sizeof(InnoMakerUsb2CanLib::innomaker_host_frame));
333 bool success =
driverInstance->sendInnoMakerDeviceBuf(device, sendBuffer,
sizeof(InnoMakerUsb2CanLib::innomaker_host_frame), 10);
336 LOG_WARNING(
"[InnoMaker-Windows] Failed to send frame");