So 11 hours in the lab, with mostly little to no progress finally culminated in a fully functional system.
Our system is basically a series a small microcontrollers with various devices attached to them, these devices communicated with our central PC by way of RS232 communication. In order to call specpfic funcitons on the PIC we basically just pass it a function address through the serial link, and the PIC jams it into a function pointer, and calls the function. It’s pretty neat, but…
What is strange is when we were setting this up, we ran into issues with the function pointers. Now UNB has decided that there is no purpose to me learning C, but here is what we did, and what we had to do to solve the problem.
Our first attempt.
int getFunctionAAsPointerAddress(){
void (*resultPtr)(int); // function ptr
result = &functionA;
return result;
}
int getFunctionBAsPointerAddress(){
void (*resultPtr)(int); // function ptr
result = &functionB;
return result;
}
This for some reason unknown to me doesn’t compile on the PIC… C you’ve done it to me again.
This how ever solves the problem…
int getFunctionAAsPointerAddress(){
void (*resultPtr)(int); // function ptr
result = &functionA;
return result;
}
int getFunctionBAsPointerAddress(){
void (*resultPtr1)(int); // function ptr
result1 = &functionB;
return result1;
}
So this flies in the face of everything I know about programming, function variables should disappear once you have returned them… At least the names should anyway.
If anyone knows why this works the way it does and feels like letting me know… please do.
I’ve decided I might take a C course next year, even just as a bird course so I can learn this stuff properly.
Good saturday to you all.
.joe





