Hi,
I've been programming for a bit and STILL have troubles with my pointers. I have a piece of code I am editing and wish to keep conformance with how all other functions are formatted. Unfortunately, this means I need to pass an array through 3 functions before it gets written out the serial port. Somewhere I'm losing the contents of the array and using an address and am trying to figure out where and how to fix it. And yes, using the serial output function directly works but I can't do that in the actual code.
I have 3 classes, actuator, thruster, and serial.
This is called over and over in an actuator class function:
allThrusters->SendCommand(SerOut1, 4);
allThrusters is a thruster class object.
SerOut1 being
float SerOut1[4]={0,0,0,0};
and:
int SendCommand(void *command, int length);
Inside SendCommand:
1 2 3 4 5 6
|
nt thruster::SendCommand(void *command, int length)
{
int nwrote;
nwrote = myserial->WriteSerial(command, length);
return nwrote;
}
|
myserial is a serial class object.
where:
int WriteSerial(void* buff, int length);
The send is successfull if I do:
1 2 3 4 5 6 7 8
|
int thruster::SendCommand(void *command, int length)
{
int nwrote;
char test[]="Hello world!\n";
nwrote = myserial->WriteSerial(test,13);
//nwrote = myserial->WriteSerial(command, length);
return nwrote;
}
|
I get Hello World! out of the serial port. So Im doing something wrong with passing the array through the pointers. Can anyone help me out? The array going into the original function (SerOut1) is fine and has the values I am expecting in it (viewed with a printf).
Thanks!