Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed-STM32F103C8T6 mbed libuavcan
main.cpp
- Committer:
- RuslanUrya
- Date:
- 2018-05-10
- Revision:
- 4:05f811770392
- Parent:
- 3:44c673ad1b8d
- Child:
- 5:f59c880d75c6
File content as of revision 4:05f811770392:
#include "mbed.h"
#//include <libuavcan/libuavcan/include.mk> //core
//#include <libuavcan/libuavcan_drivers/stm32/driver/include.mk> //stm32 driver
//#include <libuavcan/libuavcan/dsdl_compiler/setup.py> //run dsdl compiler?
#include "chip.h" //build configuration
#include "libuavcan/libuavcan/include/uavcan/build_config.hpp" //All default configuration options
#include "libuavcan/libuavcan_drivers/stm32/driver/include/uavcan_stm32/build_config.hpp" //OS detection; Any General-Purpose timer
#include "libuavcan/libuavcan/include/uavcan/node/publisher.hpp" //Publisher class
#include <uavcan/equipment/actuator/Command.hpp> //message type
extern uavcan::ICanDriver& getCanDriver();
extern uavcan::ISystemClock& getSystemClock();
const unsigned NodeMemoryPoolSize = 16384; // Need calulate (tutorial 2).
typedef uavcan::Node<NodeMemoryPoolSize> Node;
static Node& getNode() {
static Node node(getCanDriver(), getSystemClock());
return node;
}
int main() {
auto& node = getNode();
node.setName("Actuator");
if (node.start() > 0){ //<>?
//обработка ошибок запуска
}
uavcan::Publisher <uavcan::equipment::actuator::Command> pub(node); //define node to publisher
if (pub.init() > 0) { //инициализация паблишера
//обработка ошибок
}
node.setMoreOptional();
while(1) {
if (node.spin(uavcan::MonotonicDuration::fromMSec(1000)) < 1){
//обработка ошибок
}
uavcan::equipment::actuator::Command msg; //что вместо uavcan::protocol::debug::KeyValue?
msg.actuator_id = 1;
msg.command_type = COMMAND_TYPE_UNITLESS //[-1, 1]
msg.command_value = 1;
if (pub.broadcast(msg) > 0){ // отправка сообщения
// обработка ошибок
}
}
}