Good morning...
I have a header file containing:
Code:
char r_getPwr[TRANSMIT_SIZE] = {'E','R','_','C','M','D','#','P','?'};char r_getCommSpeed[TRANSMIT_SIZE] = {'E','R','_','C','M','D','#','U','?'};
char r_getChan[TRANSMIT_SIZE] = {'E','R','_','C','M','D','#','C','?'};
char r_getFreq[TRANSMIT_SIZE] = {'E','R','_','C','M','D','#','F','?'};
char r_getVersion[TRANSMIT_SIZE] = {'E','R','_','C','M','D','#','T','3'};
char r_getGrpID[TRANSMIT_SIZE + 1] = {'E','R','_','C','M','D','#','L','7','?'};
char r_ack[3] = {'A','C','K'};
struct s_rf{
char command[10];
boolean ack;
};
void rfTransmit(char* p);
A source c file containing function defn:
Code:
void rfTransmit(char* c){
char i;
for ( i = 0; i < sizeof(c) ; i++) {
UCA1TXBUF = *(c+i);
while (!(UCA1IFG&UCTXIFG));
}
}
And a source c file, main:
Code:
struct s_rf s_LPRS, *pyld;char *cmd;
volatile char *prcv, noRcvChar = 0;
int main(void)
{
WDTCTL = WDTPW | WDTHOLD; // stop watchdog timer
cmd = memcpy(s_LPRS.command, r_getVersion, sizeof(r_getVersion));
s_LPRS.ack = T;
pyld = &s_LPRS;
IOconfig;
initClockTo16MHz();
initUART();
while (1) {
rfTransmit (cmd);
__bis_SR_register(LPM3_bits + GIE); //go to sleep: LPM3
if (noRcvChar == sizeof(s_LPRS.command) && (s_LPRS.ack == T)) {
pyld = memcpy(s_LPRS.command, r_ack, sizeof(r_ack));
}
}
}
After the memcpy statement above in main I would like to know how to have the called function rfTransmit know the size of the cmd array. Can someone please tell me how to pass this into the function? When I do sizeof(c) within the function I get 2. This also confuses me somewhat as my compiler (CCS) recognizes char as 1 byte not 2??
Thanks for all the help