3/26/2018 Gmail - (no subject)
https:
mail.google.com/mail/u/0/?ui=2&ik=3fe50a2bf5&jsver=lr-NdqmOTUs.en.&view=pt&search=inbox&th=16260b9814b0609a&siml=16260b9814b0609a
karthi Manne < XXXXXXXXXX
(no subject)
1 message
mahender reddy < XXXXXXXXXX> Mon, Mar 26, 2018 at 4:13 PM
To: karthi Manne < XXXXXXXXXX
#include
#include
int PSAP_StateMachine(int UpLinkChannel, int Operator, int ManualReset, int Sync, char *TX, int *RunModulator, int *RunDemodulator);
void RecieveFrame(int *FrameDetected, int *CRC_check);
int main()
{
int State;
int UpLinkChannel, Operator, ManualReset, Sync;
char TX[10];
int RunModulator;
int RunDemodulator;
UpLinkChannel = 0;
Operator = 0;
ManualReset = 0;
Sync = 0;
char Option;
while(1)
{
State = PSAP_StateMachine(UpLinkChannel, Operator, ManualReset, Sync, &TX[0], &RunModulator, &RunDemodulator);
if((kbhit()))
{
XXXXXXXXXXprintf("\n \n Which Input you want to Change? u: UpLinkChannel o: Operator m: ManualReset s: Sync x: Exit");
XXXXXXXXXXprintf("\n Please Enter your Option: ");
XXXXXXXXXXgetch();
XXXXXXXXXXOption = getch();
XXXXXXXXXXif(Option=='x')
eak;
XXXXXXXXXXswitch(Option)
{
XXXXXXXXXXcase 'u': printf("\n\nEnter UpLinkChannel: "); scanf("%d", &UpLinkChannel);
eak;
XXXXXXXXXXcase 'o': printf("\n\nEnter Operator: "); scanf("%d", &Operator);
eak;
XXXXXXXXXXcase 'm': printf("\n\nEnter ManualReset: "); scanf("%d", &ManualReset);
eak;
XXXXXXXXXXcase 's': printf("\n\nEnter Sync: "); XXXXXXXXXXscanf("%d", &Sync);
eak;
XXXXXXXXXXdefault: continue;
}
}
}
return 0;
}
int PSAP_StateMachine(int UpLinkChannel, int Operator, int ManualReset, int Sync, char *TX, int *RunModulator, int *RunDemodulator)
{
static int State=1;
static int cnt_NumStartMsg=0;
static int cnt_NumAckMsg =0;
int FrameDetected, CRC_check;
switch(State)
{
case 1:
*RunModulator = 0;
*RunDemodulator = 0;
XXXXXXXXXXstrcpy(TX,"No Processing");
XXXXXXXXXXprintf("\nPsapIdle: State=%d, TX=%s, RunModulator=%d, RunDemodulator=%d\n", State, TX, *RunModulator, *RunDemodulator);
XXXXXXXXXXif(UpLinkChannel==1 || Operator==1)
{
XXXXXXXXXXState = 2;
}
eak;
case 2:
*RunModulator = 0;
*RunDemodulator = 0;
XXXXXXXXXXstrcpy(TX,"Send Start msg");
XXXXXXXXXXprintf("\nPsapIdle: State=%d, TX=%s, RunModulator=%d, RunDemodulator=%d\n", State, TX, *RunModulator, *RunDemodulator);
XXXXXXXXXXcnt_NumStartMsg++;
XXXXXXXXXXif(ManualReset==1)
{
XXXXXXXXXXcnt_NumStartMsg=0;
XXXXXXXXXXState = 1;
}
XXXXXXXXXXelse if(cnt_NumStartMsg==3)
{
XXXXXXXXXXcnt_NumStartMsg=0;
XXXXXXXXXXState=3;
}
eak;
case 3:
*RunModulator = 0;
*RunDemodulator = 0;
XXXXXXXXXXstrcpy(TX,"Send Start msg");
XXXXXXXXXXprintf("\nPsapStart: State=%d, TX=%s, RunModulator=%d, RunDemodulator=%d\n", State, TX, *RunModulator, *RunDemodulator);
XXXXXXXXXXif(ManualReset==1)
{
XXXXXXXXXXState = 1;
}
XXXXXXXXXXelse if(Sync==1)
{
*RunModulator = 1;
XXXXXXXXXXState=4;
}
eak;
case 4:
*RunModulator = 1;
*RunDemodulator = 0;
XXXXXXXXXXstrcpy(TX,"Send Nack msg");
XXXXXXXXXXprintf("\nPsapNack: State=%d, TX=%s, RunModulator=%d, RunDemodulator=%d\n", State, TX, *RunModulator, *RunDemodulator);
XXXXXXXXXXRecieveFrame(&FrameDetected, &CRC_check);
XXXXXXXXXXif(ManualReset==1)
{
XXXXXXXXXXState = 1;
}
XXXXXXXXXXelse if(CRC_check==0)
{
XXXXXXXXXXState = 2;
}
XXXXXXXXXXelse if(CRC_check==1)
{
*RunModulator = 0;
*RunDemodulator = 1;
XXXXXXXXXXState = 5;
}
eak;
case 5:
*RunModulator = 0;
*RunDemodulator = 1;
XXXXXXXXXXstrcpy(TX,"Send Ack msg");
XXXXXXXXXXprintf("\nPsapNack: State=%d, TX=%s, RunModulator=%d, RunDemodulator=%d\n", State, TX, *RunModulator, *RunDemodulator);
XXXXXXXXXXcnt_NumAckMsg++;
XXXXXXXXXXif(cnt_NumAckMsg>=4)
{
XXXXXXXXXXcnt_NumAckMsg = 0;
XXXXXXXXXXState = 1;
}
eak;
default:
State=1;
eak;
}
return State;
}
void RecieveFrame(int *FrameDetected, int *CRC_check)
{
*FrameDetected=1;
*CRC_check = 1;
}