Skip to content

Commit

Permalink
broadcastStepperSteps command
Browse files Browse the repository at this point in the history
  • Loading branch information
pkubanek committed Jun 5, 2024
1 parent e4995d2 commit 84cb523
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 10 deletions.
7 changes: 5 additions & 2 deletions include/ILC/ILCBusList.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,13 @@ class ILCBusList : public Modbus::BusList {
* in unicast function to verify the broadcast was received and processed
* @param data function parameters. Usually device's bus ID indexed array
*/
void broadcastFunction(uint8_t address, uint8_t func, uint32_t delay);
void broadcastFunction(uint8_t address, uint8_t func, uint32_t delay, uint8_t counter);

template<typename data_type>
void broadcastFunction(uint8_t address, uint8_t func, uint32_t delay, uint8_t counter,
std::vector<uint8_t> data);
std::vector<data_type> data) {
callFunction(address, func, delay, counter, data);
}

/**
* Return next bus broadcast counter.
Expand Down
5 changes: 5 additions & 0 deletions include/Modbus/Buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,11 @@ inline void Buffer::write(std::vector<uint8_t> data) {
writeVector<uint8_t>(data);
}

template <>
inline void Buffer::write(std::vector<int8_t> data) {
writeVector<int8_t>(data);
}

template <>
inline void Buffer::write(std::vector<uint16_t> data) {
writeVector<uint16_t>(data);
Expand Down
9 changes: 8 additions & 1 deletion include/cRIO/ElectromechanicalPneumaticILC.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ class ElectromechanicalPneumaticILC : public virtual ILC::ILCBusList {
REPORT_HARDPOINT_LVDT = 122
};


static constexpr uint8_t EA_BROADCAST = 248;

/**
* Unicast command to command stepper motor moves.
*
Expand All @@ -87,6 +90,10 @@ class ElectromechanicalPneumaticILC : public virtual ILC::ILCBusList {
callFunction(address, ILC_EM_CMD::SET_STEPPER_STEPS, 1800, steps);
}

void broadcastStepperSteps(uint8_t counter, std::vector<int8_t> steps) {
broadcastFunction(EA_BROADCAST, ILC_EM_CMD::SET_STEPPER_STEPS, 1800, counter, steps);
}

/**
* Unicast Stepper motor @glos{ILC} Force [N] and Status Request. @glos{ILC} command
* code 67 (0x43). Applies for M2 tangent and axials controllers, as well
Expand Down Expand Up @@ -170,7 +177,7 @@ class ElectromechanicalPneumaticILC : public virtual ILC::ILCBusList {
callFunction(address, ILC_EM_CMD::REPORT_FA_FORCE_STATUS, 1800);
}

void freezeSensor() {broadcastFunction(248, ILC_EM_CMD::FREEZE_SENSOR, 180); }
void freezeSensor(uint8_t counter) {broadcastFunction(EA_BROADCAST, ILC_EM_CMD::FREEZE_SENSOR, 180, counter); }

/**
* Unicast ADC Channel Offset and Sensitivity. @glos{ILC} command code 81 (0x51).
Expand Down
9 changes: 2 additions & 7 deletions src/ILC/ILCBusList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,8 @@ ILCBusList::ILCBusList(uint8_t bus) : _bus(bus) {

ILCBusList::~ILCBusList() {}

void ILCBusList::broadcastFunction(uint8_t address, uint8_t func, uint32_t delay) {
callFunction(address, func, delay);
}

void ILCBusList::broadcastFunction(uint8_t address, uint8_t func, uint32_t delay, uint8_t counter,
std::vector<uint8_t> data) {
callFunction(address, func, delay, counter, data);
void ILCBusList::broadcastFunction(uint8_t address, uint8_t func, uint32_t delay, uint8_t counter) {
callFunction(address, func, delay, counter);
}

uint8_t ILCBusList::nextBroadcastCounter() {
Expand Down

0 comments on commit 84cb523

Please sign in to comment.