CAN FD transmission on non CAN FD hardware now fails as would be expected
parent
80bccb59a5
commit
0f703f494f
|
|
@ -15,6 +15,9 @@ bool Encoder::encode(std::vector<uint8_t>& result, const std::shared_ptr<Message
|
|||
if(!canmsg)
|
||||
return false; // The message was not a properly formed CANMessage
|
||||
|
||||
if(!supportCANFD && canmsg->isCANFD)
|
||||
return false; // This device does not support CAN FD
|
||||
|
||||
if(canmsg->isCANFD && canmsg->isRemote)
|
||||
return false; // RTR frames can not be used with CAN FD
|
||||
|
||||
|
|
|
|||
|
|
@ -21,7 +21,8 @@ public:
|
|||
bool encode(std::vector<uint8_t>& result, const std::shared_ptr<Message>& message);
|
||||
bool encode(std::vector<uint8_t>& result, Command cmd, bool boolean) { return encode(result, cmd, std::vector<uint8_t>({ (uint8_t)boolean })); }
|
||||
bool encode(std::vector<uint8_t>& result, Command cmd, std::vector<uint8_t> arguments = {});
|
||||
|
||||
|
||||
bool supportCANFD = false;
|
||||
private:
|
||||
std::shared_ptr<Packetizer> packetizer;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -14,6 +14,15 @@ public:
|
|||
NeoVIFIRE2(neodevice_t neodevice) : Device(neodevice) {
|
||||
getWritableNeoDevice().type = DEVICE_TYPE;
|
||||
}
|
||||
|
||||
protected:
|
||||
static std::shared_ptr<Communication> MakeCommunication(std::unique_ptr<ICommunication> transport) {
|
||||
auto packetizer = std::make_shared<Packetizer>();
|
||||
auto encoder = std::unique_ptr<Encoder>(new Encoder(packetizer));
|
||||
encoder->supportCANFD = true;
|
||||
auto decoder = std::unique_ptr<Decoder>(new Decoder());
|
||||
return std::make_shared<Communication>(std::move(transport), packetizer, std::move(encoder), std::move(decoder));
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,11 +12,7 @@ class NeoVIFIRE2ETH : public NeoVIFIRE2 {
|
|||
public:
|
||||
static constexpr const uint16_t PRODUCT_ID = 0x0004;
|
||||
NeoVIFIRE2ETH(neodevice_t neodevice) : NeoVIFIRE2(neodevice) {
|
||||
auto transport = std::unique_ptr<ICommunication>(new PCAP(getWritableNeoDevice()));
|
||||
auto packetizer = std::make_shared<Packetizer>();
|
||||
auto encoder = std::unique_ptr<Encoder>(new Encoder(packetizer));
|
||||
auto decoder = std::unique_ptr<Decoder>(new Decoder());
|
||||
com = std::make_shared<Communication>(std::move(transport), packetizer, std::move(encoder), std::move(decoder));
|
||||
com = MakeCommunicaiton(std::unique_ptr<ICommunication>(new PCAP(getWritableNeoDevice())));
|
||||
settings = std::unique_ptr<IDeviceSettings>(new NeoVIFIRE2Settings(com));
|
||||
settings->readonly = true;
|
||||
productId = PRODUCT_ID;
|
||||
|
|
|
|||
|
|
@ -11,11 +11,7 @@ class NeoVIFIRE2USB : public NeoVIFIRE2 {
|
|||
public:
|
||||
static constexpr const uint16_t PRODUCT_ID = 0x1000;
|
||||
NeoVIFIRE2USB(neodevice_t neodevice) : NeoVIFIRE2(neodevice) {
|
||||
auto transport = std::unique_ptr<ICommunication>(new FTDI(getWritableNeoDevice()));
|
||||
auto packetizer = std::make_shared<Packetizer>();
|
||||
auto encoder = std::unique_ptr<Encoder>(new Encoder(packetizer));
|
||||
auto decoder = std::unique_ptr<Decoder>(new Decoder());
|
||||
com = std::make_shared<Communication>(std::move(transport), packetizer, std::move(encoder), std::move(decoder));
|
||||
com = MakeCommunication(std::unique_ptr<ICommunication>(new FTDI(getWritableNeoDevice())));
|
||||
settings = std::unique_ptr<IDeviceSettings>(new NeoVIFIRE2Settings(com));
|
||||
productId = PRODUCT_ID;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ public:
|
|||
static constexpr DeviceType::Enum DEVICE_TYPE = DeviceType::VCAN4_1;
|
||||
ValueCAN4_1(neodevice_t neodevice) : ValueCAN4(neodevice) {
|
||||
com = MakeCommunication(getWritableNeoDevice());
|
||||
com->encoder->supportCANFD = false; // VCAN 4-1 does not support CAN FD
|
||||
settings = std::unique_ptr<IDeviceSettings>(new ValueCAN4_1Settings(com));
|
||||
getWritableNeoDevice().type = DEVICE_TYPE;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ protected:
|
|||
auto transport = std::unique_ptr<ICommunication>(new STM32(nd));
|
||||
auto packetizer = std::make_shared<Packetizer>();
|
||||
auto encoder = std::unique_ptr<Encoder>(new Encoder(packetizer));
|
||||
encoder->supportCANFD = true;
|
||||
auto decoder = std::unique_ptr<Decoder>(new Decoder());
|
||||
return std::make_shared<Communication>(std::move(transport), packetizer, std::move(encoder), std::move(decoder));
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue