Begin work on FlexRay support
parent
0607986114
commit
2f9844df92
|
|
@ -87,7 +87,9 @@ else()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(COMMON_SRC
|
set(COMMON_SRC
|
||||||
|
communication/message/flexray/control/flexraycontrolmessage.cpp
|
||||||
communication/message/neomessage.cpp
|
communication/message/neomessage.cpp
|
||||||
|
communication/packet/flexraypacket.cpp
|
||||||
communication/packet/canpacket.cpp
|
communication/packet/canpacket.cpp
|
||||||
communication/packet/ethernetpacket.cpp
|
communication/packet/ethernetpacket.cpp
|
||||||
communication/decoder.cpp
|
communication/decoder.cpp
|
||||||
|
|
@ -96,6 +98,8 @@ set(COMMON_SRC
|
||||||
communication/multichannelcommunication.cpp
|
communication/multichannelcommunication.cpp
|
||||||
communication/communication.cpp
|
communication/communication.cpp
|
||||||
communication/icommunication.cpp
|
communication/icommunication.cpp
|
||||||
|
device/extensions/flexray/extension.cpp
|
||||||
|
device/extensions/flexray/controller.cpp
|
||||||
device/idevicesettings.cpp
|
device/idevicesettings.cpp
|
||||||
device/devicefinder.cpp
|
device/devicefinder.cpp
|
||||||
device/device.cpp
|
device/device.cpp
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,14 @@ bool EventManager::removeEventCallback(int id) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool EventManager::isDowngradingErrorsOnCurrentThread() const {
|
||||||
|
auto i = downgradedThreads.find(std::this_thread::get_id());
|
||||||
|
if(i != downgradedThreads.end()) {
|
||||||
|
return i->second;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void EventManager::get(std::vector<APIEvent>& eventOutput, size_t max, EventFilter filter) {
|
void EventManager::get(std::vector<APIEvent>& eventOutput, size_t max, EventFilter filter) {
|
||||||
std::lock_guard<std::mutex> lk(eventsMutex);
|
std::lock_guard<std::mutex> lk(eventsMutex);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -141,6 +141,22 @@ std::shared_ptr<Message> Communication::waitForMessageSync(std::shared_ptr<Messa
|
||||||
return returnedMessage;
|
return returnedMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Communication::dispatchMessage(const std::shared_ptr<Message>& msg) {
|
||||||
|
std::lock_guard<std::mutex> lk(messageCallbacksLock);
|
||||||
|
|
||||||
|
// We want callbacks to be able to access errors
|
||||||
|
const bool downgrade = EventManager::GetInstance().isDowngradingErrorsOnCurrentThread();
|
||||||
|
if(downgrade)
|
||||||
|
EventManager::GetInstance().cancelErrorDowngradingOnCurrentThread();
|
||||||
|
for(auto& cb : messageCallbacks) {
|
||||||
|
if(!closing) { // We might have closed while reading or processing
|
||||||
|
cb.second.callIfMatch(msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(downgrade)
|
||||||
|
EventManager::GetInstance().downgradeErrorsOnCurrentThread();
|
||||||
|
}
|
||||||
|
|
||||||
void Communication::readTask() {
|
void Communication::readTask() {
|
||||||
std::vector<uint8_t> readBytes;
|
std::vector<uint8_t> readBytes;
|
||||||
|
|
||||||
|
|
@ -155,17 +171,7 @@ void Communication::readTask() {
|
||||||
if(!decoder->decode(msg, packet))
|
if(!decoder->decode(msg, packet))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
std::lock_guard<std::mutex> lk(messageCallbacksLock);
|
dispatchMessage(msg);
|
||||||
|
|
||||||
for(auto& cb : messageCallbacks) {
|
|
||||||
if(!closing) { // We might have closed while reading or processing
|
|
||||||
// We want callbacks to be able to access errors
|
|
||||||
EventManager::GetInstance().cancelErrorDowngradingOnCurrentThread();
|
|
||||||
cb.second.callIfMatch(msg);
|
|
||||||
EventManager::GetInstance().downgradeErrorsOnCurrentThread();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,10 +3,12 @@
|
||||||
#include "icsneo/communication/message/serialnumbermessage.h"
|
#include "icsneo/communication/message/serialnumbermessage.h"
|
||||||
#include "icsneo/communication/message/resetstatusmessage.h"
|
#include "icsneo/communication/message/resetstatusmessage.h"
|
||||||
#include "icsneo/communication/message/readsettingsmessage.h"
|
#include "icsneo/communication/message/readsettingsmessage.h"
|
||||||
|
#include "icsneo/communication/message/flexray/control/flexraycontrolmessage.h"
|
||||||
#include "icsneo/communication/command.h"
|
#include "icsneo/communication/command.h"
|
||||||
#include "icsneo/device/device.h"
|
#include "icsneo/device/device.h"
|
||||||
#include "icsneo/communication/packet/canpacket.h"
|
#include "icsneo/communication/packet/canpacket.h"
|
||||||
#include "icsneo/communication/packet/ethernetpacket.h"
|
#include "icsneo/communication/packet/ethernetpacket.h"
|
||||||
|
#include "icsneo/communication/packet/flexraypacket.h"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
using namespace icsneo;
|
using namespace icsneo;
|
||||||
|
|
@ -51,6 +53,23 @@ bool Decoder::decode(std::shared_ptr<Message>& result, const std::shared_ptr<Pac
|
||||||
result->network = packet->network;
|
result->network = packet->network;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
case Network::Type::FlexRay: {
|
||||||
|
if(packet->data.size() < 24) {
|
||||||
|
report(APIEvent::Type::PacketDecodingError, APIEvent::Severity::Error);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
result = HardwareFlexRayPacket::DecodeToMessage(packet->data);
|
||||||
|
if(!result) {
|
||||||
|
report(APIEvent::Type::PacketDecodingError, APIEvent::Severity::Error);
|
||||||
|
return false; // A nullptr was returned, the packet was malformed
|
||||||
|
}
|
||||||
|
// Timestamps are in (resolution) ns increments since 1/1/2007 GMT 00:00:00.0000
|
||||||
|
// The resolution depends on the device
|
||||||
|
result->timestamp *= timestampResolution;
|
||||||
|
result->network = packet->network;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
case Network::Type::Internal: {
|
case Network::Type::Internal: {
|
||||||
switch(packet->network.getNetID()) {
|
switch(packet->network.getNetID()) {
|
||||||
case Network::NetID::Reset_Status: {
|
case Network::NetID::Reset_Status: {
|
||||||
|
|
@ -82,6 +101,15 @@ bool Decoder::decode(std::shared_ptr<Message>& result, const std::shared_ptr<Pac
|
||||||
result = msg;
|
result = msg;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
case Network::NetID::FlexRayControl: {
|
||||||
|
auto frResult = std::make_shared<FlexRayControlMessage>(*packet);
|
||||||
|
if(!frResult->decoded) {
|
||||||
|
report(APIEvent::Type::PacketDecodingError, APIEvent::Severity::Error);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
result = frResult;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
break;//return false;
|
break;//return false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,70 @@
|
||||||
|
#include <icsneo/communication/message/flexray/control/flexraycontrolmessage.h>
|
||||||
|
#include <cstring> // memcpy
|
||||||
|
|
||||||
|
using namespace icsneo;
|
||||||
|
|
||||||
|
std::vector<uint8_t> FlexRayControlMessage::BuildBaseControlArgs(uint8_t controller, FlexRay::Opcode op, std::initializer_list<uint8_t> args) {
|
||||||
|
std::vector<uint8_t> ret;
|
||||||
|
ret.reserve(args.size() + 4);
|
||||||
|
ret.push_back(controller);
|
||||||
|
const uint16_t size = args.size() + 1; // Add 1 for the opcode
|
||||||
|
ret.push_back(uint8_t(size));
|
||||||
|
ret.push_back(uint8_t(size >> 8));
|
||||||
|
ret.push_back(uint8_t(op));
|
||||||
|
ret.insert(ret.end(), args.begin(), args.end());
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<uint8_t> FlexRayControlMessage::BuildReadCCRegsArgs(uint8_t controller, uint16_t startAddress, uint8_t numRegisters) {
|
||||||
|
startAddress /= 4;
|
||||||
|
return BuildBaseControlArgs(controller, FlexRay::Opcode::ReadCCRegs, {
|
||||||
|
uint8_t(startAddress),
|
||||||
|
uint8_t(startAddress >> 8),
|
||||||
|
numRegisters
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<uint8_t> FlexRayControlMessage::BuildWriteCCRegArgs(uint8_t controller, uint16_t address, uint32_t value) {
|
||||||
|
address /= 4;
|
||||||
|
return BuildBaseControlArgs(controller, FlexRay::Opcode::ReadCCRegs, {
|
||||||
|
uint8_t(address),
|
||||||
|
uint8_t(address >> 8),
|
||||||
|
uint8_t(value),
|
||||||
|
uint8_t(value >> 8),
|
||||||
|
uint8_t(value >> 16),
|
||||||
|
uint8_t(value >> 24)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
FlexRayControlMessage::FlexRayControlMessage(const Packet& packet) : Message() {
|
||||||
|
if(packet.data.size() < 2)
|
||||||
|
return; // huh?
|
||||||
|
controller = packet.data[0];
|
||||||
|
if(controller < 2)
|
||||||
|
return; // Invalid controller
|
||||||
|
|
||||||
|
// Opcode is only ReadCCStatus or ReadCCRegs for the moment
|
||||||
|
opcode = FlexRay::Opcode(packet.data[1]);
|
||||||
|
if(opcode != FlexRay::Opcode::ReadCCRegs && opcode != FlexRay::Opcode::ReadCCStatus)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Read out registers
|
||||||
|
size_t bytes = packet.data.size() - 2;
|
||||||
|
const size_t count = bytes / sizeof(uint32_t);
|
||||||
|
bytes -= bytes % sizeof(uint32_t); // trim off any trailing bytes
|
||||||
|
registers.resize(count);
|
||||||
|
memcpy(registers.data(), packet.data.data() + 2, bytes);
|
||||||
|
|
||||||
|
// If it was a status message, we should decode these registers into their components
|
||||||
|
if(opcode == FlexRay::Opcode::ReadCCStatus) {
|
||||||
|
if(count < 8)
|
||||||
|
return;
|
||||||
|
pocStatus = FlexRay::POCStatus(registers[0] & 0x0000003F);
|
||||||
|
slotCounterA = registers[4] & 0x0000FFFF;
|
||||||
|
slotCounterB = (registers[4] & 0xFFFF0000) >> 16;
|
||||||
|
rateCorrection = registers[6];
|
||||||
|
offsetCorrection = registers[7];
|
||||||
|
}
|
||||||
|
|
||||||
|
decoded = true;
|
||||||
|
}
|
||||||
|
|
@ -25,6 +25,7 @@ bool MultiChannelCommunication::sendPacket(std::vector<uint8_t>& bytes) {
|
||||||
|
|
||||||
void MultiChannelCommunication::readTask() {
|
void MultiChannelCommunication::readTask() {
|
||||||
bool readMore = true;
|
bool readMore = true;
|
||||||
|
bool gotPacket = false; // Have we got the first valid packet (don't flag errors otherwise)
|
||||||
std::deque<uint8_t> usbReadFifo;
|
std::deque<uint8_t> usbReadFifo;
|
||||||
std::vector<uint8_t> readBytes;
|
std::vector<uint8_t> readBytes;
|
||||||
std::vector<uint8_t> payloadBytes;
|
std::vector<uint8_t> payloadBytes;
|
||||||
|
|
@ -108,19 +109,11 @@ void MultiChannelCommunication::readTask() {
|
||||||
if(packetizer->input(payloadBytes)) {
|
if(packetizer->input(payloadBytes)) {
|
||||||
for(auto& packet : packetizer->output()) {
|
for(auto& packet : packetizer->output()) {
|
||||||
std::shared_ptr<Message> msg;
|
std::shared_ptr<Message> msg;
|
||||||
if(!decoder->decode(msg, packet)) {
|
if(!decoder->decode(msg, packet))
|
||||||
report(APIEvent::Type::Unknown, APIEvent::Severity::Error); // TODO Use specific error
|
continue; // Error will have been reported from within decoder
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
for(auto& cb : messageCallbacks) { // We might have closed while reading or processing
|
gotPacket = true;
|
||||||
if(!closing) {
|
dispatchMessage(msg);
|
||||||
// We want callbacks to be able to access errors
|
|
||||||
EventManager::GetInstance().cancelErrorDowngradingOnCurrentThread();
|
|
||||||
cb.second.callIfMatch(msg);
|
|
||||||
EventManager::GetInstance().downgradeErrorsOnCurrentThread();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,63 @@
|
||||||
|
#include "icsneo/communication/packet/flexraypacket.h"
|
||||||
|
|
||||||
|
using namespace icsneo;
|
||||||
|
|
||||||
|
std::shared_ptr<FlexRayMessage> HardwareFlexRayPacket::DecodeToMessage(const std::vector<uint8_t>& bytestream) {
|
||||||
|
const HardwareFlexRayPacket* data = (const HardwareFlexRayPacket*)bytestream.data();
|
||||||
|
if(!data->timestamp.IsExtended) // We can only process "extended" frames here
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
|
auto msg = std::make_shared<FlexRayMessage>();
|
||||||
|
|
||||||
|
// This timestamp is raw off the device (in timestampResolution increments)
|
||||||
|
// Decoder will fix as it has information about the timestampResolution increments
|
||||||
|
msg->timestamp = data->timestamp.TS;
|
||||||
|
|
||||||
|
// Always get the frame length, even for a symbol
|
||||||
|
msg->framelen = data->frame_length_12_5ns * 12.5e-9;
|
||||||
|
|
||||||
|
if(data->tss_length_12_5ns == 0xffff) {// Flag value meaning this is a symbol
|
||||||
|
msg->symbol = FlexRay::Symbol::Unknown; // We can't know the symbol yet because this will depend on the baudrate
|
||||||
|
// Eventually we'll have to get this from the framelen
|
||||||
|
} else {
|
||||||
|
msg->tsslen = data->tss_length_12_5ns * 12.5e-9;
|
||||||
|
msg->channelB = data->statusBits.bits.chb;
|
||||||
|
|
||||||
|
if(data->statusBits.bits.bytesRxed >= 5) {
|
||||||
|
if(data->statusBits.bits.hcrc_error)
|
||||||
|
msg->headerCRCStatus = FlexRay::CRCStatus::Error;
|
||||||
|
} else {
|
||||||
|
msg->headerCRCStatus = FlexRay::CRCStatus::NoCRC;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t numBytes = data->payload_len * 2;
|
||||||
|
if(ssize_t(numBytes) >= ssize_t(data->Length) - 4) {
|
||||||
|
if(data->statusBits.bits.fcrc_error)
|
||||||
|
msg->crcStatus = FlexRay::CRCStatus::Error;
|
||||||
|
} else {
|
||||||
|
msg->crcStatus = FlexRay::CRCStatus::NoCRC;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(data->statusBits.bits.bytesRxed >= 5) { // Received entire header
|
||||||
|
msg->headerCRC = (data->hdr_crc_10 << 10) | data->hdr_crc_9_0;
|
||||||
|
if(msg->headerCRCStatus != FlexRay::CRCStatus::Error) {
|
||||||
|
msg->reserved0was1 = data->reserved_0;
|
||||||
|
msg->payloadPreamble = data->payload_preamble;
|
||||||
|
msg->nullFrame = data->null_frame;
|
||||||
|
msg->sync = data->sync;
|
||||||
|
msg->startup = data->startup;
|
||||||
|
msg->id = data->id;
|
||||||
|
if(ssize_t(numBytes) != ssize_t(data->Length) - 4) {
|
||||||
|
|
||||||
|
} else {
|
||||||
|
// This is an error, probably need to flag it
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return msg;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool HardwareFlexRayPacket::EncodeFromMessage(const FlexRayMessage& message, std::vector<uint8_t>& bytestream, const device_eventhandler_t& report) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
@ -191,7 +191,9 @@ bool Device::open() {
|
||||||
if(!settings->disabled)
|
if(!settings->disabled)
|
||||||
settings->refresh();
|
settings->refresh();
|
||||||
|
|
||||||
internalHandlerCallbackID = com->addMessageCallback(MessageCallback(MessageFilter(Network::Type::Internal), [this](std::shared_ptr<Message> message) {
|
MessageFilter filter;
|
||||||
|
filter.includeInternalInAny = true;
|
||||||
|
internalHandlerCallbackID = com->addMessageCallback(MessageCallback(filter, [this](std::shared_ptr<Message> message) {
|
||||||
handleInternalMessage(message);
|
handleInternalMessage(message);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|
@ -228,7 +230,7 @@ bool Device::goOnline() {
|
||||||
MessageFilter filter(Network::NetID::Reset_Status);
|
MessageFilter filter(Network::NetID::Reset_Status);
|
||||||
filter.includeInternalInAny = true;
|
filter.includeInternalInAny = true;
|
||||||
|
|
||||||
// wait until communication is enabled or 10 seconds, whichever comes first
|
// Wait until communication is enabled or 5 seconds, whichever comes first
|
||||||
while((std::chrono::system_clock::now() - startTime) < std::chrono::seconds(5)) {
|
while((std::chrono::system_clock::now() - startTime) < std::chrono::seconds(5)) {
|
||||||
if(latestResetStatus && latestResetStatus->comEnabled)
|
if(latestResetStatus && latestResetStatus->comEnabled)
|
||||||
break;
|
break;
|
||||||
|
|
@ -331,6 +333,17 @@ Network Device::getNetworkByNumber(Network::Type type, size_t index) const {
|
||||||
return Network::NetID::Invalid;
|
return Network::NetID::Invalid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Device::addExtension(std::shared_ptr<DeviceExtension>&& extension) {
|
||||||
|
std::lock_guard<std::mutex> lk(extensionsLock);
|
||||||
|
extensions.push_back(extension);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Device::forEachExtension(std::function<void(const std::shared_ptr<DeviceExtension>&)> fn) {
|
||||||
|
std::lock_guard<std::mutex> lk(extensionsLock);
|
||||||
|
for(const auto& ext : extensions)
|
||||||
|
fn(ext);
|
||||||
|
}
|
||||||
|
|
||||||
void Device::handleInternalMessage(std::shared_ptr<Message> message) {
|
void Device::handleInternalMessage(std::shared_ptr<Message> message) {
|
||||||
switch(message->network.getNetID()) {
|
switch(message->network.getNetID()) {
|
||||||
case Network::NetID::Reset_Status:
|
case Network::NetID::Reset_Status:
|
||||||
|
|
@ -339,6 +352,9 @@ void Device::handleInternalMessage(std::shared_ptr<Message> message) {
|
||||||
default:
|
default:
|
||||||
break; //std::cout << "HandleInternalMessage got a message from " << message->network << " and it was unhandled!" << std::endl;
|
break; //std::cout << "HandleInternalMessage got a message from " << message->network << " and it was unhandled!" << std::endl;
|
||||||
}
|
}
|
||||||
|
forEachExtension([&](const std::shared_ptr<DeviceExtension>& ext) {
|
||||||
|
ext->handleMessage(message);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void Device::updateLEDState() {
|
void Device::updateLEDState() {
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,120 @@
|
||||||
|
#include "icsneo/device/extensions/flexray/controller.h"
|
||||||
|
#include "icsneo/device/device.h"
|
||||||
|
|
||||||
|
using namespace icsneo;
|
||||||
|
|
||||||
|
std::shared_ptr<FlexRayControlMessage> FlexRay::Controller::getStatus() const {
|
||||||
|
std::lock_guard<std::mutex> lk(statusLock);
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
void FlexRay::Controller::_setStatus(std::shared_ptr<FlexRayControlMessage> msg) {
|
||||||
|
std::lock_guard<std::mutex> lk(statusLock);
|
||||||
|
status = msg;
|
||||||
|
}
|
||||||
|
|
||||||
|
void FlexRay::Controller::getReady() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void FlexRay::Controller::start() {
|
||||||
|
if(true) // TODO something
|
||||||
|
getReady();
|
||||||
|
if(wakeupBeforeStart)
|
||||||
|
setCurrentPOCCommand(FlexRay::POCCommand::Wakeup);
|
||||||
|
if(allowColdstart)
|
||||||
|
setCurrentPOCCommand(FlexRay::POCCommand::AllowColdstart);
|
||||||
|
setCurrentPOCCommand(FlexRay::POCCommand::Run);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::pair<bool, FlexRay::POCCommand> FlexRay::Controller::getCurrentPOCCommand(std::chrono::milliseconds timeout) const {
|
||||||
|
const auto val = readRegister(ERAYRegister::SUCC1, timeout);
|
||||||
|
return {val.first, FlexRay::POCCommand(val.second & 0x0000000F)};
|
||||||
|
}
|
||||||
|
|
||||||
|
bool FlexRay::Controller::setCurrentPOCCommand(FlexRay::POCCommand cmd, bool checkForSuccess, std::chrono::milliseconds timeout) {
|
||||||
|
const auto beforeWrite = std::chrono::steady_clock::now();
|
||||||
|
|
||||||
|
if(!writeRegister(ERAYRegister::SUCC1, uint32_t(cmd), true, timeout))
|
||||||
|
return false;
|
||||||
|
if(!checkForSuccess)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
const auto writeDuration = std::chrono::steady_clock::now() - beforeWrite;
|
||||||
|
timeout = std::chrono::duration_cast<std::chrono::milliseconds>(writeDuration - timeout);
|
||||||
|
if(timeout.count() <= 0)
|
||||||
|
return false; // Out of time!
|
||||||
|
|
||||||
|
return wasCommandSuccessful(timeout);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool FlexRay::Controller::wasCommandSuccessful(std::chrono::milliseconds timeout) const {
|
||||||
|
const auto val = getCurrentPOCCommand(timeout);
|
||||||
|
return val.first && val.second != FlexRay::POCCommand::CommandNotAccepted;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::pair<bool, uint32_t> FlexRay::Controller::readRegister(ERAYRegister reg, std::chrono::milliseconds timeout) const {
|
||||||
|
std::lock_guard<std::mutex> lk(readRegisterLock);
|
||||||
|
device.com->sendCommand(Command::FlexRayControl, FlexRayControlMessage::BuildReadCCRegsArgs(index, uint16_t(reg)));
|
||||||
|
std::shared_ptr<FlexRayControlMessage> resp;
|
||||||
|
const auto start = std::chrono::steady_clock::now();
|
||||||
|
while(!resp && (std::chrono::steady_clock::now() - start) < timeout) {
|
||||||
|
auto msg = device.com->waitForMessageSync(MessageFilter(icsneo::Network::NetID::FlexRayControl), timeout);
|
||||||
|
if(auto frmsg = std::dynamic_pointer_cast<FlexRayControlMessage>(msg)) {
|
||||||
|
if(frmsg->decoded && frmsg->controller == index && frmsg->opcode == FlexRay::Opcode::ReadCCRegs)
|
||||||
|
resp = frmsg;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(resp)
|
||||||
|
return {true, resp->registers[0]};
|
||||||
|
else
|
||||||
|
return {false, 0};
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t FlexRay::Controller::readRegisterOr(ERAYRegister reg, uint32_t defaultValue, std::chrono::milliseconds timeout) const {
|
||||||
|
auto ret = readRegister(reg, timeout);
|
||||||
|
return ret.first ? ret.second : defaultValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool FlexRay::Controller::writeRegister(
|
||||||
|
ERAYRegister reg,
|
||||||
|
uint32_t value,
|
||||||
|
uint32_t mask,
|
||||||
|
bool waitForPOCReady,
|
||||||
|
std::chrono::milliseconds timeout) {
|
||||||
|
|
||||||
|
if(mask != 0xffffffff) {
|
||||||
|
const auto beforeRead = std::chrono::steady_clock::now();
|
||||||
|
auto pair = readRegister(reg, timeout);
|
||||||
|
if(!pair.first)
|
||||||
|
return false; // Couldn't read, so we don't want to try to write anything
|
||||||
|
auto readDuration = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now() - beforeRead);
|
||||||
|
timeout = readDuration - timeout;
|
||||||
|
if(timeout.count() <= 0)
|
||||||
|
return false; // Out of time!
|
||||||
|
pair.second &= ~mask;
|
||||||
|
pair.second |= value & mask;
|
||||||
|
value = pair.second;
|
||||||
|
}
|
||||||
|
return writeRegister(reg, value, waitForPOCReady, timeout);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool FlexRay::Controller::writeRegister(
|
||||||
|
ERAYRegister reg,
|
||||||
|
uint32_t value,
|
||||||
|
bool waitForPOCReady,
|
||||||
|
std::chrono::milliseconds timeout) {
|
||||||
|
|
||||||
|
if(waitForPOCReady) {
|
||||||
|
const auto start = std::chrono::steady_clock::now();
|
||||||
|
bool pocBusy = isPOCBusy();
|
||||||
|
while(pocBusy && (std::chrono::steady_clock::now() - start) < timeout) {
|
||||||
|
pocBusy = isPOCBusy();
|
||||||
|
}
|
||||||
|
if(pocBusy) // timeout
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
device.com->sendCommand(Command::FlexRayControl, FlexRayControlMessage::BuildWriteCCRegArgs(index, uint16_t(reg), value));
|
||||||
|
return true; // Does the device send anything back to tell us this actually happened?
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,31 @@
|
||||||
|
#include "icsneo/device/extensions/flexray/extension.h"
|
||||||
|
#include "icsneo/device/device.h"
|
||||||
|
|
||||||
|
using namespace icsneo;
|
||||||
|
|
||||||
|
FlexRay::Extension::Extension(Device& device, uint8_t controllerCount) : DeviceExtension(device) {
|
||||||
|
for(uint8_t i = 0; i < controllerCount; i++)
|
||||||
|
controllers.emplace_back(std::make_shared<FlexRay::Controller>(device, i));
|
||||||
|
}
|
||||||
|
|
||||||
|
void FlexRay::Extension::handleMessage(const std::shared_ptr<Message>& message) {
|
||||||
|
switch(message->network.getNetID()) {
|
||||||
|
case Network::NetID::FlexRayControl: {
|
||||||
|
auto msg = std::dynamic_pointer_cast<FlexRayControlMessage>(message);
|
||||||
|
if(!msg || !msg->decoded)
|
||||||
|
return;
|
||||||
|
switch(msg->opcode) {
|
||||||
|
case FlexRay::Opcode::ReadCCStatus:
|
||||||
|
if(auto status = std::dynamic_pointer_cast<FlexRayControlMessage>(message)) { // TODO else report error?
|
||||||
|
if(status->controller >= controllers.size())
|
||||||
|
return; // TODO error
|
||||||
|
controllers[status->controller]->_setStatus(status);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -50,8 +50,9 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int addEventCallback(const EventCallback &cb);
|
bool isDowngradingErrorsOnCurrentThread() const;
|
||||||
|
|
||||||
|
int addEventCallback(const EventCallback &cb);
|
||||||
bool removeEventCallback(int id);
|
bool removeEventCallback(int id);
|
||||||
|
|
||||||
size_t eventCount(EventFilter filter = EventFilter()) const {
|
size_t eventCount(EventFilter filter = EventFilter()) const {
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,8 @@ enum class Command : uint8_t {
|
||||||
SetDefaultSettings = 0xA8, // Follow up with SaveSettings to write to EEPROM
|
SetDefaultSettings = 0xA8, // Follow up with SaveSettings to write to EEPROM
|
||||||
RequestStatusUpdate = 0xBC,
|
RequestStatusUpdate = 0xBC,
|
||||||
ReadSettings = 0xC7, // Previously known as 3G_READ_SETTINGS_EX
|
ReadSettings = 0xC7, // Previously known as 3G_READ_SETTINGS_EX
|
||||||
UpdateLEDState = 0xA7
|
UpdateLEDState = 0xA7,
|
||||||
|
FlexRayControl = 0xF3
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -64,6 +64,8 @@ protected:
|
||||||
std::map<int, MessageCallback> messageCallbacks;
|
std::map<int, MessageCallback> messageCallbacks;
|
||||||
std::atomic<bool> closing{false};
|
std::atomic<bool> closing{false};
|
||||||
|
|
||||||
|
void dispatchMessage(const std::shared_ptr<Message>& msg);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::thread readTaskThread;
|
std::thread readTaskThread;
|
||||||
void readTask();
|
void readTask();
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,35 @@
|
||||||
|
#ifndef __FLEXRAYCONTROLMESSAGE_H_
|
||||||
|
#define __FLEXRAYCONTROLMESSAGE_H_
|
||||||
|
|
||||||
|
#include "icsneo/communication/message/message.h"
|
||||||
|
#include "icsneo/communication/packet.h"
|
||||||
|
#include "icsneo/device/extensions/flexray/opcode.h"
|
||||||
|
#include "icsneo/device/extensions/flexray/pocstatus.h"
|
||||||
|
|
||||||
|
namespace icsneo {
|
||||||
|
|
||||||
|
// Internal message which gives us the state of the FlexRay Controllers
|
||||||
|
class FlexRayControlMessage : public Message {
|
||||||
|
public:
|
||||||
|
static std::vector<uint8_t> BuildBaseControlArgs(uint8_t controller, FlexRay::Opcode op, std::initializer_list<uint8_t> args);
|
||||||
|
static std::vector<uint8_t> BuildReadCCRegsArgs(uint8_t controller, uint16_t startAddress, uint8_t numRegisters = 1);
|
||||||
|
static std::vector<uint8_t> BuildWriteCCRegArgs(uint8_t controller, uint16_t address, uint32_t value);
|
||||||
|
|
||||||
|
FlexRayControlMessage(const Packet& packet);
|
||||||
|
virtual ~FlexRayControlMessage() = default;
|
||||||
|
bool decoded = false;
|
||||||
|
uint8_t controller = 0xff; // Controller index, either 0 or 1
|
||||||
|
FlexRay::Opcode opcode = FlexRay::Opcode::Unknown;
|
||||||
|
FlexRay::POCStatus pocStatus = FlexRay::POCStatus::Unknown;
|
||||||
|
uint16_t slotCounterA = 0;
|
||||||
|
uint16_t slotCounterB = 0;
|
||||||
|
uint16_t macroTick = 0;
|
||||||
|
uint16_t cycleCount = 0;
|
||||||
|
uint32_t rateCorrection = 0;
|
||||||
|
uint32_t offsetCorrection = 0;
|
||||||
|
std::vector<uint32_t> registers;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -0,0 +1,32 @@
|
||||||
|
#ifndef __FLEXRAYMESSAGE_H_
|
||||||
|
#define __FLEXRAYMESSAGE_H_
|
||||||
|
|
||||||
|
#include "icsneo/communication/message/message.h"
|
||||||
|
#include "icsneo/device/extensions/flexray/symbol.h"
|
||||||
|
#include "icsneo/device/extensions/flexray/crcstatus.h"
|
||||||
|
|
||||||
|
namespace icsneo {
|
||||||
|
|
||||||
|
class FlexRayMessage : public Message {
|
||||||
|
public:
|
||||||
|
uint16_t id = 0;
|
||||||
|
double tsslen = 0;
|
||||||
|
double framelen = 0;
|
||||||
|
FlexRay::Symbol symbol = FlexRay::Symbol::None;
|
||||||
|
FlexRay::CRCStatus headerCRCStatus = FlexRay::CRCStatus::OK;
|
||||||
|
uint16_t headerCRC = 0;
|
||||||
|
FlexRay::CRCStatus crcStatus = FlexRay::CRCStatus::OK;
|
||||||
|
uint32_t frameCRC = 0;
|
||||||
|
bool channelB = false;
|
||||||
|
bool nullFrame = false;
|
||||||
|
bool reserved0was1 = false;
|
||||||
|
bool payloadPreamble = false;
|
||||||
|
bool sync = false;
|
||||||
|
bool startup = false;
|
||||||
|
bool dynamic = false;
|
||||||
|
uint8_t cycle = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -44,6 +44,62 @@ private:
|
||||||
HostPC_to_Microblaze = 0x80, // Host PC data to microblaze processor
|
HostPC_to_Microblaze = 0x80, // Host PC data to microblaze processor
|
||||||
Microblaze_to_HostPC = 0x81 // Microblaze processor data to host PC
|
Microblaze_to_HostPC = 0x81 // Microblaze processor data to host PC
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static bool FixSlaveVNETPacketNetID(Packet& packet);
|
||||||
|
enum class CoreMiniNetwork : uint8_t {
|
||||||
|
HSCAN1 = (0),
|
||||||
|
MSCAN1 = (1),
|
||||||
|
LIN1 = (2),
|
||||||
|
LIN2 = (3),
|
||||||
|
VIRTUAL = (4),
|
||||||
|
HSCAN2 = (5),
|
||||||
|
LSFTCAN1 = (6),
|
||||||
|
SWCAN1 = (7),
|
||||||
|
HSCAN3 = (8),
|
||||||
|
GMCGI = (9),
|
||||||
|
J1850_VPW = (10),
|
||||||
|
LIN3 = (11),
|
||||||
|
LIN4 = (12),
|
||||||
|
J1708 = (13),
|
||||||
|
HSCAN4 = (14),
|
||||||
|
HSCAN5 = (15),
|
||||||
|
KLINE1 = (16),
|
||||||
|
KLINE2 = (17),
|
||||||
|
KLINE3 = (18),
|
||||||
|
KLINE4 = (19),
|
||||||
|
FLEXRAY_1A = (20),
|
||||||
|
UART = (21),
|
||||||
|
UART2 = (22),
|
||||||
|
LIN5 = (23),
|
||||||
|
MOST25 = (24),
|
||||||
|
MOST50 = (25),
|
||||||
|
FLEXRAY_1B = (26),
|
||||||
|
SWCAN2 = (27),
|
||||||
|
ETHERNET_DAQ = (28),
|
||||||
|
ETHERNET = (29),
|
||||||
|
FLEXRAY_2A = (30),
|
||||||
|
FLEXRAY_2B = (31),
|
||||||
|
HSCAN6 = (32),
|
||||||
|
HSCAN7 = (33),
|
||||||
|
LIN6 = (34),
|
||||||
|
LSFTCAN2 = (35),
|
||||||
|
OP_ETHERNET1 = (36),
|
||||||
|
OP_ETHERNET2 = (37),
|
||||||
|
OP_ETHERNET3 = (38),
|
||||||
|
OP_ETHERNET4 = (39),
|
||||||
|
OP_ETHERNET5 = (40),
|
||||||
|
OP_ETHERNET6 = (41),
|
||||||
|
OP_ETHERNET7 = (42),
|
||||||
|
OP_ETHERNET8 = (43),
|
||||||
|
OP_ETHERNET9 = (44),
|
||||||
|
OP_ETHERNET10 = (45),
|
||||||
|
OP_ETHERNET11 = (46),
|
||||||
|
OP_ETHERNET12 = (47),
|
||||||
|
KLINE5 = (48),
|
||||||
|
KLINE6 = (49),
|
||||||
|
FLEXRAY1 = (50),
|
||||||
|
FLEXRAY2 = (51)
|
||||||
|
};
|
||||||
static bool CommandTypeIsValid(CommandType cmd) {
|
static bool CommandTypeIsValid(CommandType cmd) {
|
||||||
switch(cmd) {
|
switch(cmd) {
|
||||||
case CommandType::PlasmaReadRequest:
|
case CommandType::PlasmaReadRequest:
|
||||||
|
|
|
||||||
|
|
@ -112,6 +112,7 @@ public:
|
||||||
HSCAN7 = 97,
|
HSCAN7 = 97,
|
||||||
LIN6 = 98,
|
LIN6 = 98,
|
||||||
LSFTCAN2 = 99,
|
LSFTCAN2 = 99,
|
||||||
|
FlexRayControl = 243,
|
||||||
HW_COM_Latency_Test = 512,
|
HW_COM_Latency_Test = 512,
|
||||||
Device_Status = 513,
|
Device_Status = 513,
|
||||||
Any = 0xfffe, // Never actually set as type, but used as flag for filtering
|
Any = 0xfffe, // Never actually set as type, but used as flag for filtering
|
||||||
|
|
@ -187,6 +188,7 @@ public:
|
||||||
case NetID::RED:
|
case NetID::RED:
|
||||||
case NetID::Reset_Status:
|
case NetID::Reset_Status:
|
||||||
case NetID::Device_Status:
|
case NetID::Device_Status:
|
||||||
|
case NetID::FlexRayControl:
|
||||||
return Type::Internal;
|
return Type::Internal;
|
||||||
case NetID::Invalid:
|
case NetID::Invalid:
|
||||||
case NetID::Any:
|
case NetID::Any:
|
||||||
|
|
@ -408,14 +410,17 @@ public:
|
||||||
return "LIN 6";
|
return "LIN 6";
|
||||||
case NetID::LSFTCAN2:
|
case NetID::LSFTCAN2:
|
||||||
return "LSFTCAN 2";
|
return "LSFTCAN 2";
|
||||||
|
case NetID::FlexRayControl:
|
||||||
|
return "FlexRay Control";
|
||||||
case NetID::HW_COM_Latency_Test:
|
case NetID::HW_COM_Latency_Test:
|
||||||
return "HW COM Latency Test";
|
return "HW COM Latency Test";
|
||||||
case NetID::Device_Status:
|
case NetID::Device_Status:
|
||||||
return "Device Status";
|
return "Device Status";
|
||||||
|
case NetID::Any:
|
||||||
case NetID::Invalid:
|
case NetID::Invalid:
|
||||||
default:
|
break;
|
||||||
return "Invalid Network";
|
|
||||||
}
|
}
|
||||||
|
return "Invalid Network";
|
||||||
}
|
}
|
||||||
|
|
||||||
Network() { setValue(NetID::Invalid); }
|
Network() { setValue(NetID::Invalid); }
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,66 @@
|
||||||
|
#ifndef __FLEXRAYPACKET_H__
|
||||||
|
#define __FLEXRAYPACKET_H__
|
||||||
|
|
||||||
|
#include "icsneo/communication/message/flexray/flexraymessage.h"
|
||||||
|
#include "icsneo/api/eventmanager.h"
|
||||||
|
#include <cstdint>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
namespace icsneo {
|
||||||
|
|
||||||
|
struct HardwareFlexRayPacket {
|
||||||
|
static std::shared_ptr<FlexRayMessage> DecodeToMessage(const std::vector<uint8_t>& bytestream);
|
||||||
|
static bool EncodeFromMessage(const FlexRayMessage& message, std::vector<uint8_t>& bytestream, const device_eventhandler_t& report);
|
||||||
|
|
||||||
|
//Word 0
|
||||||
|
uint16_t id : 11;
|
||||||
|
uint16_t startup : 1;
|
||||||
|
uint16_t sync : 1;
|
||||||
|
uint16_t null_frame : 1;
|
||||||
|
uint16_t payload_preamble : 1;
|
||||||
|
uint16_t reserved_0 : 1;
|
||||||
|
//Word 1
|
||||||
|
uint16_t hdr_crc_10 : 1;
|
||||||
|
uint16_t payload_len : 7;
|
||||||
|
uint16_t reserved_1 : 4;
|
||||||
|
uint16_t txmsg : 1;
|
||||||
|
uint16_t reserved_2 : 3;
|
||||||
|
//Word 2
|
||||||
|
uint16_t cycle : 6;
|
||||||
|
uint16_t hdr_crc_9_0 : 10;
|
||||||
|
//Word 3 (D0-D1)
|
||||||
|
union {
|
||||||
|
uint16_t word;
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
uint16_t bytesRxed : 9;
|
||||||
|
uint16_t dynamic : 1;
|
||||||
|
uint16_t chb : 1;
|
||||||
|
uint16_t hcrc_error : 1;
|
||||||
|
uint16_t fcrc_error : 1;
|
||||||
|
uint16_t reserved_3 : 3;
|
||||||
|
} bits;
|
||||||
|
} statusBits;
|
||||||
|
//Word 4 (D2-D3)
|
||||||
|
uint16_t tss_length_12_5ns;
|
||||||
|
//Word 5 (D4-D5)
|
||||||
|
uint16_t frame_length_12_5ns;
|
||||||
|
//Word 6 (D6-D7)
|
||||||
|
uint16_t extra;
|
||||||
|
//Word 7
|
||||||
|
uint16_t stat;
|
||||||
|
//Word 8-14 (Timestamp)
|
||||||
|
struct {
|
||||||
|
uint64_t TS : 60;
|
||||||
|
uint64_t : 3; // Reserved for future status bits
|
||||||
|
uint64_t IsExtended : 1;
|
||||||
|
} timestamp;
|
||||||
|
//Word 15 (From Extended Header)
|
||||||
|
uint16_t NetworkID;
|
||||||
|
//Word 16 (From Extended Header)
|
||||||
|
uint16_t Length;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -10,11 +10,14 @@
|
||||||
#include "icsneo/device/idevicesettings.h"
|
#include "icsneo/device/idevicesettings.h"
|
||||||
#include "icsneo/device/nullsettings.h"
|
#include "icsneo/device/nullsettings.h"
|
||||||
#include "icsneo/device/devicetype.h"
|
#include "icsneo/device/devicetype.h"
|
||||||
|
#include "icsneo/device/extensions/deviceextension.h"
|
||||||
#include "icsneo/communication/communication.h"
|
#include "icsneo/communication/communication.h"
|
||||||
#include "icsneo/communication/packetizer.h"
|
#include "icsneo/communication/packetizer.h"
|
||||||
#include "icsneo/communication/encoder.h"
|
#include "icsneo/communication/encoder.h"
|
||||||
#include "icsneo/communication/decoder.h"
|
#include "icsneo/communication/decoder.h"
|
||||||
#include "icsneo/communication/message/resetstatusmessage.h"
|
#include "icsneo/communication/message/resetstatusmessage.h"
|
||||||
|
#include "icsneo/device/extensions/flexray/controller.h"
|
||||||
|
#include "icsneo/communication/message/flexray/control/flexraycontrolmessage.h"
|
||||||
#include "icsneo/third-party/concurrentqueue/concurrentqueue.h"
|
#include "icsneo/third-party/concurrentqueue/concurrentqueue.h"
|
||||||
|
|
||||||
namespace icsneo {
|
namespace icsneo {
|
||||||
|
|
@ -83,6 +86,10 @@ public:
|
||||||
virtual size_t getNetworkCountByType(Network::Type) const;
|
virtual size_t getNetworkCountByType(Network::Type) const;
|
||||||
virtual Network getNetworkByNumber(Network::Type, size_t) const;
|
virtual Network getNetworkByNumber(Network::Type, size_t) const;
|
||||||
|
|
||||||
|
virtual std::shared_ptr<FlexRay::Controller> getFlexRayControllerByNetwork(const Network& net) const { return nullptr; }
|
||||||
|
|
||||||
|
const device_eventhandler_t& getEventHandler() const { return report; }
|
||||||
|
|
||||||
std::shared_ptr<Communication> com;
|
std::shared_ptr<Communication> com;
|
||||||
std::unique_ptr<IDeviceSettings> settings;
|
std::unique_ptr<IDeviceSettings> settings;
|
||||||
|
|
||||||
|
|
@ -116,6 +123,7 @@ protected:
|
||||||
setupSettings(*settings);
|
setupSettings(*settings);
|
||||||
setupSupportedRXNetworks(supportedRXNetworks);
|
setupSupportedRXNetworks(supportedRXNetworks);
|
||||||
setupSupportedTXNetworks(supportedTXNetworks);
|
setupSupportedTXNetworks(supportedTXNetworks);
|
||||||
|
setupExtensions();
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual device_eventhandler_t makeEventHandler() {
|
virtual device_eventhandler_t makeEventHandler() {
|
||||||
|
|
@ -152,6 +160,20 @@ protected:
|
||||||
|
|
||||||
virtual void setupSupportedRXNetworks(std::vector<Network>&) {}
|
virtual void setupSupportedRXNetworks(std::vector<Network>&) {}
|
||||||
virtual void setupSupportedTXNetworks(std::vector<Network>&) {}
|
virtual void setupSupportedTXNetworks(std::vector<Network>&) {}
|
||||||
|
|
||||||
|
virtual void setupExtensions() {}
|
||||||
|
void addExtension(std::shared_ptr<DeviceExtension>&& extension);
|
||||||
|
|
||||||
|
template<typename Extension>
|
||||||
|
std::shared_ptr<Extension> getExtension() const {
|
||||||
|
std::shared_ptr<Extension> ret;
|
||||||
|
std::lock_guard<std::mutex> lk(extensionsLock);
|
||||||
|
for(auto& ext : extensions) {
|
||||||
|
if((ret = std::dynamic_pointer_cast<Extension>(ext)))
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
// END Initialization Functions
|
// END Initialization Functions
|
||||||
|
|
||||||
void handleInternalMessage(std::shared_ptr<Message> message);
|
void handleInternalMessage(std::shared_ptr<Message> message);
|
||||||
|
|
@ -162,6 +184,10 @@ private:
|
||||||
neodevice_t data;
|
neodevice_t data;
|
||||||
std::shared_ptr<ResetStatusMessage> latestResetStatus;
|
std::shared_ptr<ResetStatusMessage> latestResetStatus;
|
||||||
|
|
||||||
|
mutable std::mutex extensionsLock;
|
||||||
|
std::vector<std::shared_ptr<DeviceExtension>> extensions;
|
||||||
|
void forEachExtension(std::function<void(const std::shared_ptr<DeviceExtension>&)> fn);
|
||||||
|
|
||||||
std::vector<Network> supportedTXNetworks;
|
std::vector<Network> supportedTXNetworks;
|
||||||
std::vector<Network> supportedRXNetworks;
|
std::vector<Network> supportedRXNetworks;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,26 @@
|
||||||
|
#ifndef __DEVICEEXTENSION_H_
|
||||||
|
#define __DEVICEEXTENSION_H_
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
#include "icsneo/communication/message/message.h"
|
||||||
|
#include "icsneo/api/eventmanager.h"
|
||||||
|
|
||||||
|
namespace icsneo {
|
||||||
|
|
||||||
|
class Device;
|
||||||
|
|
||||||
|
class DeviceExtension {
|
||||||
|
public:
|
||||||
|
DeviceExtension(Device& device) : device(device) {}
|
||||||
|
virtual ~DeviceExtension() = default;
|
||||||
|
virtual const char* getName() const = 0;
|
||||||
|
virtual void handleMessage(const std::shared_ptr<Message>& message) {}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
Device& device;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace icsneo
|
||||||
|
|
||||||
|
|
||||||
|
#endif // __DEVICEEXTENSION_H_
|
||||||
|
|
@ -0,0 +1,74 @@
|
||||||
|
#ifndef __FLEXRAYCONTROLLER_H_
|
||||||
|
#define __FLEXRAYCONTROLLER_H_
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
#include <memory>
|
||||||
|
#include <chrono>
|
||||||
|
#include <mutex>
|
||||||
|
#include "icsneo/communication/message/flexray/control/flexraycontrolmessage.h"
|
||||||
|
#include "icsneo/device/extensions/flexray/erayregister.h"
|
||||||
|
#include "icsneo/device/extensions/flexray/poccommand.h"
|
||||||
|
|
||||||
|
namespace icsneo {
|
||||||
|
|
||||||
|
class Device;
|
||||||
|
|
||||||
|
namespace FlexRay {
|
||||||
|
|
||||||
|
class Controller {
|
||||||
|
public:
|
||||||
|
Controller(Device& device, uint8_t index) : device(device), index(index) {}
|
||||||
|
std::shared_ptr<FlexRayControlMessage> getStatus() const;
|
||||||
|
void _setStatus(std::shared_ptr<FlexRayControlMessage> msg);
|
||||||
|
|
||||||
|
bool getAllowColdstart() const { return allowColdstart; }
|
||||||
|
void setAllowColdstart(bool enable) { allowColdstart = enable; }
|
||||||
|
|
||||||
|
bool getWakeupBeforeStart() const { return wakeupBeforeStart; }
|
||||||
|
void setWakeupBeforeStart(bool enable) { wakeupBeforeStart = enable; }
|
||||||
|
|
||||||
|
void getReady();
|
||||||
|
void start();
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool isPOCBusy() const { return readRegisterOr(ERAYRegister::SUCC1, 0x00000080) & 0x00000080; }
|
||||||
|
std::pair<bool, FlexRay::POCCommand> getCurrentPOCCommand(std::chrono::milliseconds timeout = std::chrono::milliseconds(50)) const;
|
||||||
|
bool setCurrentPOCCommand(
|
||||||
|
FlexRay::POCCommand cmd,
|
||||||
|
bool checkForSuccess = true,
|
||||||
|
std::chrono::milliseconds timeout = std::chrono::milliseconds(50));
|
||||||
|
bool wasCommandSuccessful(std::chrono::milliseconds timeout = std::chrono::milliseconds(50)) const;
|
||||||
|
|
||||||
|
std::pair<bool, uint32_t> readRegister(
|
||||||
|
ERAYRegister reg,
|
||||||
|
std::chrono::milliseconds timeout = std::chrono::milliseconds(50)) const;
|
||||||
|
uint32_t readRegisterOr(
|
||||||
|
ERAYRegister reg,
|
||||||
|
uint32_t defaultValue = 0,
|
||||||
|
std::chrono::milliseconds timeout = std::chrono::milliseconds(50)) const;
|
||||||
|
bool writeRegister(
|
||||||
|
ERAYRegister reg,
|
||||||
|
uint32_t value,
|
||||||
|
uint32_t mask,
|
||||||
|
bool waitForPOCReady = true,
|
||||||
|
std::chrono::milliseconds timeout = std::chrono::milliseconds(50));
|
||||||
|
bool writeRegister(
|
||||||
|
ERAYRegister reg,
|
||||||
|
uint32_t value,
|
||||||
|
bool waitForPOCReady = true,
|
||||||
|
std::chrono::milliseconds timeout = std::chrono::milliseconds(50));
|
||||||
|
|
||||||
|
Device& device;
|
||||||
|
uint8_t index;
|
||||||
|
mutable std::mutex statusLock;
|
||||||
|
mutable std::mutex readRegisterLock;
|
||||||
|
std::shared_ptr<FlexRayControlMessage> status;
|
||||||
|
bool allowColdstart = false;
|
||||||
|
bool wakeupBeforeStart = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace FlexRay
|
||||||
|
|
||||||
|
} // namespace icsneo
|
||||||
|
|
||||||
|
#endif // __FLEXRAYCONTROLLER_H_
|
||||||
|
|
@ -0,0 +1,20 @@
|
||||||
|
#ifndef __FLEXRAYCRCSTATUS_H_
|
||||||
|
#define __FLEXRAYCRCSTATUS_H_
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
namespace icsneo {
|
||||||
|
|
||||||
|
namespace FlexRay {
|
||||||
|
|
||||||
|
enum class CRCStatus {
|
||||||
|
OK = 0,
|
||||||
|
Error,
|
||||||
|
NoCRC
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace FlexRay
|
||||||
|
|
||||||
|
} // namespace icsneo
|
||||||
|
|
||||||
|
#endif // __FLEXRAYCRCSTATUS_H_
|
||||||
|
|
@ -0,0 +1,116 @@
|
||||||
|
#ifndef __ERAYREGISTER_H_
|
||||||
|
#define __ERAYREGISTER_H_
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
namespace icsneo {
|
||||||
|
|
||||||
|
enum class ERAYRegister : uint32_t {
|
||||||
|
// Customer Registers : Not Part of ERAY, part of FUJITSU FlexRay ASSP MB88121C
|
||||||
|
VER = 0x0000,// Version Information Register reset = 0440_79FF Access = r
|
||||||
|
CCNT = 0x0004,// Clock Control Register reset = 0000_0000 Access = r/w
|
||||||
|
DBGS_DMAS = 0x0008,// Debug Support Register / DMA Support Register reset = 0000_0000 Acess = r/w
|
||||||
|
INT_REG = 0x000C,// Interrupt Register Register reset = 0000_0000 Acess = r/w
|
||||||
|
LCK = 0x001C,// Lock Register reset = 0000_0000 Acess = r/w
|
||||||
|
|
||||||
|
// Interrupt-Related Registers
|
||||||
|
EIR = 0x0020,// Error Interrupt Register reset=0000_0000 Access = r/w
|
||||||
|
SIR = 0x0024,// Status Interrupt Register 0000_0000 r/w
|
||||||
|
EILS = 0x0028,// Error Interrupt Line Select Register 0000_0000 r/w
|
||||||
|
SILS = 0x002C,// Status Interrupt Line Select Register 0303_FFFF r/w
|
||||||
|
EIES = 0x0030,// Error Interrupt Enable Register (set) 0000_0000 r/w
|
||||||
|
EIER = 0x0034,// Error Interrupt Enable Register (reset) 0000_0000 r/w
|
||||||
|
SIES = 0x0038,// Status Interrupt Enable Register (set) 0000_0000 r/w
|
||||||
|
SIER = 0x003C,// Status Interrupt Enable Register (reset) 0000_0000 r/w
|
||||||
|
ILE = 0x0040,// Interrupt Line Enable Register 0000_0000 r/w
|
||||||
|
T0C = 0x0044,// Timer 0 Configuration Register 0 0000_0000 r/w
|
||||||
|
T1C = 0x0048,// Timer 0 Configuration Register 1 0002_0000 r/w
|
||||||
|
STPW1 = 0x004C,// Stop Watch Register 1 0000_0000 r/w
|
||||||
|
STPW2 = 0x0050,// Stop Watch Register 2 0000_0000 r
|
||||||
|
//0x0054<35>0x007C- reserved(11) 0000_0000 r
|
||||||
|
|
||||||
|
// System Universal Control (SUC)
|
||||||
|
// The system universal control controls the following functions.
|
||||||
|
//<2F> Configuration
|
||||||
|
//<2F> Wakeup
|
||||||
|
//<2F> Startup
|
||||||
|
//<2F> Normal operation
|
||||||
|
//<2F> Passive operation
|
||||||
|
//<2F> Monitor mode
|
||||||
|
SUCC1 = 0x0080,// SUC Configuration Register 1 0C40_1000 r/w
|
||||||
|
SUCC2 = 0x0084,// SUC Configuration Register 2 0100_0504 r/w
|
||||||
|
SUCC3 = 0x0088,// SUC Configuration Register 3 0000_0011 r/w
|
||||||
|
|
||||||
|
// Network Management (NEM)
|
||||||
|
// Sets the handling of the network management vector
|
||||||
|
NEMC = 0x008C,// NEM Configuration Register 0000_0000 r/w
|
||||||
|
|
||||||
|
PRTC1 = 0x0090,// PRT Configuration Register 1 084C_0633 r/w
|
||||||
|
PRTC2 = 0x0094,// PRT Configuration Register 2 0F2D_0A0E r/w
|
||||||
|
MHDC = 0x0098,// MHD Configuration Register 0000_0000 r/w
|
||||||
|
GTUC1 = 0x00A0,// GTU Configuration Register 1 0000_0280 r/w
|
||||||
|
GTUC2 = 0x00A4,// GTU Configuration Register 2 0002_000A r/w
|
||||||
|
GTUC3 = 0x00A8,// GTU Configuration Register 3 0202_0000 r/w
|
||||||
|
GTUC4 = 0x00AC,// GTU Configuration Register 4 0008_0007 r/w
|
||||||
|
GTUC5 = 0x00B0,// GTU Configuration Register 5 0E00_0000 r/w
|
||||||
|
GTUC6 = 0x00B4,// GTU Configuration Register 6 0002_0000 r/w
|
||||||
|
GTUC7 = 0x00B8,// GTU Configuration Register 7 0002_0004 r/w
|
||||||
|
GTUC8 = 0x00BC,// GTU Configuration Register 8 0000_0002 r/w
|
||||||
|
GTUC9 = 0x00C0,// GTU Configuration Register 9 0000_0101 r/w
|
||||||
|
GTUC10 = 0x00C4,// GTU Configuration Register 10 0002_0005 r/w
|
||||||
|
GTUC11 = 0x00C8,// GTU Configuration Register 11 0000_0000 r/w
|
||||||
|
|
||||||
|
CCSV = 0x0100,// CC Status Vector Register 0010_4000 r
|
||||||
|
|
||||||
|
CCEV = 0x0104,// CC Error Vector Register 0000_0000 r
|
||||||
|
// 0x0108 =-0x010C, reserved(2) 0000_0000 r
|
||||||
|
SCV = 0x0110,//Slot Counter Value Register 0000_0000 r
|
||||||
|
MTCCV = 0x0114,//Macrotick and Cycle Counter Value Register 0000_0000 r
|
||||||
|
RCV = 0x0118,//Rate Correction Value Register 0000_0000 r
|
||||||
|
OCV = 0x011C,//Offset Correction Value Register 0000_0000 r
|
||||||
|
SFS = 0x0120,//Sync Frame Status Register 0000_0000 r
|
||||||
|
SWNIT = 0x0124,//Symbol Window and NIT Status Register 0000_0000 r
|
||||||
|
ACS = 0x0128,//Aggregated Channel Status Register 0000_0000 r/w -
|
||||||
|
|
||||||
|
ESID_START = 0x0130,
|
||||||
|
ESID_END = 0x0168,
|
||||||
|
|
||||||
|
OSID_START = 0x0170,
|
||||||
|
OSID_END = 0x01A8,
|
||||||
|
|
||||||
|
NMV1 = 0x01B0,
|
||||||
|
NMV2 = 0x01B4,
|
||||||
|
NMV3 = 0x01B8,
|
||||||
|
|
||||||
|
// Message Buffer Control Registers
|
||||||
|
MRC = 0x0300,// Message RAM Configuration Register 0180_0000 r/w
|
||||||
|
FRF = 0x0304,// FIFO Rejection Filter Register 0180_0000 r/w
|
||||||
|
FRFM = 0x0308,// FIFO Rejection Filter Mask Register 0000_0000 r/w
|
||||||
|
FCL = 0x030C,// FIFO Critical Level Register 0000_0080 r/w
|
||||||
|
|
||||||
|
// Message Buffer Status Registers
|
||||||
|
MHDS = 0x0310,// Message Handler Status Register 0000_0000 r/w
|
||||||
|
LDTS = 0x0314,// Last Dynamic Transmit Slot Register 0000_0000 r
|
||||||
|
FSR = 0x0318,// FIFO Status Register 0000_0000 r
|
||||||
|
MHDF = 0x031C,// Message Handler Constraints Flags Register 0000_0000 r/w
|
||||||
|
TXRQ1 = 0x0320,// Transmission Request Register 1 0000_0000 r
|
||||||
|
TXRQ2 = 0x0324,// Transmission Request Register 2 0000_0000 r
|
||||||
|
TXRQ3 = 0x0328,// Transmission Request Register 3 0000_0000 r
|
||||||
|
TXRQ4 = 0x032C,// Transmission Request Register 4 0000_0000 r
|
||||||
|
NDAT1 = 0x0330,// New Data Register 1 0000_0000 r
|
||||||
|
NDAT2 = 0x0334,// New Data Register 2 0000_0000 r
|
||||||
|
|
||||||
|
WRHS1 = 0x0500,// Write Header Section Register 1
|
||||||
|
WRHS2 = 0x0504,// Write Header Section Register 2
|
||||||
|
WRHS3 = 0x0508,// Write Header Section Register 3
|
||||||
|
|
||||||
|
IBCM = 0x0510,// Input Buffer Command Mask Register
|
||||||
|
IBCR = 0x0514,// Input Buffer Command Request Register
|
||||||
|
|
||||||
|
OBCM = 0x710,
|
||||||
|
OBCR = 0x714,
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace icsneo
|
||||||
|
|
||||||
|
#endif // __ERAYREGISTER_H_
|
||||||
|
|
@ -0,0 +1,38 @@
|
||||||
|
#ifndef __FLEXRAYEXTENSION_H_
|
||||||
|
#define __FLEXRAYEXTENSION_H_
|
||||||
|
|
||||||
|
#include <mutex>
|
||||||
|
#include <memory>
|
||||||
|
#include <utility>
|
||||||
|
#include "icsneo/device/extensions/flexray/erayregister.h"
|
||||||
|
#include "icsneo/communication/message/flexray/control/flexraycontrolmessage.h"
|
||||||
|
#include "icsneo/device/extensions/deviceextension.h"
|
||||||
|
|
||||||
|
namespace icsneo {
|
||||||
|
|
||||||
|
namespace FlexRay {
|
||||||
|
|
||||||
|
class Controller;
|
||||||
|
|
||||||
|
class Extension : public DeviceExtension {
|
||||||
|
public:
|
||||||
|
Extension(Device& device, uint8_t controllerCount);
|
||||||
|
const char* getName() const override { return "FlexRay"; }
|
||||||
|
void handleMessage(const std::shared_ptr<Message>& message) override;
|
||||||
|
|
||||||
|
std::shared_ptr<Controller> getController(uint8_t index) const {
|
||||||
|
if(index >= controllers.size())
|
||||||
|
return nullptr;
|
||||||
|
return controllers[index];
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::vector<std::shared_ptr<Controller>> controllers;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace FlexRay
|
||||||
|
|
||||||
|
} // namespace icsneo
|
||||||
|
|
||||||
|
|
||||||
|
#endif // __FLEXRAYEXTENSION_H_
|
||||||
|
|
@ -0,0 +1,26 @@
|
||||||
|
#ifndef __FLEXRAYOPCODE_H_
|
||||||
|
#define __FLEXRAYOPCODE_H_
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
namespace icsneo {
|
||||||
|
|
||||||
|
namespace FlexRay {
|
||||||
|
|
||||||
|
// Second byte, opcode
|
||||||
|
enum class Opcode : uint8_t {
|
||||||
|
SetNetID = 0x00,
|
||||||
|
ReadCCRegs = 0x01,
|
||||||
|
WriteCCReg = 0x02,
|
||||||
|
WriteMessageBuffer = 0x03,
|
||||||
|
ReadCCStatus = 0x04,
|
||||||
|
AddConfiguredMessage = 0x05,
|
||||||
|
InitForRun = 0x06,
|
||||||
|
Unknown = 0xff
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace FlexRay
|
||||||
|
|
||||||
|
} // namespace icsneo
|
||||||
|
|
||||||
|
#endif // __FLEXRAYOPCODE_H_
|
||||||
|
|
@ -0,0 +1,31 @@
|
||||||
|
#ifndef __FLEXRAYPOCCOMMAND_H_
|
||||||
|
#define __FLEXRAYPOCCOMMAND_H_
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
namespace icsneo {
|
||||||
|
|
||||||
|
namespace FlexRay {
|
||||||
|
|
||||||
|
enum class POCCommand : uint8_t {
|
||||||
|
CommandNotAccepted = 0x00,
|
||||||
|
Config = 0x01,
|
||||||
|
Ready = 0x02,
|
||||||
|
Wakeup = 0x03,
|
||||||
|
Run = 0x04,
|
||||||
|
AllSlots = 0x05,
|
||||||
|
Halt = 0x06,
|
||||||
|
Freeze = 0x07,
|
||||||
|
SendMTS = 0x08,
|
||||||
|
AllowColdstart = 0x09,
|
||||||
|
ResetStatusIndicators = 0x0a,
|
||||||
|
MonitorMode = 0x0b,
|
||||||
|
ClearRAMs = 0x0c,
|
||||||
|
Unknown = 0xff
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace FlexRay
|
||||||
|
|
||||||
|
} // namespace icsneo
|
||||||
|
|
||||||
|
#endif // __FLEXRAYPOCCOMMAND_H_
|
||||||
|
|
@ -0,0 +1,40 @@
|
||||||
|
#ifndef __FLEXRAYPOCSTATUS_H_
|
||||||
|
#define __FLEXRAYPOCSTATUS_H_
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
namespace icsneo {
|
||||||
|
|
||||||
|
namespace FlexRay {
|
||||||
|
|
||||||
|
enum class POCStatus : uint8_t {
|
||||||
|
DefaultConfig = 0x00,
|
||||||
|
Ready = 0x01,
|
||||||
|
NormalActive = 0x02,
|
||||||
|
NormalPassive = 0x03,
|
||||||
|
Halt = 0x04,
|
||||||
|
MonitorMode = 0x05,
|
||||||
|
WakeupStandby = 0x10,
|
||||||
|
WakeupListen = 0x11,
|
||||||
|
WakeupSend = 0x12,
|
||||||
|
WakeupDetect = 0x13,
|
||||||
|
StartupPrepare = 0x20,
|
||||||
|
ColdstartListen = 0x21,
|
||||||
|
ColdstartCollisionResolution = 0x22,
|
||||||
|
ColdstartConsistencyCheck = 0x23,
|
||||||
|
ColdstartGap = 0x24,
|
||||||
|
ColdstartJoin = 0x25,
|
||||||
|
IntegrationColdstartCheck = 0x26,
|
||||||
|
IntegrationListen = 0x27,
|
||||||
|
IntegrationConsistencyCheck = 0x28,
|
||||||
|
InitializeSchedule = 0x29,
|
||||||
|
AbortStartup = 0x2a,
|
||||||
|
StartupSuccess = 0x2b,
|
||||||
|
Unknown = 0xff
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace FlexRay
|
||||||
|
|
||||||
|
} // namespace icsneo
|
||||||
|
|
||||||
|
#endif // __FLEXRAYPOCSTATUS_H_
|
||||||
|
|
@ -0,0 +1,21 @@
|
||||||
|
#ifndef __FLEXRAYSYMBOL_H_
|
||||||
|
#define __FLEXRAYSYMBOL_H_
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
namespace icsneo {
|
||||||
|
|
||||||
|
namespace FlexRay {
|
||||||
|
|
||||||
|
enum class Symbol {
|
||||||
|
None = 0,
|
||||||
|
Unknown,
|
||||||
|
Wakeup,
|
||||||
|
CAS
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace FlexRay
|
||||||
|
|
||||||
|
} // namespace icsneo
|
||||||
|
|
||||||
|
#endif // __FLEXRAYSYMBOL_H_
|
||||||
|
|
@ -1,29 +0,0 @@
|
||||||
#ifndef __PLASION_H_
|
|
||||||
#define __PLASION_H_
|
|
||||||
|
|
||||||
#include "icsneo/device/device.h"
|
|
||||||
#include "icsneo/communication/multichannelcommunication.h"
|
|
||||||
#include "icsneo/platform/ftdi.h"
|
|
||||||
|
|
||||||
namespace icsneo {
|
|
||||||
|
|
||||||
class Plasion : public Device {
|
|
||||||
protected:
|
|
||||||
virtual std::shared_ptr<Communication> makeCommunication(
|
|
||||||
std::unique_ptr<ICommunication> transport,
|
|
||||||
std::shared_ptr<Packetizer> packetizer,
|
|
||||||
std::unique_ptr<Encoder> encoder,
|
|
||||||
std::unique_ptr<Decoder> decoder
|
|
||||||
) override { return std::make_shared<MultiChannelCommunication>(report, std::move(transport), packetizer, std::move(encoder), std::move(decoder)); }
|
|
||||||
|
|
||||||
// TODO: This is done so that Plasion can still transmit it's basic networks, awaiting VLAN support
|
|
||||||
virtual bool isSupportedRXNetwork(const Network&) const override { return true; }
|
|
||||||
virtual bool isSupportedTXNetwork(const Network&) const override { return true; }
|
|
||||||
|
|
||||||
public:
|
|
||||||
Plasion(neodevice_t neodevice) : Device(neodevice) {}
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
#include "icsneo/device/device.h"
|
#include "icsneo/device/device.h"
|
||||||
#include "icsneo/device/devicetype.h"
|
#include "icsneo/device/devicetype.h"
|
||||||
#include "icsneo/platform/ftdi.h"
|
#include "icsneo/platform/ftdi.h"
|
||||||
#include "icsneo/device/neovifire/neovifiresettings.h"
|
#include "icsneo/device/tree/neovifire/neovifiresettings.h"
|
||||||
|
|
||||||
namespace icsneo {
|
namespace icsneo {
|
||||||
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
#ifndef __NEOVIFIRE2ETH_H_
|
#ifndef __NEOVIFIRE2ETH_H_
|
||||||
#define __NEOVIFIRE2ETH_H_
|
#define __NEOVIFIRE2ETH_H_
|
||||||
|
|
||||||
#include "icsneo/device/neovifire2/neovifire2.h"
|
#include "icsneo/device/tree/neovifire2/neovifire2.h"
|
||||||
#include "icsneo/platform/pcap.h"
|
#include "icsneo/platform/pcap.h"
|
||||||
#include "icsneo/device/neovifire2/neovifire2settings.h"
|
#include "icsneo/device/tree/neovifire2/neovifire2settings.h"
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
namespace icsneo {
|
namespace icsneo {
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
#ifndef __NEOVIFIRE2USB_H_
|
#ifndef __NEOVIFIRE2USB_H_
|
||||||
#define __NEOVIFIRE2USB_H_
|
#define __NEOVIFIRE2USB_H_
|
||||||
|
|
||||||
#include "icsneo/device/neovifire2/neovifire2.h"
|
#include "icsneo/device/tree/neovifire2/neovifire2.h"
|
||||||
#include "icsneo/platform/ftdi.h"
|
#include "icsneo/platform/ftdi.h"
|
||||||
#include "icsneo/device/neovifire2/neovifire2settings.h"
|
#include "icsneo/device/tree/neovifire2/neovifire2settings.h"
|
||||||
|
|
||||||
namespace icsneo {
|
namespace icsneo {
|
||||||
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
#ifndef __NEOVIION_H_
|
#ifndef __NEOVIION_H_
|
||||||
#define __NEOVIION_H_
|
#define __NEOVIION_H_
|
||||||
|
|
||||||
#include "icsneo/device/plasion/plasion.h"
|
#include "icsneo/device/tree/plasion/plasion.h"
|
||||||
#include "icsneo/device/devicetype.h"
|
#include "icsneo/device/devicetype.h"
|
||||||
#include "icsneo/platform/ftdi.h"
|
#include "icsneo/platform/ftdi.h"
|
||||||
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
#ifndef __NEOVIPLASMA_H_
|
#ifndef __NEOVIPLASMA_H_
|
||||||
#define __NEOVIPLASMA_H_
|
#define __NEOVIPLASMA_H_
|
||||||
|
|
||||||
#include "icsneo/device/plasion/plasion.h"
|
#include "icsneo/device/tree/plasion/plasion.h"
|
||||||
#include "icsneo/device/devicetype.h"
|
#include "icsneo/device/devicetype.h"
|
||||||
#include "icsneo/platform/ftdi.h"
|
#include "icsneo/platform/ftdi.h"
|
||||||
|
|
||||||
|
|
@ -0,0 +1,91 @@
|
||||||
|
#ifndef __PLASION_H_
|
||||||
|
#define __PLASION_H_
|
||||||
|
|
||||||
|
#include "icsneo/device/device.h"
|
||||||
|
#include "icsneo/communication/multichannelcommunication.h"
|
||||||
|
#include "icsneo/platform/ftdi.h"
|
||||||
|
#include "icsneo/device/extensions/flexray/extension.h"
|
||||||
|
|
||||||
|
namespace icsneo {
|
||||||
|
|
||||||
|
class Plasion : public Device {
|
||||||
|
protected:
|
||||||
|
virtual std::shared_ptr<Communication> makeCommunication(
|
||||||
|
std::unique_ptr<ICommunication> transport,
|
||||||
|
std::shared_ptr<Packetizer> packetizer,
|
||||||
|
std::unique_ptr<Encoder> encoder,
|
||||||
|
std::unique_ptr<Decoder> decoder
|
||||||
|
) override { return std::make_shared<MultiChannelCommunication>(report, std::move(transport), packetizer, std::move(encoder), std::move(decoder)); }
|
||||||
|
|
||||||
|
// TODO: This is done so that Plasion can still transmit it's basic networks, awaiting VLAN support
|
||||||
|
virtual bool isSupportedRXNetwork(const Network&) const override { return true; }
|
||||||
|
virtual bool isSupportedTXNetwork(const Network&) const override { return true; }
|
||||||
|
virtual void setupExtensions() override {
|
||||||
|
addExtension(std::make_shared<FlexRay::Extension>(*this, 2));
|
||||||
|
}
|
||||||
|
|
||||||
|
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::LSFTCAN,
|
||||||
|
Network::NetID::LSFTCAN2,
|
||||||
|
|
||||||
|
Network::NetID::SWCAN,
|
||||||
|
Network::NetID::SWCAN2,
|
||||||
|
|
||||||
|
Network::NetID::Ethernet,
|
||||||
|
|
||||||
|
Network::NetID::LIN,
|
||||||
|
Network::NetID::LIN2,
|
||||||
|
Network::NetID::LIN3,
|
||||||
|
Network::NetID::LIN4,
|
||||||
|
|
||||||
|
Network::NetID::FlexRay,
|
||||||
|
Network::NetID::FlexRay2
|
||||||
|
};
|
||||||
|
return supportedNetworks;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void setupSupportedRXNetworks(std::vector<Network>& rxNetworks) override {
|
||||||
|
for(auto& netid : GetSupportedNetworks())
|
||||||
|
rxNetworks.emplace_back(netid);
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual std::shared_ptr<FlexRay::Controller> getFlexRayControllerByNetwork(const Network& net) const override {
|
||||||
|
uint8_t idx = 0xff;
|
||||||
|
switch(net.getNetID()) {
|
||||||
|
case Network::NetID::FlexRay:
|
||||||
|
idx = 0;
|
||||||
|
break;
|
||||||
|
case Network::NetID::FlexRay2:
|
||||||
|
idx = 1;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return Device::getFlexRayControllerByNetwork(net);
|
||||||
|
}
|
||||||
|
|
||||||
|
auto extension = getExtension<FlexRay::Extension>();
|
||||||
|
if(!extension)
|
||||||
|
return Device::getFlexRayControllerByNetwork(net);
|
||||||
|
|
||||||
|
auto res = extension->getController(idx);
|
||||||
|
if(!res)
|
||||||
|
return Device::getFlexRayControllerByNetwork(net);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
public:
|
||||||
|
Plasion(neodevice_t neodevice) : Device(neodevice) {}
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
#ifndef __RADPLUTOUSB_H_
|
#ifndef __RADPLUTOUSB_H_
|
||||||
#define __RADPLUTOUSB_H_
|
#define __RADPLUTOUSB_H_
|
||||||
|
|
||||||
#include "icsneo/device/radpluto/radpluto.h"
|
#include "icsneo/device/tree/radpluto/radpluto.h"
|
||||||
#include "icsneo/platform/stm32.h"
|
#include "icsneo/platform/stm32.h"
|
||||||
|
|
||||||
namespace icsneo {
|
namespace icsneo {
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
#include "icsneo/device/device.h"
|
#include "icsneo/device/device.h"
|
||||||
#include "icsneo/device/devicetype.h"
|
#include "icsneo/device/devicetype.h"
|
||||||
#include "icsneo/device/radstar2/radstar2settings.h"
|
#include "icsneo/device/tree/radstar2/radstar2settings.h"
|
||||||
|
|
||||||
namespace icsneo {
|
namespace icsneo {
|
||||||
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
#ifndef __RADSTAR2ETH_H_
|
#ifndef __RADSTAR2ETH_H_
|
||||||
#define __RADSTAR2ETH_H_
|
#define __RADSTAR2ETH_H_
|
||||||
|
|
||||||
#include "icsneo/device/radstar2/radstar2.h"
|
#include "icsneo/device/tree/radstar2/radstar2.h"
|
||||||
#include "icsneo/communication/network.h"
|
#include "icsneo/communication/network.h"
|
||||||
#include "icsneo/communication/message/serialnumbermessage.h"
|
#include "icsneo/communication/message/serialnumbermessage.h"
|
||||||
#include "icsneo/platform/pcap.h"
|
#include "icsneo/platform/pcap.h"
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
#ifndef __RADSTAR2USB_H_
|
#ifndef __RADSTAR2USB_H_
|
||||||
#define __RADSTAR2USB_H_
|
#define __RADSTAR2USB_H_
|
||||||
|
|
||||||
#include "icsneo/device/radstar2/radstar2.h"
|
#include "icsneo/device/tree/radstar2/radstar2.h"
|
||||||
#include "icsneo/platform/ftdi.h"
|
#include "icsneo/platform/ftdi.h"
|
||||||
|
|
||||||
namespace icsneo {
|
namespace icsneo {
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
#include "icsneo/device/device.h"
|
#include "icsneo/device/device.h"
|
||||||
#include "icsneo/device/devicetype.h"
|
#include "icsneo/device/devicetype.h"
|
||||||
#include "icsneo/platform/ftdi.h"
|
#include "icsneo/platform/ftdi.h"
|
||||||
#include "icsneo/device/valuecan3/valuecan3settings.h"
|
#include "icsneo/device/tree/valuecan3/valuecan3settings.h"
|
||||||
|
|
||||||
namespace icsneo {
|
namespace icsneo {
|
||||||
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
#define __VALUECAN4_1_2_SETTINGS_H_
|
#define __VALUECAN4_1_2_SETTINGS_H_
|
||||||
|
|
||||||
#include "icsneo/device/idevicesettings.h"
|
#include "icsneo/device/idevicesettings.h"
|
||||||
#include "icsneo/device/valuecan4/settings/valuecan4settings.h"
|
#include "icsneo/device/tree/valuecan4/settings/valuecan4settings.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
#ifndef __VALUECAN4_1_SETTINGS_H_
|
#ifndef __VALUECAN4_1_SETTINGS_H_
|
||||||
#define __VALUECAN4_1_SETTINGS_H_
|
#define __VALUECAN4_1_SETTINGS_H_
|
||||||
|
|
||||||
#include "icsneo/device/valuecan4/settings/valuecan4-1-2settings.h"
|
#include "icsneo/device/tree/valuecan4/settings/valuecan4-1-2settings.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
#define __VALUECAN4_2EL_SETTINGS_H_
|
#define __VALUECAN4_2EL_SETTINGS_H_
|
||||||
|
|
||||||
#include "icsneo/device/idevicesettings.h"
|
#include "icsneo/device/idevicesettings.h"
|
||||||
#include "icsneo/device/valuecan4/settings/valuecan4-4-2elsettings.h"
|
#include "icsneo/device/tree/valuecan4/settings/valuecan4-4-2elsettings.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
#ifndef __VALUECAN4_2_SETTINGS_H_
|
#ifndef __VALUECAN4_2_SETTINGS_H_
|
||||||
#define __VALUECAN4_2_SETTINGS_H_
|
#define __VALUECAN4_2_SETTINGS_H_
|
||||||
|
|
||||||
#include "icsneo/device/valuecan4/settings/valuecan4-1-2settings.h"
|
#include "icsneo/device/tree/valuecan4/settings/valuecan4-1-2settings.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
#define __VALUECAN4_4_2EL_SETTINGS_H_
|
#define __VALUECAN4_4_2EL_SETTINGS_H_
|
||||||
|
|
||||||
#include "icsneo/device/idevicesettings.h"
|
#include "icsneo/device/idevicesettings.h"
|
||||||
#include "icsneo/device/valuecan4/settings/valuecan4settings.h"
|
#include "icsneo/device/tree/valuecan4/settings/valuecan4settings.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
#define __VALUECAN4_4_SETTINGS_H_
|
#define __VALUECAN4_4_SETTINGS_H_
|
||||||
|
|
||||||
#include "icsneo/device/idevicesettings.h"
|
#include "icsneo/device/idevicesettings.h"
|
||||||
#include "icsneo/device/valuecan4/settings/valuecan4-4-2elsettings.h"
|
#include "icsneo/device/tree/valuecan4/settings/valuecan4-4-2elsettings.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
#ifndef __VALUECAN4_1_H_
|
#ifndef __VALUECAN4_1_H_
|
||||||
#define __VALUECAN4_1_H_
|
#define __VALUECAN4_1_H_
|
||||||
|
|
||||||
#include "icsneo/device/valuecan4/valuecan4.h"
|
#include "icsneo/device/tree/valuecan4/valuecan4.h"
|
||||||
#include "icsneo/device/valuecan4/settings/valuecan4-1settings.h"
|
#include "icsneo/device/tree/valuecan4/settings/valuecan4-1settings.h"
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
namespace icsneo {
|
namespace icsneo {
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
#ifndef __VALUECAN4_2_H_
|
#ifndef __VALUECAN4_2_H_
|
||||||
#define __VALUECAN4_2_H_
|
#define __VALUECAN4_2_H_
|
||||||
|
|
||||||
#include "icsneo/device/valuecan4/valuecan4.h"
|
#include "icsneo/device/tree/valuecan4/valuecan4.h"
|
||||||
#include "icsneo/device/valuecan4/settings/valuecan4-2settings.h"
|
#include "icsneo/device/tree/valuecan4/settings/valuecan4-2settings.h"
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
namespace icsneo {
|
namespace icsneo {
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
#ifndef __VALUECAN4_2EL_H_
|
#ifndef __VALUECAN4_2EL_H_
|
||||||
#define __VALUECAN4_2EL_H_
|
#define __VALUECAN4_2EL_H_
|
||||||
|
|
||||||
#include "icsneo/device/valuecan4/valuecan4.h"
|
#include "icsneo/device/tree/valuecan4/valuecan4.h"
|
||||||
#include "icsneo/device/valuecan4/settings/valuecan4-2elsettings.h"
|
#include "icsneo/device/tree/valuecan4/settings/valuecan4-2elsettings.h"
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
namespace icsneo {
|
namespace icsneo {
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
#ifndef __VALUECAN4_4_H_
|
#ifndef __VALUECAN4_4_H_
|
||||||
#define __VALUECAN4_4_H_
|
#define __VALUECAN4_4_H_
|
||||||
|
|
||||||
#include "icsneo/device/valuecan4/valuecan4.h"
|
#include "icsneo/device/tree/valuecan4/valuecan4.h"
|
||||||
#include "icsneo/device/valuecan4/settings/valuecan4-4settings.h"
|
#include "icsneo/device/tree/valuecan4/settings/valuecan4-4settings.h"
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
namespace icsneo {
|
namespace icsneo {
|
||||||
|
|
@ -1,23 +1,23 @@
|
||||||
#ifndef __DEVICES_POSIX_H_
|
#ifndef __DEVICES_POSIX_H_
|
||||||
#define __DEVICES_POSIX_H_
|
#define __DEVICES_POSIX_H_
|
||||||
|
|
||||||
#include "icsneo/device/neoobd2pro/neoobd2pro.h"
|
#include "icsneo/device/tree/neoobd2pro/neoobd2pro.h"
|
||||||
#include "icsneo/device/neoobd2sim/neoobd2sim.h"
|
#include "icsneo/device/tree/neoobd2sim/neoobd2sim.h"
|
||||||
#include "icsneo/device/neovifire/neovifire.h"
|
#include "icsneo/device/tree/neovifire/neovifire.h"
|
||||||
//#include "icsneo/device/neovifire2/neovifire2eth.h"
|
//#include "icsneo/device/tree/neovifire2/neovifire2eth.h"
|
||||||
#include "icsneo/device/neovifire2/neovifire2usb.h"
|
#include "icsneo/device/tree/neovifire2/neovifire2usb.h"
|
||||||
#include "icsneo/device/plasion/neoviion.h"
|
#include "icsneo/device/tree/plasion/neoviion.h"
|
||||||
#include "icsneo/device/plasion/neoviplasma.h"
|
#include "icsneo/device/tree/plasion/neoviplasma.h"
|
||||||
//#include "icsneo/device/radgalaxy/radgalaxy.h"
|
//#include "icsneo/device/tree/radgalaxy/radgalaxy.h"
|
||||||
#include "icsneo/device/radpluto/radplutousb.h"
|
#include "icsneo/device/tree/radpluto/radplutousb.h"
|
||||||
//#include "icsneo/device/radstar2/radstar2eth.h"
|
//#include "icsneo/device/tree/radstar2/radstar2eth.h"
|
||||||
#include "icsneo/device/radstar2/radstar2usb.h"
|
#include "icsneo/device/tree/radstar2/radstar2usb.h"
|
||||||
#include "icsneo/device/radsupermoon/radsupermoon.h"
|
#include "icsneo/device/tree/radsupermoon/radsupermoon.h"
|
||||||
#include "icsneo/device/valuecan3/valuecan3.h"
|
#include "icsneo/device/tree/valuecan3/valuecan3.h"
|
||||||
#include "icsneo/device/valuecan4/valuecan4-1.h"
|
#include "icsneo/device/tree/valuecan4/valuecan4-1.h"
|
||||||
#include "icsneo/device/valuecan4/valuecan4-2.h"
|
#include "icsneo/device/tree/valuecan4/valuecan4-2.h"
|
||||||
#include "icsneo/device/valuecan4/valuecan4-2el.h"
|
#include "icsneo/device/tree/valuecan4/valuecan4-2el.h"
|
||||||
#include "icsneo/device/valuecan4/valuecan4-4.h"
|
#include "icsneo/device/tree/valuecan4/valuecan4-4.h"
|
||||||
#include "icsneo/device/vividcan/vividcan.h"
|
#include "icsneo/device/tree/vividcan/vividcan.h"
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -1,23 +1,23 @@
|
||||||
#ifndef __DEVICES_WINDOWS_H_
|
#ifndef __DEVICES_WINDOWS_H_
|
||||||
#define __DEVICES_WINDOWS_H_
|
#define __DEVICES_WINDOWS_H_
|
||||||
|
|
||||||
#include "icsneo/device/neoobd2pro/neoobd2pro.h"
|
#include "icsneo/device/tree/neoobd2pro/neoobd2pro.h"
|
||||||
#include "icsneo/device/neoobd2sim/neoobd2sim.h"
|
#include "icsneo/device/tree/neoobd2sim/neoobd2sim.h"
|
||||||
#include "icsneo/device/neovifire/neovifire.h"
|
#include "icsneo/device/tree/neovifire/neovifire.h"
|
||||||
#include "icsneo/device/neovifire2/neovifire2eth.h"
|
#include "icsneo/device/tree/neovifire2/neovifire2eth.h"
|
||||||
#include "icsneo/device/neovifire2/neovifire2usb.h"
|
#include "icsneo/device/tree/neovifire2/neovifire2usb.h"
|
||||||
#include "icsneo/device/plasion/neoviion.h"
|
#include "icsneo/device/tree/plasion/neoviion.h"
|
||||||
#include "icsneo/device/plasion/neoviplasma.h"
|
#include "icsneo/device/tree/plasion/neoviplasma.h"
|
||||||
#include "icsneo/device/radgalaxy/radgalaxy.h"
|
#include "icsneo/device/tree/radgalaxy/radgalaxy.h"
|
||||||
#include "icsneo/device/radpluto/radplutousb.h"
|
#include "icsneo/device/tree/radpluto/radplutousb.h"
|
||||||
#include "icsneo/device/radstar2/radstar2eth.h"
|
#include "icsneo/device/tree/radstar2/radstar2eth.h"
|
||||||
#include "icsneo/device/radstar2/radstar2usb.h"
|
#include "icsneo/device/tree/radstar2/radstar2usb.h"
|
||||||
#include "icsneo/device/radsupermoon/radsupermoon.h"
|
#include "icsneo/device/tree/radsupermoon/radsupermoon.h"
|
||||||
#include "icsneo/device/valuecan3/valuecan3.h"
|
#include "icsneo/device/tree/valuecan3/valuecan3.h"
|
||||||
#include "icsneo/device/valuecan4/valuecan4-1.h"
|
#include "icsneo/device/tree/valuecan4/valuecan4-1.h"
|
||||||
#include "icsneo/device/valuecan4/valuecan4-2.h"
|
#include "icsneo/device/tree/valuecan4/valuecan4-2.h"
|
||||||
#include "icsneo/device/valuecan4/valuecan4-2el.h"
|
#include "icsneo/device/tree/valuecan4/valuecan4-2el.h"
|
||||||
#include "icsneo/device/valuecan4/valuecan4-4.h"
|
#include "icsneo/device/tree/valuecan4/valuecan4-4.h"
|
||||||
#include "icsneo/device/vividcan/vividcan.h"
|
#include "icsneo/device/tree/vividcan/vividcan.h"
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
Loading…
Reference in New Issue