candleLight, CANable, CANnectivity and cantact adapters speak gs_usb. On Linux and macOS the kernel driver exposes them as SocketCAN interfaces, so SavvyCAN already reached them through Qt SerialBus. Windows has no such driver, which left those adapters unusable there. Add a GSUSBConnection that talks to the hardware directly over WinUSB: - one connection per physical device, one SavvyCAN bus per CAN channel - CAN FD including BRS, plus RTR, extended IDs and error frames - known good bit timings for 16/48/80/160/170 MHz device clocks, with a generic solver for clocks the tables do not cover - hardware timestamps, unwrapped across the 32 bit rollover and anchored to the host clock so they line up with the rest of SavvyCAN gs_usb multiplexes every channel over a single USB bulk IN endpoint, so a single reader thread drains it and hands frames to the connection thread in batches, coalescing the wakeups. That keeps one producer on the lock free queue, which the tx echo path already writes to. Device scans skip adapters that a live connection holds. candle_dev_open() shares the file handle and queues read URBs immediately, so probing a device in use would consume frames the open connection is waiting for. connections/candle_api is an unmodified copy of the candle Windows API, LGPL 3.0 rather than MIT and only compiled into Windows builds. See its README for provenance. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XZnuZJ7zc3e8hk6C8bGDZN
48 lines
1.5 KiB
C++
48 lines
1.5 KiB
C++
#include <QString>
|
|
#include "canconfactory.h"
|
|
#include "serialbusconnection.h"
|
|
#include "gvretserial.h"
|
|
#include "mqtt_bus.h"
|
|
#include "socketcand.h"
|
|
#include "lawicel_serial.h"
|
|
#include "canserver.h"
|
|
#include "canlogserver.h"
|
|
#include "gs_usb.h"
|
|
|
|
using namespace CANCon;
|
|
|
|
CANConnection* CanConFactory::create(type pType, QString pPortName, QString pDriverName, int pSerialSpeed, int pBusSpeed, bool pCanFd, int pDataRate)
|
|
{
|
|
switch(pType) {
|
|
case SERIALBUS:
|
|
return new SerialBusConnection(pPortName, pDriverName, pBusSpeed, pDataRate, pCanFd);
|
|
case GVRET_SERIAL:
|
|
if(pPortName.contains(".") && !pPortName.contains("tty") && !pPortName.contains("serial"))
|
|
return new GVRetSerial(pPortName, true);
|
|
else
|
|
return new GVRetSerial(pPortName, false);
|
|
case REMOTE:
|
|
return new GVRetSerial(pPortName, true); //it's a special case of GVRET connected over TCP/IP so it uses the same class
|
|
case LAWICEL:
|
|
return new LAWICELSerial(pPortName, pSerialSpeed, pBusSpeed, pCanFd, pDataRate);
|
|
case KAYAK:
|
|
return new SocketCANd(pPortName);
|
|
case MQTT:
|
|
return new MQTT_BUS(pPortName);
|
|
case CANSERVER:
|
|
return new CANserver(pPortName);
|
|
case CANLOGSERVER:
|
|
return new CanLogServer(pPortName);
|
|
case GS_USB:
|
|
#ifdef Q_OS_WIN
|
|
return new GSUSBConnection(pPortName, pBusSpeed, pCanFd, pDataRate);
|
|
#else
|
|
//everywhere else gs_usb devices are handled by the kernel driver and show up as SocketCAN
|
|
return nullptr;
|
|
#endif
|
|
default: {}
|
|
}
|
|
|
|
return nullptr;
|
|
}
|