4 Commits
Author SHA1 Message Date
Kyle Schwarz 245073f9d5 1.0.0 2025-06-05 21:10:54 -04:00
Kyle Schwarz c4e858d346 Driver: Prefer Npcap
Prefer Npcap over WinPcap and TCP
2025-06-04 22:14:09 -04:00
Keith NashandKyle Schwarz b3d47f2ae5 Communication: Add LogDataMessage 2025-05-16 19:36:27 +00:00
Kyle Schwarz b94ade1ef6 FIRE3: Add Ethernet Activation Lines 2025-05-15 11:11:26 -04:00
14 changed files with 74 additions and 18 deletions
+2 -2
View File
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.16)
project(libicsneo VERSION 0.3.0)
project(libicsneo VERSION 1.0.0)
cmake_policy(SET CMP0074 NEW)
if(POLICY CMP0135)
@@ -246,6 +246,7 @@ set(SRC_FILES
communication/message/ethphymessage.cpp
communication/message/linmessage.cpp
communication/message/livedatamessage.cpp
communication/message/logdatamessage.cpp
communication/message/tc10statusmessage.cpp
communication/message/gptpstatusmessage.cpp
communication/message/ethernetstatusmessage.cpp
@@ -429,7 +430,6 @@ if(LIBICSNEO_ENABLE_RAW_ETHERNET)
add_definitions(-DWPCAP -DHAVE_REMOTE)
else()
target_include_directories(icsneocpp PUBLIC AFTER ${LIBICSNEO_NPCAP_INCLUDE_DIR})
add_definitions(-DNPCAP)
endif()
else()
find_package(PCAP REQUIRED)
+10
View File
@@ -16,6 +16,7 @@
#include "icsneo/communication/message/mdiomessage.h"
#include "icsneo/communication/message/extendeddatamessage.h"
#include "icsneo/communication/message/livedatamessage.h"
#include "icsneo/communication/message/logdatamessage.h"
#include "icsneo/communication/message/diskdatamessage.h"
#include "icsneo/communication/message/hardwareinfo.h"
#include "icsneo/communication/message/tc10statusmessage.h"
@@ -491,7 +492,16 @@ bool Decoder::decode(std::shared_ptr<Message>& result, const std::shared_ptr<Pac
result = std::make_shared<DiskDataMessage>(std::move(packet->data));
return true;
}
case Network::NetID::Data_To_Host: {
result = LogDataMessage::DecodeToMessage(packet->data);
if(!result) {
report(APIEvent::Type::PacketDecodingError, APIEvent::Severity::EventWarning);
return false;
}
return true;
}
default:
break;
}
break;
+12
View File
@@ -0,0 +1,12 @@
#include "icsneo/communication/message/logdatamessage.h"
#include <iostream>
using namespace icsneo;
std::shared_ptr<LogDataMessage> LogDataMessage::DecodeToMessage(const std::vector<uint8_t>& bytestream) {
if(bytestream.size() % 2 != 0)
return nullptr;
const auto* begin = (char16_t*)bytestream.data();
const auto* end = begin + (bytestream.size() / sizeof(char16_t));
return std::make_shared<LogDataMessage>(std::wstring(begin,end));
}
+8
View File
@@ -405,6 +405,14 @@ bool Device::close() {
return com->close();
}
bool Device::enableLogData() {
return com->sendCommand(Command::EnableLogData, true);
}
bool Device::disableLogData() {
return com->sendCommand(Command::EnableLogData, false);
}
bool Device::goOnline() {
if(!enableNetworkCommunication(true))
return false;
+1
View File
@@ -38,6 +38,7 @@ enum class Command : uint8_t {
FlexRayControl = 0xF3,
CoreMiniPreload = 0xF4, // Previously known as RED_CMD_COREMINI_PRELOAD
PHYControlRegisters = 0xEF,
EnableLogData = 0xF6,
};
enum class ExtendedCommand : uint16_t {
@@ -0,0 +1,26 @@
#ifndef __LOGDATAMESSAGE_H_
#define __LOGDATAMESSAGE_H_
#ifdef __cplusplus
#include "icsneo/communication/message/message.h"
#include <cstdint>
#include <memory>
namespace icsneo {
class LogDataMessage : public RawMessage {
public:
static std::shared_ptr<LogDataMessage> DecodeToMessage(const std::vector<uint8_t>& bytestream);
LogDataMessage(std::wstring logDataString) :
RawMessage(Message::Type::LogData, Network::NetID::Data_To_Host), logMessage(logDataString) {}
std::wstring logMessage;
};
}
#endif // __cplusplus
#endif
@@ -44,6 +44,7 @@ public:
AppError = 0x8012,
GPTPStatus = 0x8013,
EthernetStatus = 0x8014,
LogData = 0x8015,
};
Message(Type t) : type(t) {}
+1
View File
@@ -583,6 +583,7 @@ public:
case NetID::RED_GET_RTC:
case NetID::DiskData:
case NetID::RED_App_Error:
case NetID::Data_To_Host:
return Type::Internal;
case NetID::Invalid:
case NetID::Any:
+2
View File
@@ -151,6 +151,8 @@ public:
virtual bool isDisconnected() const { return com->isDisconnected(); }
virtual bool goOnline();
virtual bool goOffline();
virtual bool enableLogData();
virtual bool disableLogData();
enum class PreloadReturn : uint8_t
{
@@ -49,6 +49,7 @@ public:
};
return supportedNetworks;
}
size_t getEthernetActivationLineCount() const override { return 2; }
protected:
NeoVIFIRE3(neodevice_t neodevice, const driver_factory_t& makeDriver) : Device(neodevice) {
initialize<NeoVIFIRE3Settings, Disk::ExtExtractorDiskReadDriver, Disk::NeoMemoryDiskDriver>(makeDriver);
+1
View File
@@ -20,6 +20,7 @@
#include "icsneo/communication/message/a2bmessage.h"
#include "icsneo/communication/message/linmessage.h"
#include "icsneo/communication/message/mdiomessage.h"
#include "icsneo/communication/message/logdatamessage.h"
#include "icsneo/communication/message/callback/streamoutput/a2bwavoutput.h"
@@ -50,7 +50,7 @@ public:
bool ok() const;
private:
PCAPDLL();
HINSTANCE dll;
HINSTANCE dll = nullptr;
void closeDLL();
};
}
+8 -14
View File
@@ -28,21 +28,15 @@ bool PCAPDLL::ok() const
PCAPDLL::PCAPDLL()
{
#ifdef NPCAP // Use -DLIBICSNEO_NPCAP_INCLUDE_DIR when configuring, point towards the npcap includes
DLL_DIRECTORY_COOKIE cookie = 0;
TCHAR dllPath[512] = { 0 };
int len = GetSystemDirectory(dllPath, 480); // be safe
if (len) {
_tcscat_s(dllPath, 512, TEXT("\\Npcap"));
cookie = AddDllDirectory(dllPath);
TCHAR dir[512] = {0};
if(GetSystemDirectory(dir, 480)) {
_tcscat_s(dir, 512, TEXT("\\Npcap"));
if(SetDllDirectory(dir)) {
// will search for Npcap first, then fall back to WinPcap
dll = LoadLibrary(TEXT("wpcap.dll"));
SetDllDirectory(nullptr); // reset
}
}
dll = LoadLibraryEx(TEXT("wpcap.dll"), nullptr, LOAD_LIBRARY_SEARCH_USER_DIRS);
if (cookie)
RemoveDllDirectory(cookie);
#else // Otherwise we'll use WinPCAP, or npcap in compatibility mode
dll = LoadLibrary(TEXT("wpcap.dll"));
#endif
if(dll == NULL) {
closeDLL();
-1
View File
@@ -46,7 +46,6 @@ local_scheme = "no-local-version"
[tool.scikit-build.cmake.define]
LIBICSNEO_ENABLE_BINDINGS_PYTHON = true
LIBICSNEO_ENABLE_TCP = true
CMAKE_MSVC_RUNTIME_LIBRARY = "MultiThreaded"
[tool.cibuildwheel]