I try to create two function to split string become 2 part , the first function i want to get string "Mode 1", from serial port when RX_IN_CHR_UART
variable, filled data like "Mode 1 34", and the second function i want to get the "34"
this function to get string "Mode 1"
#define GET_MODE_X 6
#define GET_VALUE 4
const char RX_IN_CHR_UART[];
char* pod(char buf_Rx[])
{
int i=0;
char spn[GET_MODE_X]; // 7
for(i=0;i<GET_MODE_X;i++)
{
spn[i] = buf_Rx[i];
}
return Get_mode_x = spn;
}
and this function to get string "34"
char* dop(char buf_Rx_val[])
{
int k=0;
char datasip[GET_VALUE]; //2
for(k=0;k<GET_VALUE;k++)
{
datasip[k] = buf_Rx_val[GET_MODE_X+k+1];
}
return (Get_val_mod = datasip);
}
when i try to compare function dop()
use if(dop(RX_IN_CHR_UART)=="34")
it doesn't works.
if(!strcmp(mode1,pod(RX_IN_CHR_UART))) // compare "Mode 1"
{
Send_teks("Mode 1 ->:"); // send to serial port
Send_teks(pod(RX_IN_CHR_UART));
Send_Char('\n');
Send_teks("Data yang dimasukkan ->:");
Send_teks(dop(RX_IN_CHR_UART));
Send_Char('\n');
if(dop(RX_IN_CHR_UART) == "34") // doesn't work well
{
pwm_off();
LCD_command(0x85);
LCD_sendstring("Kipas off ");
Send_teks("Sukses");
Send_Char('\n');
Send_teks("Kipas Off");
Send_Char('\n');
}
}
what should i do with this function to compare dop() equal to "34" ?