Merge branch 'feature/e-endstop' into merge-abc-with-homing
[clinton/Smoothieware.git] / src / libs / PublicData.cpp
CommitLineData
8293d443
JM
1#include "libs/Kernel.h"
2#include "PublicData.h"
3#include "PublicDataRequest.h"
4
3bfb2639 5bool PublicData::get_value(uint16_t csa, uint16_t csb, uint16_t csc, void *data) {
b19aa09d 6 PublicDataRequest pdr(csa, csb, csc);
564cf1f0
JM
7 // the caller may have created the storage for the returned data so we clear the flag,
8 // if it gets set by the callee setting the data ptr that means the data is a pointer to a pointer and is set to a pointer to the returned data
9 pdr.set_data_ptr(data, false);
314ab8f7 10 THEKERNEL->call_event(ON_GET_PUBLIC_DATA, &pdr );
42fcc651 11 if(pdr.is_taken() && pdr.has_returned_data()) {
3bfb2639
JM
12 // the callee set the returned data pointer
13 *(void**)data= pdr.get_data_ptr();
14 }
b19aa09d 15 return pdr.is_taken();
8293d443
JM
16}
17
47339e4a 18bool PublicData::set_value(uint16_t csa, uint16_t csb, uint16_t csc, void *data) {
b19aa09d
JM
19 PublicDataRequest pdr(csa, csb, csc);
20 pdr.set_data_ptr(data);
314ab8f7 21 THEKERNEL->call_event(ON_SET_PUBLIC_DATA, &pdr );
b19aa09d 22 return pdr.is_taken();
8293d443 23}