Author SHA1 Message Date
Kyle Schwarz c4ce803d62 LINMessage: Fix timestamp scaling 2024-12-19 15:54:27 -05:00
Kyle Schwarz 34cacf4cf2 EthernetMessage: Fix TX receipts
Fixes
- HardwareEthernetPacket packing
- EthernetMessage::fcs
2024-12-13 12:55:57 -05:00
Kyle Schwarz 4157558e84 Bindings: Python: Drop GIL for Device calls
Avoids an ABBA deadlock with the GIL and messageCallbacksLock
2024-12-12 11:12:55 -05:00
Kyle Schwarz 40b85488dc TCP: Add LIBICSNEO_DISABLE_TCP env option 2024-12-11 17:25:36 -05:00
Kyle Schwarz 7584563002 Bindings: Python: Add default MessageFilter constructor 2024-12-11 17:22:09 -05:00
Kyle Schwarz 4f83614037 Bindings: Python: Fix Device RTC functions 2024-12-04 12:31:06 -05:00
Kyle Schwarz 38a4af8062 Device: Fix getRTC response size
Some devices pad to 16-bit.
2024-12-04 12:11:01 -05:00
Kyle Schwarz 3b95b41be4 Bindings: Python: Add LINMessage 2024-12-03 23:41:51 -05:00
Kyle Schwarz 3da31a29b4 Bindings: Python: Add more Network members 2024-12-03 22:35:40 -05:00
Kyle Schwarz d0f3e593df Device: Add RAD-Galaxy 2 2024-12-02 20:02:06 -05:00
Kyle Schwarz 90268a4f04 CI: Update DOCKER_HOST 2024-12-02 19:44:21 -05:00
Kyle Schwarz dbe19a5616 Bindings: Python: Add MDIOMessage 2024-11-08 15:06:45 -05:00
Kyle Schwarz e5d7a38160 CI: Fix push command 2024-11-05 16:00:30 -05:00
Kyle Schwarz d714b620c4 CI: Add GitHub auto-push 2024-11-05 14:58:54 -05:00
Kyle Schwarz 10d2625cb6 Bindings: Python: Add get_tc10_status 2024-11-05 14:30:53 -05:00
Kyle Schwarz b9cfa85009 Docs: Add GitHub link 2024-11-05 12:56:27 -05:00
Kyle Schwarz 776d14bb3e Docs: Fix RTD requirements path 2024-11-04 18:05:24 -05:00
27 changed files with 622 additions and 31 deletions
+16 -1
View File
@@ -437,7 +437,7 @@ build python/linux/amd64:
CIBW_BEFORE_ALL: yum install -y flex && sh ci/bootstrap-libpcap.sh && sh ci/bootstrap-libusb.sh CIBW_BEFORE_ALL: yum install -y flex && sh ci/bootstrap-libpcap.sh && sh ci/bootstrap-libusb.sh
CIBW_BUILD: "*manylinux*" # no musl CIBW_BUILD: "*manylinux*" # no musl
CIBW_ARCHS: x86_64 CIBW_ARCHS: x86_64
DOCKER_HOST: tcp://docker:2375/ DOCKER_HOST: unix:///var/run/docker.sock
DOCKER_DRIVER: overlay2 DOCKER_DRIVER: overlay2
DOCKER_TLS_CERTDIR: "" DOCKER_TLS_CERTDIR: ""
CIBW_ENVIRONMENT: CMAKE_PREFIX_PATH=/project/libpcap/install:/project/libusb/install CIBW_ENVIRONMENT: CMAKE_PREFIX_PATH=/project/libpcap/install:/project/libusb/install
@@ -514,3 +514,18 @@ deploy python/pypi:
- build python/linux/arm64 - build python/linux/arm64
- build python/macos - build python/macos
- build python/windows - build python/windows
push github:
stage: deploy
tags:
- linux-build
image: alpine:latest
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
dependencies:
- deploy python/pypi
needs:
- deploy python/pypi
script:
- apk add git
- git push https://$LIBICSNEO_GITHUB_USERNAME:$LIBICSNEO_GITHUB_TOKEN@github.com/intrepidcs/libicsneo.git HEAD:master
+1 -1
View File
@@ -9,7 +9,7 @@ build:
python: python:
install: install:
- requirements: docs/icsneopy/requirements.txt - requirements: docs/requirements.txt
sphinx: sphinx:
configuration: docs/conf.py configuration: docs/conf.py
+1
View File
@@ -24,6 +24,7 @@ each of the respective APIs.
- RAD-Comet 2 - RAD-Comet 2
- RAD-Comet 3 - RAD-Comet 3
- RAD-Galaxy - RAD-Galaxy
- RAD-Galaxy 2
- RAD-Gigastar - RAD-Gigastar
- RAD-Gigastar 2 - RAD-Gigastar 2
- RAD-Moon 2 - RAD-Moon 2
+2
View File
@@ -13,7 +13,9 @@ pybind11_add_module(icsneopy
icsneopy/communication/message/message.cpp icsneopy/communication/message/message.cpp
icsneopy/communication/message/canmessage.cpp icsneopy/communication/message/canmessage.cpp
icsneopy/communication/message/ethernetmessage.cpp icsneopy/communication/message/ethernetmessage.cpp
icsneopy/communication/message/linmessage.cpp
icsneopy/communication/message/tc10statusmessage.cpp icsneopy/communication/message/tc10statusmessage.cpp
icsneopy/communication/message/mdiomessage.cpp
icsneopy/communication/message/callback/messagecallback.cpp icsneopy/communication/message/callback/messagecallback.cpp
icsneopy/communication/message/filter/messagefilter.cpp icsneopy/communication/message/filter/messagefilter.cpp
icsneopy/device/device.cpp icsneopy/device/device.cpp
@@ -15,7 +15,7 @@ void init_ethernetmessage(pybind11::module_& m) {
.def(pybind11::init()) .def(pybind11::init())
.def_readwrite("preemptionEnabled", &EthernetMessage::preemptionEnabled) .def_readwrite("preemptionEnabled", &EthernetMessage::preemptionEnabled)
.def_readwrite("preemptionFlags", &EthernetMessage::preemptionFlags) .def_readwrite("preemptionFlags", &EthernetMessage::preemptionFlags)
.def_readwrite("fcsAvailable", &EthernetMessage::fcsAvailable) .def_readwrite("fcs", &EthernetMessage::fcs)
.def_readwrite("frameTooShort", &EthernetMessage::frameTooShort) .def_readwrite("frameTooShort", &EthernetMessage::frameTooShort)
.def_readwrite("noPadding", &EthernetMessage::noPadding) .def_readwrite("noPadding", &EthernetMessage::noPadding)
.def("get_destination_mac", &EthernetMessage::getDestinationMAC, pybind11::return_value_policy::reference) .def("get_destination_mac", &EthernetMessage::getDestinationMAC, pybind11::return_value_policy::reference)
@@ -8,6 +8,7 @@ namespace icsneo {
void init_messagefilter(pybind11::module_& m) { void init_messagefilter(pybind11::module_& m) {
pybind11::class_<MessageFilter, std::shared_ptr<MessageFilter>>(m, "MessageFilter") pybind11::class_<MessageFilter, std::shared_ptr<MessageFilter>>(m, "MessageFilter")
.def(pybind11::init())
.def(pybind11::init<Network::NetID>()); .def(pybind11::init<Network::NetID>());
} }
@@ -0,0 +1,59 @@
#include <pybind11/pybind11.h>
#include <pybind11/stl.h>
#include <pybind11/functional.h>
#include "icsneo/communication/message/linmessage.h"
namespace icsneo {
void init_linmessage(pybind11::module_& m) {
pybind11::class_<LINErrorFlags>(m, "LINErrorFlags")
.def_readwrite("ErrRxBreakOnly", &LINErrorFlags::ErrRxBreakOnly)
.def_readwrite("ErrRxBreakSyncOnly", &LINErrorFlags::ErrRxBreakSyncOnly)
.def_readwrite("ErrTxRxMismatch", &LINErrorFlags::ErrTxRxMismatch)
.def_readwrite("ErrRxBreakNotZero", &LINErrorFlags::ErrRxBreakNotZero)
.def_readwrite("ErrRxBreakTooShort", &LINErrorFlags::ErrRxBreakTooShort)
.def_readwrite("ErrRxSyncNot55", &LINErrorFlags::ErrRxSyncNot55)
.def_readwrite("ErrRxDataLenOver8", &LINErrorFlags::ErrRxDataLenOver8)
.def_readwrite("ErrFrameSync", &LINErrorFlags::ErrFrameSync)
.def_readwrite("ErrFrameMessageID", &LINErrorFlags::ErrFrameMessageID)
.def_readwrite("ErrFrameResponderData", &LINErrorFlags::ErrFrameResponderData)
.def_readwrite("ErrChecksumMatch", &LINErrorFlags::ErrChecksumMatch);
pybind11::class_<LINStatusFlags>(m, "LINStatusFlags")
.def_readwrite("TxChecksumEnhanced", &LINStatusFlags::TxChecksumEnhanced)
.def_readwrite("TxCommander", &LINStatusFlags::TxCommander)
.def_readwrite("TxResponder", &LINStatusFlags::TxResponder)
.def_readwrite("TxAborted", &LINStatusFlags::TxAborted)
.def_readwrite("UpdateResponderOnce", &LINStatusFlags::UpdateResponderOnce)
.def_readwrite("HasUpdatedResponderOnce", &LINStatusFlags::HasUpdatedResponderOnce)
.def_readwrite("BusRecovered", &LINStatusFlags::BusRecovered)
.def_readwrite("BreakOnly", &LINStatusFlags::BreakOnly);
pybind11::class_<LINMessage, std::shared_ptr<LINMessage>, Frame> linMessage(m, "LINMessage");
pybind11::enum_<LINMessage::Type>(linMessage, "Type")
.value("NOT_SET", LINMessage::Type::NOT_SET)
.value("LIN_COMMANDER_MSG", LINMessage::Type::LIN_COMMANDER_MSG)
.value("LIN_HEADER_ONLY", LINMessage::Type::LIN_HEADER_ONLY)
.value("LIN_BREAK_ONLY", LINMessage::Type::LIN_BREAK_ONLY)
.value("LIN_SYNC_ONLY", LINMessage::Type::LIN_SYNC_ONLY)
.value("LIN_UPDATE_RESPONDER", LINMessage::Type::LIN_UPDATE_RESPONDER)
.value("LIN_ERROR", LINMessage::Type::LIN_ERROR);
linMessage
.def(pybind11::init<>())
.def(pybind11::init<uint8_t>())
.def_static("calc_checksum", &LINMessage::calcChecksum)
.def("calc_protected_id", &LINMessage::calcProtectedID)
.def_readwrite("ID", &LINMessage::ID)
.def_readwrite("protectedID", &LINMessage::protectedID)
.def_readwrite("checksum", &LINMessage::checksum)
.def_readwrite("linMsgType", &LINMessage::linMsgType)
.def_readwrite("isEnhancedChecksum", &LINMessage::isEnhancedChecksum)
.def_readwrite("errFlags", &LINMessage::errFlags)
.def_readwrite("statusFlags", &LINMessage::statusFlags);
}
} // namespace icsneo
@@ -0,0 +1,35 @@
#include <pybind11/pybind11.h>
#include <pybind11/stl.h>
#include <pybind11/functional.h>
#include "icsneo/communication/message/mdiomessage.h"
namespace icsneo {
void init_mdiomessage(pybind11::module_& m) {
pybind11::class_<MDIOMessage, std::shared_ptr<MDIOMessage>, Frame> mdioMessage(m, "MDIOMessage");
pybind11::enum_<MDIOMessage::Clause>(mdioMessage, "Clause")
.value("Clause45", MDIOMessage::Clause::Clause45)
.value("Clause22", MDIOMessage::Clause::Clause22);
pybind11::enum_<MDIOMessage::Direction>(mdioMessage, "Direction")
.value("Write", MDIOMessage::Direction::Write)
.value("Read", MDIOMessage::Direction::Read);
mdioMessage
.def(pybind11::init())
.def_readwrite("isTXMsg", &MDIOMessage::isTXMsg)
.def_readwrite("txTimeout", &MDIOMessage::txTimeout)
.def_readwrite("txAborted", &MDIOMessage::txAborted)
.def_readwrite("txInvalidBus", &MDIOMessage::txInvalidBus)
.def_readwrite("txInvalidPhyAddr", &MDIOMessage::txInvalidPhyAddr)
.def_readwrite("txInvalidRegAddr", &MDIOMessage::txInvalidRegAddr)
.def_readwrite("txInvalidClause", &MDIOMessage::txInvalidClause)
.def_readwrite("txInvalidOpcode", &MDIOMessage::txInvalidOpcode)
.def_readwrite("phyAddress", &MDIOMessage::phyAddress)
.def_readwrite("devAddress", &MDIOMessage::devAddress)
.def_readwrite("regAddress", &MDIOMessage::regAddress)
.def_readwrite("direction", &MDIOMessage::direction)
.def_readwrite("clause", &MDIOMessage::clause);
}
} // namespace icsneo
@@ -167,7 +167,30 @@ void init_network(pybind11::module_& m) {
.value("Any", Network::NetID::Any) .value("Any", Network::NetID::Any)
.value("Invalid", Network::NetID::Invalid); .value("Invalid", Network::NetID::Invalid);
network.def(pybind11::init<Network::NetID>()); pybind11::enum_<Network::Type>(network, "Type")
.value("Invalid", Network::Type::Invalid)
.value("Internal", Network::Type::Internal)
.value("CAN", Network::Type::CAN)
.value("LIN", Network::Type::LIN)
.value("FlexRay", Network::Type::FlexRay)
.value("MOST", Network::Type::MOST)
.value("Ethernet", Network::Type::Ethernet)
.value("LSFTCAN", Network::Type::LSFTCAN)
.value("SWCAN", Network::Type::SWCAN)
.value("ISO9141", Network::Type::ISO9141)
.value("I2C", Network::Type::I2C)
.value("A2B", Network::Type::A2B)
.value("SPI", Network::Type::SPI)
.value("MDIO", Network::Type::MDIO)
.value("Any", Network::Type::Any)
.value("Other", Network::Type::Other);
network
.def(pybind11::init<Network::NetID>())
.def("__repr__", [](Network& self) { return Network::GetNetIDString(self.getNetID()); })
.def_static("get_net_id_string", &Network::GetNetIDString, pybind11::arg("netid"), pybind11::arg("expand") = true)
.def("get_net_id", &Network::getNetID)
.def("get_type", &Network::getType);
} }
} // namespace icsneo } // namespace icsneo
+17 -14
View File
@@ -1,6 +1,7 @@
#include <pybind11/pybind11.h> #include <pybind11/pybind11.h>
#include <pybind11/stl.h> #include <pybind11/stl.h>
#include <pybind11/functional.h> #include <pybind11/functional.h>
#include <pybind11/chrono.h>
#include "icsneo/device/device.h" #include "icsneo/device/device.h"
@@ -12,30 +13,32 @@ void init_device(pybind11::module_& m) {
.def("get_serial", &Device::getSerial) .def("get_serial", &Device::getSerial)
.def("get_serial_number", &Device::getSerialNumber) .def("get_serial_number", &Device::getSerialNumber)
.def("get_product_name", &Device::getProductName) .def("get_product_name", &Device::getProductName)
.def("open", [](Device& device) { return device.open(); }) .def("open", [](Device& device) { return device.open(); }, pybind11::call_guard<pybind11::gil_scoped_release>())
.def("close", &Device::close) .def("close", &Device::close, pybind11::call_guard<pybind11::gil_scoped_release>())
.def("is_open", &Device::isOpen) .def("is_open", &Device::isOpen)
.def("go_online", &Device::goOnline) .def("go_online", &Device::goOnline, pybind11::call_guard<pybind11::gil_scoped_release>())
.def("go_offline", &Device::goOffline) .def("go_offline", &Device::goOffline, pybind11::call_guard<pybind11::gil_scoped_release>())
.def("is_online", &Device::isOnline).def("enable_message_polling", &Device::enableMessagePolling) .def("is_online", &Device::isOnline)
.def("disable_message_polling", &Device::disableMessagePolling) .def("enable_message_polling", &Device::enableMessagePolling, pybind11::call_guard<pybind11::gil_scoped_release>())
.def("disable_message_polling", &Device::disableMessagePolling, pybind11::call_guard<pybind11::gil_scoped_release>())
.def("is_message_polling_enabled", &Device::isMessagePollingEnabled) .def("is_message_polling_enabled", &Device::isMessagePollingEnabled)
.def("get_messages", [](Device& device) { return device.getMessages(); }) .def("get_messages", [](Device& device) { return device.getMessages(); }, pybind11::call_guard<pybind11::gil_scoped_release>())
.def("get_current_message_count", &Device::getCurrentMessageCount) .def("get_current_message_count", &Device::getCurrentMessageCount)
.def("get_polling_message_limit", &Device::getPollingMessageLimit) .def("get_polling_message_limit", &Device::getPollingMessageLimit)
.def("set_polling_message_limit", &Device::setPollingMessageLimit) .def("set_polling_message_limit", &Device::setPollingMessageLimit)
.def("add_message_callback", &Device::addMessageCallback) .def("add_message_callback", &Device::addMessageCallback, pybind11::call_guard<pybind11::gil_scoped_release>())
.def("remove_message_callback", &Device::removeMessageCallback) .def("remove_message_callback", &Device::removeMessageCallback, pybind11::call_guard<pybind11::gil_scoped_release>())
.def("transmit", pybind11::overload_cast<std::shared_ptr<Frame>>(&Device::transmit)) .def("transmit", pybind11::overload_cast<std::shared_ptr<Frame>>(&Device::transmit), pybind11::call_guard<pybind11::gil_scoped_release>())
.def("get_supported_rx_networks", &Device::getSupportedRXNetworks, pybind11::return_value_policy::reference) .def("get_supported_rx_networks", &Device::getSupportedRXNetworks, pybind11::return_value_policy::reference)
.def("get_supported_tx_networks", &Device::getSupportedTXNetworks, pybind11::return_value_policy::reference) .def("get_supported_tx_networks", &Device::getSupportedTXNetworks, pybind11::return_value_policy::reference)
.def("get_rtc", &Device::getRTC) .def("get_rtc", &Device::getRTC, pybind11::call_guard<pybind11::gil_scoped_release>())
.def("set_rtc", &Device::setRTC) .def("set_rtc", &Device::setRTC, pybind11::call_guard<pybind11::gil_scoped_release>())
.def("describe", &Device::describe) .def("describe", &Device::describe)
.def("is_online_supported", &Device::isOnlineSupported) .def("is_online_supported", &Device::isOnlineSupported)
.def("supports_tc10", &Device::supportsTC10) .def("supports_tc10", &Device::supportsTC10)
.def("request_tc10_wake", &Device::requestTC10Wake) .def("request_tc10_wake", &Device::requestTC10Wake, pybind11::call_guard<pybind11::gil_scoped_release>())
.def("request_tc10_sleep", &Device::requestTC10Sleep) .def("request_tc10_sleep", &Device::requestTC10Sleep, pybind11::call_guard<pybind11::gil_scoped_release>())
.def("get_tc10_status", &Device::getTC10Status, pybind11::call_guard<pybind11::gil_scoped_release>())
.def("__repr__", &Device::describe); .def("__repr__", &Device::describe);
} }
@@ -33,6 +33,7 @@ void init_devicetype(pybind11::module_& m) {
.value("EtherBADGE", DeviceType::Enum::EtherBADGE) .value("EtherBADGE", DeviceType::Enum::EtherBADGE)
.value("RAD_A2B", DeviceType::Enum::RAD_A2B) .value("RAD_A2B", DeviceType::Enum::RAD_A2B)
.value("RADEpsilon", DeviceType::Enum::RADEpsilon) .value("RADEpsilon", DeviceType::Enum::RADEpsilon)
.value("RADGalaxy2", DeviceType::Enum::RADGalaxy2)
.value("RADMoon3", DeviceType::Enum::RADMoon3) .value("RADMoon3", DeviceType::Enum::RADMoon3)
.value("RADComet", DeviceType::Enum::RADComet) .value("RADComet", DeviceType::Enum::RADComet)
.value("FIRE3_FlexRay", DeviceType::Enum::FIRE3_FlexRay) .value("FIRE3_FlexRay", DeviceType::Enum::FIRE3_FlexRay)
+4
View File
@@ -14,7 +14,9 @@ void init_devicetype(pybind11::module_&);
void init_message(pybind11::module_&); void init_message(pybind11::module_&);
void init_canmessage(pybind11::module_&); void init_canmessage(pybind11::module_&);
void init_ethernetmessage(pybind11::module_&); void init_ethernetmessage(pybind11::module_&);
void init_linmessage(pybind11::module_&);
void init_tc10statusmessage(pybind11::module_&); void init_tc10statusmessage(pybind11::module_&);
void init_mdiomessage(pybind11::module_&);
void init_device(pybind11::module_&); void init_device(pybind11::module_&);
void init_messagefilter(pybind11::module_&); void init_messagefilter(pybind11::module_&);
void init_messagecallback(pybind11::module_&); void init_messagecallback(pybind11::module_&);
@@ -32,7 +34,9 @@ PYBIND11_MODULE(icsneopy, m) {
init_message(m); init_message(m);
init_canmessage(m); init_canmessage(m);
init_ethernetmessage(m); init_ethernetmessage(m);
init_linmessage(m);
init_tc10statusmessage(m); init_tc10statusmessage(m);
init_mdiomessage(m);
init_messagefilter(m); init_messagefilter(m);
init_messagecallback(m); init_messagecallback(m);
init_device(m); init_device(m);
+1
View File
@@ -178,6 +178,7 @@ bool Decoder::decode(std::shared_ptr<Message>& result, const std::shared_ptr<Pac
LINMessage& msg = *static_cast<LINMessage*>(result.get()); LINMessage& msg = *static_cast<LINMessage*>(result.get());
msg.network = packet->network; msg.network = packet->network;
msg.timestamp *= timestampResolution;
return true; return true;
} }
case Network::Type::MDIO: { case Network::Type::MDIO: {
+1 -1
View File
@@ -51,7 +51,7 @@ neomessage_t icsneo::CreateNeoMessage(const std::shared_ptr<Message> message) {
eth.status.incompleteFrame = ethmsg->frameTooShort; eth.status.incompleteFrame = ethmsg->frameTooShort;
// TODO Fill in extra status bits // TODO Fill in extra status bits
//eth.status.xyz = ethmsg->preemptionEnabled; //eth.status.xyz = ethmsg->preemptionEnabled;
//eth.status.xyz = ethmsg->fcsAvailable; //eth.status.xyz = ethmsg->fcs;
//eth.status.xyz = ethmsg->noPadding; //eth.status.xyz = ethmsg->noPadding;
break; break;
} }
+9 -8
View File
@@ -16,8 +16,8 @@ std::shared_ptr<EthernetMessage> HardwareEthernetPacket::DecodeToMessage(const s
if(packet->Length < 4) if(packet->Length < 4)
return nullptr; return nullptr;
const size_t ethernetFrameSize = packet->Length - (sizeof(uint16_t) * 2); const size_t fcsSize = packet->header.FCS_AVAIL ? 4 : 0;
const size_t bytestreamExpectedSize = sizeof(HardwareEthernetPacket) + ethernetFrameSize; const size_t bytestreamExpectedSize = sizeof(HardwareEthernetPacket) + packet->Length;
const size_t bytestreamActualSize = bytestream.size(); const size_t bytestreamActualSize = bytestream.size();
if(bytestreamActualSize < bytestreamExpectedSize) if(bytestreamActualSize < bytestreamExpectedSize)
return nullptr; return nullptr;
@@ -37,8 +37,6 @@ std::shared_ptr<EthernetMessage> HardwareEthernetPacket::DecodeToMessage(const s
if(message.preemptionEnabled) if(message.preemptionEnabled)
message.preemptionFlags = (uint8_t)((rawWords[0] & 0x03F8) >> 4); message.preemptionFlags = (uint8_t)((rawWords[0] & 0x03F8) >> 4);
message.fcsAvailable = packet->header.FCS_AVAIL;
message.frameTooShort = packet->header.RUNT_FRAME; message.frameTooShort = packet->header.RUNT_FRAME;
if(message.frameTooShort) if(message.frameTooShort)
message.error = true; message.error = true;
@@ -47,12 +45,15 @@ std::shared_ptr<EthernetMessage> HardwareEthernetPacket::DecodeToMessage(const s
// Decoder will fix as it has information about the timestampResolution increments // Decoder will fix as it has information about the timestampResolution increments
message.timestamp = packet->timestamp.TS; message.timestamp = packet->timestamp.TS;
// Network ID is also not set, this will be fixed in the Decoder as well const std::vector<uint8_t>::const_iterator databegin = bytestream.begin() + sizeof(HardwareEthernetPacket);
const std::vector<uint8_t>::const_iterator dataend = databegin + packet->Length - fcsSize;
const std::vector<uint8_t>::const_iterator databegin = bytestream.begin() + (sizeof(HardwareEthernetPacket) - (sizeof(uint16_t) * 2));
const std::vector<uint8_t>::const_iterator dataend = databegin + ethernetFrameSize;
message.data.insert(message.data.begin(), databegin, dataend); message.data.insert(message.data.begin(), databegin, dataend);
if(fcsSize) {
uint32_t& fcs = message.fcs.emplace();
std::copy(dataend, dataend + fcsSize, (uint8_t*)&fcs);
}
return messagePtr; return messagePtr;
} }
+1 -1
View File
@@ -1951,7 +1951,7 @@ bool Device::setRTC(const std::chrono::time_point<std::chrono::system_clock>& ti
} }
auto m51msg = std::dynamic_pointer_cast<Main51Message>(generic); auto m51msg = std::dynamic_pointer_cast<Main51Message>(generic);
if(!m51msg || m51msg->data.size() != 1) { if(!m51msg || m51msg->data.empty() || m51msg->data.size() > 2) {
report(APIEvent::Type::MessageFormattingError, APIEvent::Severity::Error); report(APIEvent::Type::MessageFormattingError, APIEvent::Severity::Error);
return false; return false;
} }
+8
View File
@@ -197,6 +197,10 @@ std::vector<std::shared_ptr<Device>> DeviceFinder::FindAll() {
makeIfSerialMatches<RADGalaxy>(dev, newFoundDevices); makeIfSerialMatches<RADGalaxy>(dev, newFoundDevices);
#endif #endif
#ifdef __RADGALAXY2_H_
makeIfSerialMatches<RADGalaxy2>(dev, newFoundDevices);
#endif
#ifdef __RADMARS_H_ #ifdef __RADMARS_H_
makeIfSerialMatches<RADMars>(dev, newFoundDevices); makeIfSerialMatches<RADMars>(dev, newFoundDevices);
#endif #endif
@@ -352,6 +356,10 @@ const std::vector<DeviceType>& DeviceFinder::GetSupportedDevices() {
RADGalaxy::DEVICE_TYPE, RADGalaxy::DEVICE_TYPE,
#endif #endif
#ifdef __RADGALAXY2_H_
RADGalaxy2::DEVICE_TYPE,
#endif
#ifdef __RADMARS_H_ #ifdef __RADMARS_H_
RADMars::DEVICE_TYPE, RADMars::DEVICE_TYPE,
#endif #endif
+6 -1
View File
@@ -1,9 +1,14 @@
=========
libicsneo libicsneo
========= =========
libicsneo is the `Intrepid Control Systems <https://intrepidcs.com/>`_ device
communication library. The source code for libicsneo can be found on GitHub:
`https://github.com/intrepidcs/libicsneo <https://github.com/intrepidcs/libicsneo>`_
.. toctree:: .. toctree::
:maxdepth: 1 :maxdepth: 1
:caption: API Documentation :caption: Documentation
icsneocpp/index icsneocpp/index
icsneopy/index icsneopy/index
@@ -35,7 +35,7 @@ class EthernetMessage : public Frame {
public: public:
bool preemptionEnabled = false; bool preemptionEnabled = false;
uint8_t preemptionFlags = 0; uint8_t preemptionFlags = 0;
bool fcsAvailable = false; std::optional<uint32_t> fcs;
bool frameTooShort = false; bool frameTooShort = false;
bool noPadding = false; bool noPadding = false;
@@ -10,6 +10,8 @@
namespace icsneo { namespace icsneo {
#pragma pack(push, 2)
typedef uint16_t icscm_bitfield; typedef uint16_t icscm_bitfield;
struct HardwareEthernetPacket { struct HardwareEthernetPacket {
@@ -42,6 +44,8 @@ struct HardwareEthernetPacket {
uint16_t Length; uint16_t Length;
}; };
#pragma pack(pop)
} }
#endif // __cplusplus #endif // __cplusplus
+4
View File
@@ -47,6 +47,7 @@ public:
EtherBADGE = (0x00000016), EtherBADGE = (0x00000016),
RAD_A2B = (0x00000017), RAD_A2B = (0x00000017),
RADEpsilon = (0x00000018), RADEpsilon = (0x00000018),
RADGalaxy2 = (0x00000021),
RADMoon3 = (0x00000023), RADMoon3 = (0x00000023),
RADComet = (0x00000024), RADComet = (0x00000024),
FIRE3_FlexRay = (0x00000025), FIRE3_FlexRay = (0x00000025),
@@ -182,6 +183,8 @@ public:
return "neoVI Flex"; return "neoVI Flex";
case RADGalaxy: case RADGalaxy:
return "RAD-Galaxy"; return "RAD-Galaxy";
case RADGalaxy2:
return "RAD-Galaxy 2";
case RADStar2: case RADStar2:
return "RAD-Star 2"; return "RAD-Star 2";
case VividCAN: case VividCAN:
@@ -248,6 +251,7 @@ private:
#define ICSNEO_DEVICETYPE_ETHERBADGE ((devicetype_t)0x00000016) #define ICSNEO_DEVICETYPE_ETHERBADGE ((devicetype_t)0x00000016)
#define ICSNEO_DEVICETYPE_RAD_A2B ((devicetype_t)0x00000017) #define ICSNEO_DEVICETYPE_RAD_A2B ((devicetype_t)0x00000017)
#define ICSNEO_DEVICETYPE_RADEPSILON ((devicetype_t)0x00000018) #define ICSNEO_DEVICETYPE_RADEPSILON ((devicetype_t)0x00000018)
#define ICSNEO_DEVICETYPE_RADGALAXY2 ((devicetype_t)0x00000021)
#define ICSNEO_DEVICETYPE_RADMoon3 ((devicetype_t)0x00000023) #define ICSNEO_DEVICETYPE_RADMoon3 ((devicetype_t)0x00000023)
#define ICSNEO_DEVICETYPE_RADCOMET ((devicetype_t)0x00000024) #define ICSNEO_DEVICETYPE_RADCOMET ((devicetype_t)0x00000024)
#define ICSNEO_DEVICETYPE_FIRE3FLEXRAY ((devicetype_t)0x00000025) #define ICSNEO_DEVICETYPE_FIRE3FLEXRAY ((devicetype_t)0x00000025)
@@ -0,0 +1,120 @@
#ifndef __RADGALAXY2_H_
#define __RADGALAXY2_H_
#ifdef __cplusplus
#include "icsneo/device/device.h"
#include "icsneo/device/devicetype.h"
#include "icsneo/communication/packetizer.h"
#include "icsneo/communication/decoder.h"
#include "icsneo/disk/extextractordiskreaddriver.h"
#include "icsneo/disk/neomemorydiskdriver.h"
#include "icsneo/device/tree/radgalaxy2/radgalaxy2settings.h"
namespace icsneo {
class RADGalaxy2 : public Device {
public:
// Serial numbers start with G2
// Ethernet MAC allocation is 0x17, standard driver is Raw
ICSNEO_FINDABLE_DEVICE(RADGalaxy2, DeviceType::RADGalaxy2, "G2");
static const std::vector<Network>& GetSupportedNetworks() {
static std::vector<Network> supportedNetworks = {
Network::NetID::HSCAN,
Network::NetID::MSCAN,
Network::NetID::HSCAN2,
Network::NetID::HSCAN3,
Network::NetID::HSCAN4,
Network::NetID::HSCAN5,
Network::NetID::HSCAN6,
Network::NetID::HSCAN7,
Network::NetID::LIN,
Network::NetID::LIN2,
Network::NetID::Ethernet,
Network::NetID::Ethernet2,
Network::NetID::Ethernet3,
Network::NetID::OP_Ethernet1,
Network::NetID::OP_Ethernet2,
Network::NetID::OP_Ethernet3,
Network::NetID::OP_Ethernet4,
Network::NetID::OP_Ethernet5,
Network::NetID::OP_Ethernet6,
Network::NetID::OP_Ethernet7,
Network::NetID::OP_Ethernet8,
Network::NetID::OP_Ethernet9,
Network::NetID::OP_Ethernet10,
Network::NetID::OP_Ethernet11,
Network::NetID::OP_Ethernet12,
Network::NetID::ISO9141,
Network::NetID::ISO9141_2,
Network::NetID::MDIO1,
Network::NetID::MDIO2,
Network::NetID::MDIO3,
Network::NetID::MDIO4,
Network::NetID::MDIO5,
};
return supportedNetworks;
}
size_t getEthernetActivationLineCount() const override { return 1; }
bool supportsTC10() const override { return true; }
protected:
RADGalaxy2(neodevice_t neodevice, const driver_factory_t& makeDriver) : Device(neodevice) {
initialize<RADGalaxy2Settings, Disk::ExtExtractorDiskReadDriver, Disk::NeoMemoryDiskDriver>(makeDriver);
}
void setupPacketizer(Packetizer& packetizer) override {
Device::setupPacketizer(packetizer);
packetizer.disableChecksum = true;
packetizer.align16bit = false;
}
void setupEncoder(Encoder& encoder) override {
Device::setupEncoder(encoder);
encoder.supportCANFD = true;
encoder.supportEthPhy = true;
}
void setupDecoder(Decoder& decoder) override {
Device::setupDecoder(decoder);
decoder.timestampResolution = 10; // Timestamps are in 10ns increments instead of the usual 25ns
}
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); }
void handleDeviceStatus(const std::shared_ptr<RawMessage>& message) override {
if(message->data.size() < sizeof(radgalaxy2_status_t))
return;
std::lock_guard<std::mutex> lk(ioMutex);
const radgalaxy2_status_t* status = reinterpret_cast<const radgalaxy2_status_t*>(message->data.data());
ethActivationStatus = status->ethernetActivationLineEnabled;
}
std::optional<MemoryAddress> getCoreminiStartAddressFlash() const override {
return 512*4;
}
std::optional<MemoryAddress> getCoreminiStartAddressSD() const override {
return 0;
}
};
}
#endif // __cplusplus
#endif
@@ -0,0 +1,192 @@
#ifndef __RADGALAXY2SETTINGS_H_
#define __RADGALAXY2SETTINGS_H_
#include "icsneo/device/idevicesettings.h"
#include <stdint.h>
#ifdef __cplusplus
namespace icsneo {
#endif
#pragma pack(push, 2)
typedef struct {
uint32_t ecu_id;
uint16_t perf_en;
/* CAN */
CAN_SETTINGS can1;
CANFD_SETTINGS canfd1;
CAN_SETTINGS can2;
CANFD_SETTINGS canfd2;
CAN_SETTINGS can3;
CANFD_SETTINGS canfd3;
CAN_SETTINGS can4;
CANFD_SETTINGS canfd4;
CAN_SETTINGS can5;
CANFD_SETTINGS canfd5;
CAN_SETTINGS can6;
CANFD_SETTINGS canfd6;
CAN_SETTINGS can7;
CANFD_SETTINGS canfd7;
CAN_SETTINGS can8;
CANFD_SETTINGS canfd8;
// SWCAN_SETTINGS swcan1; G2 does not have SWCAN.
uint16_t network_enables;
// SWCAN_SETTINGS swcan2; G2 does not have SWCAN.
uint16_t network_enables_2;
uint32_t pwr_man_timeout;
uint16_t pwr_man_enable;
uint16_t network_enabled_on_boot;
/* ISO15765-2 Transport Layer */
uint16_t iso15765_separation_time_offset;
/* ISO9141 - Keyword */
uint16_t iso_9141_kwp_enable_reserved;
ISO9141_KEYWORD2000_SETTINGS iso9141_kwp_settings_1;
uint16_t iso_parity_1;
uint16_t iso_msg_termination_1;
uint16_t idle_wakeup_network_enables_1;
uint16_t idle_wakeup_network_enables_2;
/* reserved for T1 networks such as BR1, BR2, etc.. */
uint16_t network_enables_3;
uint16_t idle_wakeup_network_enables_3;
STextAPISettings text_api;
uint64_t termination_enables; // New feature unlike Galaxy.
TIMESYNC_ICSHARDWARE_SETTINGS timeSyncSettings;
struct
{
uint16_t hwComLatencyTestEn : 1;
uint16_t reserved : 15;
} flags;
LIN_SETTINGS lin1;
OP_ETH_GENERAL_SETTINGS opEthGen;
OP_ETH_SETTINGS opEth1;
OP_ETH_SETTINGS opEth2;
OP_ETH_SETTINGS opEth3;
OP_ETH_SETTINGS opEth4;
OP_ETH_SETTINGS opEth5;
OP_ETH_SETTINGS opEth6;
OP_ETH_SETTINGS opEth7;
OP_ETH_SETTINGS opEth8;
OP_ETH_SETTINGS opEth9;
OP_ETH_SETTINGS opEth10;
OP_ETH_SETTINGS opEth11;
OP_ETH_SETTINGS opEth12;
OP_ETH_SETTINGS opEth13;
OP_ETH_SETTINGS opEth14;
OP_ETH_SETTINGS opEth15;
OP_ETH_SETTINGS opEth16;
ETHERNET10G_SETTINGS ethernet10g;
ETHERNET10G_SETTINGS ethernet10g_2;
ETHERNET10G_SETTINGS ethernet10g_3;
uint16_t network_enables_4;
RAD_REPORTING_SETTINGS reporting;
RAD_GPTP_SETTINGS gPTP;
uint64_t network_enables_5;
LIN_SETTINGS lin2;
} radgalaxy2_settings_t;
typedef struct {
uint8_t unused[3];
uint8_t ethernetActivationLineEnabled;
} radgalaxy2_status_t;
#pragma pack(pop)
#ifdef __cplusplus
#include <iostream>
class RADGalaxy2Settings : public IDeviceSettings {
public:
RADGalaxy2Settings(std::shared_ptr<Communication> com) : IDeviceSettings(com, sizeof(radgalaxy2_settings_t)) {}
const CAN_SETTINGS* getCANSettingsFor(Network net) const override {
auto cfg = getStructurePointer<radgalaxy2_settings_t>();
if(cfg == nullptr)
return nullptr;
switch(net.getNetID()) {
case Network::NetID::HSCAN:
return &(cfg->can1);
case Network::NetID::MSCAN:
return &(cfg->can2);
case Network::NetID::HSCAN2:
return &(cfg->can3);
case Network::NetID::HSCAN3:
return &(cfg->can4);
case Network::NetID::HSCAN4:
return &(cfg->can5);
case Network::NetID::HSCAN5:
return &(cfg->can6);
case Network::NetID::HSCAN6:
return &(cfg->can7);
case Network::NetID::HSCAN7:
return &(cfg->can8);
default:
return nullptr;
}
}
const CANFD_SETTINGS* getCANFDSettingsFor(Network net) const override {
auto cfg = getStructurePointer<radgalaxy2_settings_t>();
if(cfg == nullptr)
return nullptr;
switch(net.getNetID()) {
case Network::NetID::HSCAN:
return &(cfg->canfd1);
case Network::NetID::MSCAN:
return &(cfg->canfd2);
case Network::NetID::HSCAN2:
return &(cfg->canfd3);
case Network::NetID::HSCAN3:
return &(cfg->canfd4);
case Network::NetID::HSCAN4:
return &(cfg->canfd5);
case Network::NetID::HSCAN5:
return &(cfg->canfd6);
case Network::NetID::HSCAN6:
return &(cfg->canfd7);
case Network::NetID::HSCAN7:
return &(cfg->canfd8);
default:
return nullptr;
}
}
const LIN_SETTINGS* getLINSettingsFor(Network net) const override {
auto cfg = getStructurePointer<radgalaxy2_settings_t>();
if(cfg == nullptr)
return nullptr;
switch(net.getNetID()) {
case Network::NetID::LIN:
return &(cfg->lin1);
case Network::NetID::LIN2:
return &(cfg->lin2);
default:
return nullptr;
}
}
};
}
#endif // __cplusplus
#endif
+96 -1
View File
@@ -220,7 +220,7 @@ typedef unsigned __int64 uint64_t;
#define NEODEVICE_RADEPSILON_EXPRESS (0x0000001d) #define NEODEVICE_RADEPSILON_EXPRESS (0x0000001d)
#define NEODEVICE_RADPROXIMA (0x0000001e) #define NEODEVICE_RADPROXIMA (0x0000001e)
#define NEODEVICE_NEW_DEVICE_58 (0x0000001f) #define NEODEVICE_NEW_DEVICE_58 (0x0000001f)
#define NEODEVICE_NEW_DEVICE_59 (0x00000021) #define NEODEVICE_RAD_GALAXY_2 (0x00000021)
#define NEODEVICE_RAD_BMS (0x00000022) #define NEODEVICE_RAD_BMS (0x00000022)
#define NEODEVICE_RADMOON3 (0x00000023) #define NEODEVICE_RADMOON3 (0x00000023)
#define NEODEVICE_RADCOMET (0x00000024) #define NEODEVICE_RADCOMET (0x00000024)
@@ -2999,6 +2999,100 @@ typedef struct _SRADGigastarSettings
#define SRADGigastarSettings_SIZE 710 #define SRADGigastarSettings_SIZE 710
typedef struct _SRADGalaxy2Settings
{
uint32_t ecu_id;
uint16_t perf_en;
/* CAN */
CAN_SETTINGS can1;
CANFD_SETTINGS canfd1;
CAN_SETTINGS can2;
CANFD_SETTINGS canfd2;
CAN_SETTINGS can3;
CANFD_SETTINGS canfd3;
CAN_SETTINGS can4;
CANFD_SETTINGS canfd4;
CAN_SETTINGS can5;
CANFD_SETTINGS canfd5;
CAN_SETTINGS can6;
CANFD_SETTINGS canfd6;
CAN_SETTINGS can7;
CANFD_SETTINGS canfd7;
CAN_SETTINGS can8;
CANFD_SETTINGS canfd8;
// SWCAN_SETTINGS swcan1; G2 does not have SWCAN.
uint16_t network_enables;
// SWCAN_SETTINGS swcan2; G2 does not have SWCAN.
uint16_t network_enables_2;
uint32_t pwr_man_timeout;
uint16_t pwr_man_enable;
uint16_t network_enabled_on_boot;
/* ISO15765-2 Transport Layer */
uint16_t iso15765_separation_time_offset;
/* ISO9141 - Keyword */
uint16_t iso_9141_kwp_enable_reserved;
ISO9141_KEYWORD2000_SETTINGS iso9141_kwp_settings_1;
uint16_t iso_parity_1;
uint16_t iso_msg_termination_1;
uint16_t idle_wakeup_network_enables_1;
uint16_t idle_wakeup_network_enables_2;
/* reserved for T1 networks such as BR1, BR2, etc.. */
uint16_t network_enables_3;
uint16_t idle_wakeup_network_enables_3;
STextAPISettings text_api;
uint64_t termination_enables; // New feature unlike Galaxy.
TIMESYNC_ICSHARDWARE_SETTINGS timeSyncSettings;
struct
{
uint16_t hwComLatencyTestEn : 1;
uint16_t reserved : 15;
} flags;
LIN_SETTINGS lin1;
OP_ETH_GENERAL_SETTINGS opEthGen;
OP_ETH_SETTINGS opEth1;
OP_ETH_SETTINGS opEth2;
OP_ETH_SETTINGS opEth3;
OP_ETH_SETTINGS opEth4;
OP_ETH_SETTINGS opEth5;
OP_ETH_SETTINGS opEth6;
OP_ETH_SETTINGS opEth7;
OP_ETH_SETTINGS opEth8;
OP_ETH_SETTINGS opEth9;
OP_ETH_SETTINGS opEth10;
OP_ETH_SETTINGS opEth11;
OP_ETH_SETTINGS opEth12;
OP_ETH_SETTINGS opEth13;
OP_ETH_SETTINGS opEth14;
OP_ETH_SETTINGS opEth15;
OP_ETH_SETTINGS opEth16;
ETHERNET10G_SETTINGS ethernet10g;
ETHERNET10G_SETTINGS ethernet10g_2;
ETHERNET10G_SETTINGS ethernet10g_3;
uint16_t network_enables_4;
RAD_REPORTING_SETTINGS reporting;
RAD_GPTP_SETTINGS gPTP;
uint64_t network_enables_5;
LIN_SETTINGS lin2;
} SRADGalaxy2Settings;
#define SRADGalaxy2Settings_SIZE 840
typedef struct _SVividCANSettings typedef struct _SVividCANSettings
{ {
uint32_t ecu_id; uint32_t ecu_id;
@@ -5425,6 +5519,7 @@ CHECK_STRUCT_SIZE(SPendantSettings);
CHECK_STRUCT_SIZE(SIEVBSettings); CHECK_STRUCT_SIZE(SIEVBSettings);
CHECK_STRUCT_SIZE(SEEVBSettings); CHECK_STRUCT_SIZE(SEEVBSettings);
CHECK_STRUCT_SIZE(SRADGalaxySettings); CHECK_STRUCT_SIZE(SRADGalaxySettings);
CHECK_STRUCT_SIZE(SRADGalaxy2Settings);
CHECK_STRUCT_SIZE(SRADStar2Settings); CHECK_STRUCT_SIZE(SRADStar2Settings);
CHECK_STRUCT_SIZE(SOBD2SimSettings) CHECK_STRUCT_SIZE(SOBD2SimSettings)
CHECK_STRUCT_SIZE(CmProbeSettings); CHECK_STRUCT_SIZE(CmProbeSettings);
+1
View File
@@ -19,6 +19,7 @@
#include "icsneo/device/tree/radmoont1s/radmoont1s.h" #include "icsneo/device/tree/radmoont1s/radmoont1s.h"
#include "icsneo/device/tree/radepsilon/radepsilon.h" #include "icsneo/device/tree/radepsilon/radepsilon.h"
#include "icsneo/device/tree/radgalaxy/radgalaxy.h" #include "icsneo/device/tree/radgalaxy/radgalaxy.h"
#include "icsneo/device/tree/radgalaxy2/radgalaxy2.h"
#include "icsneo/device/tree/radgigastar/radgigastar.h" #include "icsneo/device/tree/radgigastar/radgigastar.h"
#include "icsneo/device/tree/radgigastar2/radgigastar2.h" #include "icsneo/device/tree/radgigastar2/radgigastar2.h"
#include "icsneo/device/tree/radjupiter/radjupiter.h" #include "icsneo/device/tree/radjupiter/radjupiter.h"
@@ -19,6 +19,7 @@
#include "icsneo/device/tree/radmoont1s/radmoont1s.h" #include "icsneo/device/tree/radmoont1s/radmoont1s.h"
#include "icsneo/device/tree/radepsilon/radepsilon.h" #include "icsneo/device/tree/radepsilon/radepsilon.h"
#include "icsneo/device/tree/radgalaxy/radgalaxy.h" #include "icsneo/device/tree/radgalaxy/radgalaxy.h"
#include "icsneo/device/tree/radgalaxy2/radgalaxy2.h"
#include "icsneo/device/tree/radgigastar/radgigastar.h" #include "icsneo/device/tree/radgigastar/radgigastar.h"
#include "icsneo/device/tree/radgigastar2/radgigastar2.h" #include "icsneo/device/tree/radgigastar2/radgigastar2.h"
#include "icsneo/device/tree/radjupiter/radjupiter.h" #include "icsneo/device/tree/radjupiter/radjupiter.h"
+15
View File
@@ -88,6 +88,21 @@ void TCP::Socket::poll(uint16_t event, uint32_t msTimeout) {
} }
void TCP::Find(std::vector<FoundDevice>& found) { void TCP::Find(std::vector<FoundDevice>& found) {
static const auto tcpDisabled = []() -> bool {
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable : 4996)
#endif
const auto disabled = std::getenv("LIBICSNEO_DISABLE_TCP");
return disabled ? std::stoi(disabled) : false;
#ifdef _MSC_VER
#pragma warning(pop)
#endif
};
if(tcpDisabled()) {
return;
}
static const auto MDNS_PORT = htons((unsigned short)5353); static const auto MDNS_PORT = htons((unsigned short)5353);
static const auto MDNS_IP = htonl((((uint32_t)224U) << 24U) | ((uint32_t)251U)); static const auto MDNS_IP = htonl((((uint32_t)224U) << 24U) | ((uint32_t)251U));