Compare commits

...

6 Commits

Author SHA1 Message Date
vits71 584f524823
Merge 739ff4d637 into 52e98af9fd 2025-03-27 18:33:43 -04:00
Jonathan Schwartz 52e98af9fd Device: Add RAD-EpsilonXL 2025-03-25 20:43:18 +00:00
Jonathan Schwartz e1a0ca056a Communication: Ignore empty LIN frames for checksum 2025-03-21 18:04:45 +00:00
Kyle Schwarz 538d6ec0c8 Communication: Remove unused parameter 2025-03-17 23:12:25 -04:00
vits71 739ff4d637
Merge branch 'intrepidcs:master' into Npcap-fix 2025-01-11 23:15:28 +01:00
Vít Šembera e233233b94 Fixed Npcap related errors in PCAPDLL::PCAPDLL() 2024-07-18 13:26:39 +02:00
13 changed files with 222 additions and 7 deletions

View File

@ -13,7 +13,7 @@ option(LIBICSNEO_BUILD_ICSNEOC "Build dynamic C library" ON)
option(LIBICSNEO_BUILD_ICSNEOC_STATIC "Build static C library" ON)
option(LIBICSNEO_BUILD_ICSNEOLEGACY "Build icsnVC40 compatibility library" ON)
option(LIBICSNEO_BUILD_ICSNEOLEGACY_STATIC "Build static icsnVC40 compatibility library" ON)
set(LIBICSNEO_NPCAP_INCLUDE_DIR "" CACHE STRING "Npcap include directory; set to build with Npcap")
set(LIBICSNEO_NPCAP_INCLUDE_DIR "C:/Users/Vit/source/repos/npcap-sdk-1.13/Include" CACHE STRING "Npcap include directory; set to build with Npcap")
# Device Drivers
# You almost certainly don't want firmio for your build,

View File

@ -23,6 +23,8 @@ each of the respective APIs.
- RAD-A2B
- RAD-Comet 2
- RAD-Comet 3
- RAD-Epsilon
- RAD-EpsilonXL
- RAD-Galaxy
- RAD-Galaxy 2
- RAD-Gigastar

View File

@ -33,6 +33,7 @@ void init_devicetype(pybind11::module_& m) {
.value("EtherBADGE", DeviceType::Enum::EtherBADGE)
.value("RAD_A2B", DeviceType::Enum::RAD_A2B)
.value("RADEpsilon", DeviceType::Enum::RADEpsilon)
.value("RADEpsilonXL", DeviceType::Enum::RADEpsilonXL)
.value("RADGalaxy2", DeviceType::Enum::RADGalaxy2)
.value("RADMoon3", DeviceType::Enum::RADMoon3)
.value("RADComet", DeviceType::Enum::RADComet)

View File

@ -31,7 +31,7 @@ std::shared_ptr<Message> HardwareLINPacket::DecodeToMessage(const std::vector<ui
auto isChecksumInvalid = [&]() -> bool {
/* messages with no data have no checksum (e.g. header only) */
if(!msg->data.size())
return true;
return false;
uint8_t checkSum = (8 > numDataBytes) ? *(dataStart + numDataBytes) : packet->CoreMiniBitsLIN.LINByte9;
LINMessage::calcChecksum(*msg);

View File

@ -193,6 +193,10 @@ std::vector<std::shared_ptr<Device>> DeviceFinder::FindAll() {
makeIfSerialMatches<RADEpsilon>(dev, newFoundDevices);
#endif
#ifdef __RADEPSILONXL_H_
makeIfSerialMatches<RADEpsilonXL>(dev, newFoundDevices);
#endif
#ifdef __RADGALAXY_H_
makeIfSerialMatches<RADGalaxy>(dev, newFoundDevices);
#endif
@ -352,6 +356,10 @@ const std::vector<DeviceType>& DeviceFinder::GetSupportedDevices() {
RADEpsilon::DEVICE_TYPE,
#endif
#ifdef __RADEPSILONXL_H_
RADEpsilonXL::DEVICE_TYPE,
#endif
#ifdef __RADGALAXY_H_
RADGalaxy::DEVICE_TYPE,
#endif

View File

@ -126,13 +126,13 @@ public:
) {}
StreamOutput(const char* filename) :
MessageCallback([](std::shared_ptr<Message> msg) {}),
MessageCallback([](std::shared_ptr<Message>) {}),
stream(
new std::ofstream(filename, std::ios::binary),
std::default_delete<std::ostream>()
) {}
StreamOutput(std::ostream& os) : MessageCallback([](std::shared_ptr<Message> msg) {}), stream(&os, [](std::ostream*){}) {}
StreamOutput(std::ostream& os) : MessageCallback([](std::shared_ptr<Message>) {}), stream(&os, [](std::ostream*){}) {}
protected:
std::unique_ptr<std::ostream, std::function<void(std::ostream*)>> stream;

View File

@ -47,6 +47,7 @@ public:
EtherBADGE = (0x00000016),
RAD_A2B = (0x00000017),
RADEpsilon = (0x00000018),
RADEpsilonXL = (0x0000001e),
RADGalaxy2 = (0x00000021),
RADMoon3 = (0x00000023),
RADComet = (0x00000024),
@ -141,6 +142,8 @@ public:
return "RAD-A2B";
case RADEpsilon:
return "RAD-Epsilon";
case RADEpsilonXL:
return "RAD-EpsilonXL";
case RADMoon3:
return "RAD-Moon 3";
case RADComet:
@ -251,6 +254,7 @@ private:
#define ICSNEO_DEVICETYPE_ETHERBADGE ((devicetype_t)0x00000016)
#define ICSNEO_DEVICETYPE_RAD_A2B ((devicetype_t)0x00000017)
#define ICSNEO_DEVICETYPE_RADEPSILON ((devicetype_t)0x00000018)
#define ICSNEO_DEVICETYPE_RADEPSILONXL ((devicetype_t)0x0000001e)
#define ICSNEO_DEVICETYPE_RADGALAXY2 ((devicetype_t)0x00000021)
#define ICSNEO_DEVICETYPE_RADMoon3 ((devicetype_t)0x00000023)
#define ICSNEO_DEVICETYPE_RADCOMET ((devicetype_t)0x00000024)

View File

@ -3,6 +3,7 @@
#include "icsneo/device/device.h"
#include "icsneo/device/devicetype.h"
#include "icsneo/device/tree/radepsilon/radepsilonsettings.h"
namespace icsneo {
@ -28,7 +29,7 @@ public:
protected:
RADEpsilon(neodevice_t neodevice, const driver_factory_t& makeDriver) : Device(neodevice) {
initialize(makeDriver);
initialize<RADEpsilonSettings, Disk::NeoMemoryDiskDriver, Disk::NeoMemoryDiskDriver>(makeDriver);
}
virtual void setupEncoder(Encoder& encoder) override {

View File

@ -0,0 +1,131 @@
#ifndef __RADEPSILONSETTINGS_H_
#define __RADEPSILONSETTINGS_H_
#include <stdint.h>
#include "icsneo/device/idevicesettings.h"
#include "icsneo/communication/network.h"
#ifdef __cplusplus
namespace icsneo {
#endif
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable : 4201) // nameless struct/union
#endif
#pragma pack(push, 2)
#define RADEPSILON_MAX_PHY 18
typedef struct {
uint8_t phyMode[RADEPSILON_MAX_PHY];
uint8_t enablePhy[RADEPSILON_MAX_PHY];
uint8_t speed[RADEPSILON_MAX_PHY];
uint8_t legacy[RADEPSILON_MAX_PHY];
uint8_t spoofedMac[6];
uint8_t spoofMacFlag;
uint8_t pad;
} radepsilon_switch_settings_t;
typedef struct {
/* Performance Test */
uint16_t perf_en;
CAN_SETTINGS can1;
CANFD_SETTINGS canfd1;
CAN_SETTINGS can2;
CANFD_SETTINGS canfd2;
LIN_SETTINGS lin1;
uint16_t network_enables[3];
uint64_t termination_enables;
uint16_t misc_io_analog_enable;
uint32_t pwr_man_timeout;
uint16_t pwr_man_enable;
uint16_t network_enabled_on_boot;
/* ISO15765-2 Transport Layer */
int16_t iso15765_separation_time_offset;
uint16_t iso9141_kwp_enable_reserved;
uint16_t iso_tester_pullup_enable;
uint16_t iso_parity;
uint16_t iso_msg_termination;
ISO9141_KEYWORD2000_SETTINGS iso9141_kwp_settings;
ETHERNET_SETTINGS ethernet;
STextAPISettings text_api;
struct
{
uint32_t disableUsbCheckOnBoot : 1;
uint32_t enableLatencyTest : 1;
uint32_t enablePcEthernetComm : 1;
uint32_t reserved : 29;
} flags;
radepsilon_switch_settings_t switchSettings;
ETHERNET_SETTINGS2 ethernet2;
uint16_t misc_io_on_report_events;
DISK_SETTINGS disk;
} radepsilon_settings_t;
#pragma pack(pop)
#ifdef _MSC_VER
#pragma warning(pop)
#endif
#ifdef __cplusplus
#include <iostream>
class RADEpsilonSettings : public IDeviceSettings {
public:
RADEpsilonSettings(std::shared_ptr<Communication> com) : IDeviceSettings(com, sizeof(radepsilon_settings_t)) {}
const CAN_SETTINGS* getCANSettingsFor(Network net) const override {
auto cfg = getStructurePointer<radepsilon_settings_t>();
if(cfg == nullptr)
return nullptr;
switch(net.getNetID()) {
case Network::NetID::HSCAN:
return &(cfg->can1);
case Network::NetID::HSCAN2:
return &(cfg->can2);
default:
return nullptr;
}
}
const CANFD_SETTINGS* getCANFDSettingsFor(Network net) const override {
auto cfg = getStructurePointer<radepsilon_settings_t>();
if(cfg == nullptr)
return nullptr;
switch(net.getNetID()) {
case Network::NetID::HSCAN:
return &(cfg->canfd1);
case Network::NetID::HSCAN2:
return &(cfg->canfd2);
default:
return nullptr;
}
}
const LIN_SETTINGS* getLINSettingsFor(Network net) const override {
auto cfg = getStructurePointer<radepsilon_settings_t>();
if(cfg == nullptr)
return nullptr;
switch(net.getNetID()) {
case Network::NetID::LIN:
return &(cfg->lin1);
default:
return nullptr;
}
}
};
}; // namespace icsneo
#endif // __cplusplus
#endif // __RADEPSILONSETTINGS_H_

View File

@ -0,0 +1,63 @@
#ifndef __RADEPSILONXL_H_
#define __RADEPSILONXL_H_
#include "icsneo/device/device.h"
#include "icsneo/device/devicetype.h"
#include "icsneo/device/tree/radepsilon/radepsilonsettings.h" // Shared settings with RADEpsilon
namespace icsneo {
class RADEpsilonXL : public Device {
public:
// Serial numbers start with PX
// USB PID is 0x1109, standard driver is CDCACM
ICSNEO_FINDABLE_DEVICE(RADEpsilonXL, DeviceType::RADEpsilonXL, "PX");
static const std::vector<Network>& GetSupportedNetworks() {
static std::vector<Network> supportedNetworks = {
Network::NetID::HSCAN,
Network::NetID::HSCAN2,
Network::NetID::Ethernet, // Connected to port 6 on the switch
Network::NetID::LIN
};
return supportedNetworks;
}
bool supportsComponentVersions() const override { return true; }
protected:
RADEpsilonXL(neodevice_t neodevice, const driver_factory_t& makeDriver) : Device(neodevice) {
initialize<RADEpsilonSettings, Disk::NeoMemoryDiskDriver, Disk::NeoMemoryDiskDriver>(makeDriver);
}
virtual void setupEncoder(Encoder& encoder) override {
Device::setupEncoder(encoder);
encoder.supportCANFD = true;
}
void setupSupportedRXNetworks(std::vector<Network>& rxNetworks) override {
for(auto& netid : GetSupportedNetworks())
rxNetworks.emplace_back(netid);
}
// The supported TX networks are the same as the supported RX networks for this device
void setupSupportedTXNetworks(std::vector<Network>& txNetworks) override { setupSupportedRXNetworks(txNetworks); }
std::optional<MemoryAddress> getCoreminiStartAddressFlash() const override {
return 14*1024*1024;
}
std::optional<MemoryAddress> getCoreminiStartAddressSD() const override {
return 0;
}
bool supportsEraseMemory() const override {
return true;
}
};
}; // namespace icsneo
#endif // __RADEPSILONXL_H_

View File

@ -18,6 +18,7 @@
#include "icsneo/device/tree/radcomet3/radcomet3.h"
#include "icsneo/device/tree/radmoont1s/radmoont1s.h"
#include "icsneo/device/tree/radepsilon/radepsilon.h"
#include "icsneo/device/tree/radepsilonxl/radepsilonxl.h"
#include "icsneo/device/tree/radgalaxy/radgalaxy.h"
#include "icsneo/device/tree/radgalaxy2/radgalaxy2.h"
#include "icsneo/device/tree/radgigastar/radgigastar.h"

View File

@ -18,6 +18,7 @@
#include "icsneo/device/tree/radcomet3/radcomet3.h"
#include "icsneo/device/tree/radmoont1s/radmoont1s.h"
#include "icsneo/device/tree/radepsilon/radepsilon.h"
#include "icsneo/device/tree/radepsilonxl/radepsilonxl.h"
#include "icsneo/device/tree/radgalaxy/radgalaxy.h"
#include "icsneo/device/tree/radgalaxy2/radgalaxy2.h"
#include "icsneo/device/tree/radgigastar/radgigastar.h"

View File

@ -34,9 +34,12 @@ PCAPDLL::PCAPDLL()
int len = GetSystemDirectory(dllPath, 480); // be safe
if (len) {
_tcscat_s(dllPath, 512, TEXT("\\Npcap"));
cookie = AddDllDirectory(dllPath);
WCHAR dllPath_w[512] = { 0 };
if (mbstowcs(dllPath_w, dllPath, 512)) {
cookie = AddDllDirectory(dllPath_w);
}
}
dll = LoadLibraryEx(TEXT("wpcap.dll"), nullptr, LOAD_LIBRARY_SEARCH_USER_DIRS);
dll = LoadLibraryEx(TEXT("wpcap.dll"), nullptr, LOAD_LIBRARY_SEARCH_DEFAULT_DIRS);
if (cookie)
RemoveDllDirectory(cookie);