mirror of
https://github.com/intrepidcs/libicsneo.git
synced 2026-08-05 01:18:36 +02:00
All: Update network names
Updates all network names, the new format is <id>_<%02d>.
This commit is contained in:
@@ -37,39 +37,39 @@ int main() {
|
||||
}
|
||||
std::cout << "OK" << std::endl;
|
||||
|
||||
std::cout << "\tGetting HSCAN Baudrate... ";
|
||||
int64_t baud = device->settings->getBaudrateFor(icsneo::Network::NetID::HSCAN);
|
||||
std::cout << "\tGetting DW CAN 01 Baudrate... ";
|
||||
int64_t baud = device->settings->getBaudrateFor(icsneo::Network::NetID::DWCAN_01);
|
||||
if(baud < 0)
|
||||
std::cout << "FAIL" << std::endl;
|
||||
else
|
||||
std::cout << "OK, " << (baud/1000) << "kbit/s" << std::endl;
|
||||
|
||||
std::cout << "\tSetting HSCAN to operate at 125kbit/s... ";
|
||||
ret = device->settings->setBaudrateFor(icsneo::Network::NetID::HSCAN, 125000);
|
||||
std::cout << "\tSetting DW CAN 01 to operate at 125kbit/s... ";
|
||||
ret = device->settings->setBaudrateFor(icsneo::Network::NetID::DWCAN_01, 125000);
|
||||
std::cout << (ret ? "OK" : "FAIL") << std::endl;
|
||||
|
||||
// Changes to the settings do not take affect until you call settings->apply()!
|
||||
// When you get the baudrate here, you're reading what the device is currently operating on
|
||||
std::cout << "\tGetting HSCAN Baudrate... (expected to be unchanged) ";
|
||||
baud = device->settings->getBaudrateFor(icsneo::Network::NetID::HSCAN);
|
||||
std::cout << "\tGetting DW CAN 01 Baudrate... (expected to be unchanged) ";
|
||||
baud = device->settings->getBaudrateFor(icsneo::Network::NetID::DWCAN_01);
|
||||
if(baud < 0)
|
||||
std::cout << "FAIL" << std::endl;
|
||||
else
|
||||
std::cout << "OK, " << (baud/1000) << "kbit/s" << std::endl;
|
||||
|
||||
std::cout << "\tGetting HSCANFD Baudrate... ";
|
||||
baud = device->settings->getFDBaudrateFor(icsneo::Network::NetID::HSCAN);
|
||||
std::cout << "\tGetting DW CAN 01 FD Baudrate... ";
|
||||
baud = device->settings->getFDBaudrateFor(icsneo::Network::NetID::DWCAN_01);
|
||||
if(baud < 0)
|
||||
std::cout << "FAIL" << std::endl;
|
||||
else
|
||||
std::cout << "OK, " << (baud/1000) << "kbit/s" << std::endl;
|
||||
|
||||
std::cout << "\tSetting HSCANFD to operate at 8Mbit/s... ";
|
||||
ret = device->settings->setFDBaudrateFor(icsneo::Network::NetID::HSCAN, 8000000);
|
||||
std::cout << "\tSetting DW CAN 01 FD to operate at 8Mbit/s... ";
|
||||
ret = device->settings->setFDBaudrateFor(icsneo::Network::NetID::DWCAN_01, 8000000);
|
||||
std::cout << (ret ? "OK" : "FAIL") << std::endl;
|
||||
|
||||
std::cout << "\tGetting HSCANFD Baudrate... (expected to be unchanged) ";
|
||||
baud = device->settings->getFDBaudrateFor(icsneo::Network::NetID::HSCAN);
|
||||
std::cout << "\tGetting DW CAN 01 FD Baudrate... (expected to be unchanged) ";
|
||||
baud = device->settings->getFDBaudrateFor(icsneo::Network::NetID::DWCAN_01);
|
||||
if(baud < 0)
|
||||
std::cout << "FAIL" << std::endl;
|
||||
else
|
||||
@@ -83,15 +83,15 @@ int main() {
|
||||
std::cout << (ret ? "OK" : "FAIL") << std::endl;
|
||||
|
||||
// Now that we have applied, we expect that our operating baudrates have changed
|
||||
std::cout << "\tGetting HSCAN Baudrate... ";
|
||||
baud = device->settings->getBaudrateFor(icsneo::Network::NetID::HSCAN);
|
||||
std::cout << "\tGetting DW CAN 01 Baudrate... ";
|
||||
baud = device->settings->getBaudrateFor(icsneo::Network::NetID::DWCAN_01);
|
||||
if(baud < 0)
|
||||
std::cout << "FAIL" << std::endl;
|
||||
else
|
||||
std::cout << "OK, " << (baud/1000) << "kbit/s" << std::endl;
|
||||
|
||||
std::cout << "\tGetting HSCANFD Baudrate... ";
|
||||
baud = device->settings->getFDBaudrateFor(icsneo::Network::NetID::HSCAN);
|
||||
std::cout << "\tGetting DW CAN 01 (FD) Baudrate... ";
|
||||
baud = device->settings->getFDBaudrateFor(icsneo::Network::NetID::DWCAN_01);
|
||||
if(baud < 0)
|
||||
std::cout << "FAIL" << std::endl;
|
||||
else
|
||||
@@ -155,13 +155,13 @@ int main() {
|
||||
// We can transmit messages
|
||||
std::cout << "\n\tTransmitting an extended CAN FD frame... ";
|
||||
auto txMessage5 = std::make_shared<icsneo::CANMessage>();
|
||||
txMessage5->network = icsneo::Network::NetID::HSCAN;
|
||||
txMessage5->network = icsneo::Network::NetID::DWCAN_01;
|
||||
txMessage5->arbid = 0x1C5001C5;
|
||||
txMessage5->data.insert(txMessage5->data.end(), {0xaa, 0xbb, 0xcc});
|
||||
// The DLC will come from the length of the data vector
|
||||
txMessage5->isExtended = true;
|
||||
txMessage5->isCANFD = true;
|
||||
ret = device->transmit(txMessage5); // This will return false if the device does not support CAN FD, or does not have HSCAN
|
||||
ret = device->transmit(txMessage5); // This will return false if the device does not support CAN FD, or does not have DWCAN_01
|
||||
std::cout << (ret ? "OK" : "FAIL") << std::endl;
|
||||
|
||||
// We can also register a handler
|
||||
@@ -290,25 +290,25 @@ int main() {
|
||||
// We can transmit messages
|
||||
std::cout << "\tTransmitting an extended CAN FD frame... ";
|
||||
auto txMessage = std::make_shared<icsneo::CANMessage>();
|
||||
txMessage->network = icsneo::Network::NetID::HSCAN;
|
||||
txMessage->network = icsneo::Network::NetID::DWCAN_01;
|
||||
txMessage->arbid = 0x1C5001C5;
|
||||
txMessage->data.insert(txMessage->data.end(), {0xaa, 0xbb, 0xcc});
|
||||
// The DLC will come from the length of the data vector
|
||||
txMessage->isExtended = true;
|
||||
txMessage->isCANFD = true;
|
||||
ret = device->transmit(txMessage); // This will return false if the device does not support CAN FD, or does not have HSCAN
|
||||
ret = device->transmit(txMessage); // This will return false if the device does not support CAN FD, or does not have DWCAN_01
|
||||
std::cout << (ret ? "OK" : "FAIL") << std::endl;
|
||||
|
||||
std::cout << "\tTransmitting an ethernet frame on OP (BR) Ethernet 2... ";
|
||||
std::cout << "\tTransmitting an ethernet frame on AE 02... ";
|
||||
auto ethTxMessage = std::make_shared<icsneo::EthernetMessage>();
|
||||
ethTxMessage->network = icsneo::Network::NetID::OP_Ethernet2;
|
||||
ethTxMessage->network = icsneo::Network::NetID::AE_02;
|
||||
ethTxMessage->data.insert(ethTxMessage->data.end(), {
|
||||
0x00, 0xFC, 0x70, 0x00, 0x01, 0x02, /* Destination MAC */
|
||||
0x00, 0xFC, 0x70, 0x00, 0x01, 0x01, /* Source MAC */
|
||||
0x00, 0x00, /* Ether Type */
|
||||
0x01, 0xC5, 0x01, 0xC5 /* Payload (will automatically be padded on transmit unless you set `ethTxMessage->noPadding`) */
|
||||
});
|
||||
ret = device->transmit(ethTxMessage); // This will return false if the device does not support OP (BR) Ethernet 2
|
||||
ret = device->transmit(ethTxMessage); // This will return false if the device does not support AE 02
|
||||
std::cout << (ret ? "OK" : "FAIL") << std::endl;
|
||||
|
||||
std::vector<icsneo::MiscIO> emisc = device->getEMiscIO();
|
||||
|
||||
Reference in New Issue
Block a user