Program does not go into the switch statements at all !

Hsjsjs

Do you guys have any idea why it did not go onto the switch statement?

Do you think you could maybe lean over a bit? You're blocking our view of your serial output.

All of the anonymous values you are printing on each end don't help with understanding.

It appears that you are using the Serial pins to talk to the XBee and to talk to the PC. That really isn't a good idea.

In the if-else-if-else-if in loop in the end device the first two tests are exhaustive so the third arm
can never happen.

PaulS:
It appears that you are using the Serial pins to talk to the XBee and to talk to the PC. That really isn't a good idea.

Actually, i'm trying to use serial communication to communicate with three XBees Sir. Right now I'm focusing on getting just one End device to work first before i moved on to make End device 2 work. I am able to send the value across the end device from the master. I need to get the end device to light up the LED in the Switch case statement as well to have a complete prototype ready to submit.

MarkT:
In the if-else-if-else-if in loop in the end device the first two tests are exhaustive so the third arm
can never happen.

What are the limitations on using if/ Else-if/ Else-if statement then if there's any? Does the problem lies with it not meeting the switch condition value therefore it was unable to execute switch case?

What are the limitations on using if/ Else-if/ Else-if statement then if there's any?

There aren't any. The only thing to be careful of is making sure that all if statements can be reached. Since your first one deals with all characters that are not a comma, and the second one deals with all (remaining) characters that are commas, there is no way for the third if statement to ever be reached. It seems like you want to move the third statement into the else if block that deals with the commas.

It seems odd to me, that when you read your char, and if it isn't a comma you stick it in your array, it seems odd to me that there isn't a " fieldIndex++ ; " immediately after you stick it in the array.

PaulS:
There aren't any. The only thing to be careful of is making sure that all if statements can be reached. Since your first one deals with all characters that are not a comma, and the second one deals with all (remaining) characters that are commas, there is no way for the third if statement to ever be reached. It seems like you want to move the third statement into the else if block that deals with the commas.

Sir, what exactly are the reason why the third arm of my if statement can never be reached? Is there an alternatives to
if/else-if/else-if statement if i want to keep the structure of the code as it is while replacing my if/else-if statement only?

A character is either going to be equal to comma or not. The first and second if statements take care of all possibilities (== and !=) if you just compare to comma, so the last else part never gets executed.

Are you sure you need the last else statement? Should this just be outside the if/else?

BingXuanChng:
Sir, what exactly are the reason why the third arm of my if statement can never be reached? Is there an alternatives to
if/else-if/else-if statement if i want to keep the structure of the code as it is while replacing my if/else-if statement only?

I suspect you have the closing } belonging to else if (ch ==’,’) in the wrong place. It appears before else if (fieldIndex == (No_of_Fields -1)) whereas I think it should actually be after the closing } for else if (fieldIndex == (No_of_Fields -1))

…R