int main(void) {
txrx data;
modules mods;
int sa = 0;
int da = 0;
int status = 0;
int function = 0;
sa = 50; // sensor address
da = 100; // actuator address
mods.sensor(status,function);
data.send_packet(sa, da, status, function);
data.rec_packet();
mods.actuator();
return 0;
}
int modules::sensor(int status, int function) {
int sensor;
cout << "Sensor: 0=NULL, 1=motion, 2=vehicle" << "\n";
cin >> sensor;
if (sensor == 0){
status = 9;
function = 9;
}
elseif (sensor == 1) {
status = 1;
function = 200;
}
else {
status = 1;
function = 128;
}
return(status,function);
}
I expected 'mods.sensor(status,function);' to return the status and function variables. I then expected these to be picked up by 'data.send_packet(sa, da, status, function);' however they are not.
I know the answer is probably really simple however after searching the internet and looking through my book I cannot find out why 'data.send_packet(sa, da, status, function);' is not picking up on the status and function variables returned by 'mods.sensor(status,function);'.
You sir are a true gentleman! Thank you very much for helping me understand my problem.
You would think that a function could return two values in the way I was trying to. I can not see any problems it could cause however I'm still a beginner in C++ and I'm sure the original developers thought about the consequences of doing so.