no return value subsystem
Up to Project Discussion
I am working on a project where I want to measure the distance of car with a hybrid light barrier. But therefor I need the get function in the subsystem to return values but that doesn't work.
Code:
int DistanceCalibrate() {
int statikardan, passedway, times, timenow;
//time(×);
//time(&timenow);
times = TaskGetTickCount();
timenow = 0;
passedway = 0;
while ((timenow - times) < 20000) {
statikardan = AnalogIn_GetValue(2);
if (statikardan < 400) {
passedway++;
}
timenow = TaskGetTickCount();
AppLed_SetState(0, 1);
Sleep(10);
}
AppLed_SetState(0, 0);
return passedway;
}
static char* RmzOsc_Name = "rmz";
static char * RmzOsc_PropertyNames[] = { "drive", "angle", "measure", 0 }; // must have a trailing 0
int RmzOsc_PropertySet(int property, char* message, int value);
int RmzOsc_PropertyGet(int property);
// Returns the name of the subsystem
const char* RmzOsc_GetName() {
return RmzOsc_Name;
}
// Now getting a message. This is actually a part message, with the first
// part (the subsystem) already parsed off.
int RmzOsc_ReceiveMessage(int channel, char* message, int length) {
int status = Osc_GeneralReceiverHelper(channel, message, length,
RmzOsc_Name, RmzOsc_PropertySet, RmzOsc_PropertyGet,
RmzOsc_PropertyNames);
if (status != CONTROLLER_OK)
return Osc_SendError(channel, RmzOsc_Name, status);
return CONTROLLER_OK;
}
int RmzOsc_PropertyGet(int property) {
int value = 0;
switch (property) {
case 0:
value = DistanceCalibrate();
break;
case 1:
value = 20;
}
return value;
}
If I type the porperty name in mchelper i tested that the function DistanceCalibrate() gets called but i don't get any message back to mchelper, I hope that someone can help me.
ng

