📄 birdcmds.c
字号:
examinevaluerspsize[19] = 7;
examinevaluerspsize[20] = 30;
examinevaluerspsize[22] = 30;
examinevaluerspsize[23] = 7;
}
}
/*
Store the command parameter number
*/
birdexaminevaluecmd[1] = (unsigned char) examinevalueparanumber[answer];
/*
Send the command to the Bird
*/
if (send_serial_cmd(birdexaminevaluecmd,2) !=2)
return(FALSE);
/*
Get the n byte response
*/
for (i=0; i< examinevaluerspsize[answer] ; i++)
{
rxchar = waitforchar();
parameter[i] = (unsigned char) rxchar;
if (rxchar < 0)
{
printf("** ERROR ** could not read data back from the Bird\n\r");
hitkeycontinue();
return(FALSE);
}
}
/*
Decode the information retrieved
*/
switch (answer)
{
case 1: /* System Status */
/*
check Master/Slave bird .. bit 15
*/
if ( ((unsigned char) parameter[1]) & 0x80 )
printf("Bird is Master\n\r");
else
printf("Bird is Slave\n\r");
/*
check bird initialization status .. bit 14
*/
if ( ((unsigned char) parameter[1]) & 0x40 )
printf("Bird has been initialized\n\r");
else
printf("Bird has not been initialized\n\r");
/*
check if an error has been detected .. bit 13
*/
if ( ((unsigned char) parameter[1]) & 0x20 )
printf("An error has been detected\n\r");
else
printf("No error detected\n\r");
/*
check if bird is NOT RUNNING / RUNNING .. bit 12
*/
if ( ((unsigned char) parameter[1]) & 0x10 )
printf("Bird is NOT RUNNING\n\r");
else
printf("Bird is RUNNING\n\r");
/*
check if bird is in HOST SYNC .. bit 11
*/
if ( ((unsigned char) parameter[1]) & 0x08 )
printf("Bird is in HOST SYNC\n\r");
else
printf("Bird is not in HOST SYNC\n\r");
/*
Print Expanded Addressing or Expanded .. bit 10
*/
if ( ((unsigned char) parameter[1]) & 0x04 )
printf("Bird in Expanded Addressing Mode\n\r");
else
printf("Bird in Normal Addressing Mode\n\r");
/*
check if in CRTSYNC mode .. bit 9
*/
if ( ((unsigned char) parameter[1]) & 0x02 )
printf("Bird in CRTSYNC Mode\n\r");
else
printf("Bird not in CRTSYNC Mode\n\r");
/*
check if sync modes enabled .. bit 8
*/
if ( ((unsigned char) parameter[1]) & 0x01 )
printf("SYNC mode not enabled\n\r");
else
printf("SYNC mode enabled\n\r");
/*
check factory test mode ..bit 7
*/
printf ("Factory Test Commands: ");
if (((unsigned char) parameter[0]) & 0x80)
printf("ENABLED\n\r");
else
printf("DISABLED\n\r");
/*
check XOFF/XON ..bit 6
*/
if (((unsigned char) parameter[0]) & 0x80)
printf("XOFF\n\r");
else
printf("XON\n\r");
/*
check sleep/wake ..bit 5
*/
if (((unsigned char) parameter[0]) & 0x20)
printf("Bird in Sleep Mode\n\r");
else
printf("Bird in Wake Up Mode\n\r");
/*
check output selection ..bits 4,3,2,1
*/
switch (((unsigned char) parameter[0] & 0x1e) >> 1)
{
case 1:
printf ("Position output selected ");
break;
case 2:
printf ("Angle output selected ");
break;
case 3:
printf ("Matrix output selected ");
break;
case 4:
printf ("Position/Angle output selected ");
break;
case 5:
printf ("Position/Matrix output selected ");
break;
case 6:
printf ("Factory Test output selected ");
break;
case 7:
printf ("Quaternion output selected ");
break;
case 8:
printf ("Position/Quaternion output selected ");
break;
default:
printf ("Illegal Output mode detected\n\r");
hitkeycontinue();
return(FALSE);
}
/*
check outputmode .. bit 0
*/
if (((unsigned char) parameter[0]) & 0x1)
printf("in STREAM mode\n\r");
else
printf("in POINT mode\n\r");
break;
case 2: /* Software Rev */
printf ("Software REV %d.%d\n\r",parameter[0],parameter[1]);
break;
case 3: /* CPU Crystal */
/*
Store the Value in the Global
*/
crystalfreq = parameter[0];
printf ("CPU Crystal is %4.1f MHz\n\r",crystalfreq);
break;
case 4: /* Maximum Range */
printf ("Maximum Range is ");
if (parameter[0] == 1)
printf ("72 inches\n\r");
else
printf ("36 inches\n\r");
break;
case 5: /* Filter Status */
printf ("AC Narrow Notch filter is: ");
if (parameter[0] & 4)
printf ("OFF\n\r");
else
printf ("ON\n\r");
printf ("AC Wide Notch filter is: ");
if (parameter[0] & 2)
printf ("OFF\n\r");
else
printf ("ON\n\r");
printf ("DC filter is: ");
if (parameter[0] & 1)
printf ("OFF\n\r");
else
printf ("ON\n\r");
break;
case 6: /* Filter Constant Table - Alpha Min */
for (i=0; i<7; i++)
{
printf ("For the range %s, Filter constant is %6.4f\n\r",
dcfiltermsg[i],
(float)(((*(unsigned char *)¶meter[(i*2)]) +
((*(unsigned char *)¶meter[(i*2+1)]) << 8))
* WTF));
}
break;
case 7: /* Measurement Rate */
/*
Display the Rate
*/
if (!getcrystalfreq())
return(FALSE);
i = ((*(unsigned char *)¶meter[0]) & 0xff)
+ (((*(unsigned char *)¶meter[1]) & 0xff) << 8) ;
measurementrate =
1000.0/((4*(i*(8.0/crystalfreq)/1000.0))+ 0.3);
printf ("Measurement Rate: %6.2f\n\r",measurementrate);
/*
Display the Transmitter Counts
*/
printf("Transmitter Time Counts: %u\n\r",i);
break;
case 8: /* Disable/Enable Data Ready Output */
printf ("\n\rData Ready Output is ");
if (parameter[0] == TRUE)
printf("ENABLED");
else
printf("DISABLED");
break;
case 9: /* Change Data Ready Character */
printf ("\n\rData Ready Output Character is %u (decimal), <%c> (ASCII)",(unsigned char) parameter[0],(char) parameter[0]);
break;
case 10: /* Error Code */
displayerror(parameter[0],parameter[1],FALSE);
break;
case 11: /* ON ERROR Mask */
switch(parameter[0] & 0x3)
{
case 0: /* FATAL errors are Blinked Forever */
printf ("\n\rFATAL Errors are Blinked Forever and Operation is Halted\n\r");
break;
case 1: /* FATAL errors are Blinked Once */
printf ("\n\rFATAL Errors are Blinked Once and Operation is Resumed \n\r");
break;
case 2: /* FATAL errors are Not Blinked */
printf ("\n\rFATAL Errors are Not Blinked and Operation is Halted\n\r");
break;
case 3: /* FATAL errors are Not Blinked Forever */
printf ("\n\rFATAL Errors are Not Blinked and Operation Continues\n\r");
break;
}
break;
case 12: /* DC Filter Constant Table */
/*
Display the DC Filter Table
*/
for (i=0;i<7;i++)
{
printf ("\n\rFor the range %s, current value is %u (decimal)\n\r",
dcfiltermsg[i],
(unsigned short)((*(unsigned char *)¶meter[i*2]) +
((*(unsigned char *)¶meter[i*2+1]) << 8)));
}
break;
case 13: /* Filter Constant Table - Alpha Max */
for (i=0; i<7; i++)
{
printf ("For the range %s, Filter constant is %6.4f\n\r",
dcfiltermsg[i],
(float)(((*(unsigned char *)¶meter[i*2]) +
((*(unsigned char *)¶meter[i*2+1]) << 8))
* WTF));
}
break;
case 14: /* Glitch Checking */
if (parameter[0] == TRUE)
printf("Sudden Changes are not output");
else
printf("Sudden Changes are output");
break;
case 15: /* Model */
parameter[10] = 0; /* set the string termination */
printf ("\n\rModel is: %s",¶meter[0]);
break;
case 16: /* Expanded Error Code */
displayerror(parameter[0],parameter[1],TRUE);
break;
case 17: /* XYZ Reference Frame */
if (parameter[0] == TRUE)
printf("XYZ Reference Frame defined");
else
printf("XYZ Reference Frame Not defined");
break;
case 18: /* FBB Host Delay */
printf("\n\rFBB Host Response Delay is %d microseconds",
(unsigned short)(((*(unsigned char *) ¶meter[0]) +
((*(unsigned char *) ¶meter[1]) << 8))) * 10);
break;
case 19: /* FBB Configuration */
showfbbconfig(¶meter[0]);
break;
case 20: /* FBB ARMed */
case 22: /* Flock System Config */
displayflocksys(¶meter[0]);
break;
case 21: /* Group Data Mode */
if (parameter[0] == TRUE)
printf("\n\rGroup Data Mode is Enabled");
else
printf("\n\rGroup Data Mode is Disabled");
break;
case 23: /* FBB Auto Configuration - 1 Trans/N Rec */
showfbbconfig(¶meter[0]);
break;
}
hitkeycontinue();
return(TRUE);
}
else
{
return(ESC_SEL);
}
}
void displayflocksys(parameter)
unsigned char * parameter;
{
int i;
/*
Display the Configuration for each Address
*/
printf("\n\rFlock Configuration...");
for (i=0;i<numfbbaddrs;i++)
{
/*
Allow the User to View the Data on a 25 line Screen
*/
if (i == 20)
hitkeycontinue();
printf("\n\rFBB ADDR %d: ",i+1);
if (parameter[i] & 0x80)
{
if (parameter[i] & 0x10)
printf("ERC, ");
else
printf("6DFOB, ");
}
else
{
printf("NOT ACCESSIBLE");
continue;
}
if (parameter[i] & 0x40)
printf("RUNNING, ");
else
printf("NOT RUNNING, ");
if ((parameter[i] & 0x30) == 0x20)
printf("RCVR");
if ((parameter[i] & 0x30) == 0x00)
printf("NO RCVR");
if ((parameter[i] & 0x11) == 0x01)
printf(", XMTR ");
else
{
if ((parameter[i] & 0x10) == 0x00)
printf(", NO XMTR");
}
if ((parameter[i] & 0x11) == 0x11)
printf(" ERT 0");
if ((parameter[i] & 0x12) == 0x12)
printf(" ERT 1");
if ((parameter[i] & 0x14) == 0x14)
printf(" ERT 2");
if ((parameter[i] & 0x18) == 0x18)
printf(" ERT 3");
if ((parameter[i] & 0x1f) == 0x10)
printf(" NO ERTs");
}
hitkeycontinue();
return;
}
/*
bird_crtsync - Implements the CRT SYNC command
Prototype in: birdcmds.h
Parameters Passed: void
Return Value: TRUE if a command was executed
FALSE if command could not be executed
ESC_SEL if the user selected escape
Remarks:
*/
int bird_crtsync()
{
short i;
short rxchar;
static unsigned char birdcrtsynccmd[] = {'A',0};
unsigned char parameter[4];
static char * crtsyncmenu[] = {"Select CRT sync mode:",
"CRT Sync Off",
"CRT Sync - CRT Vertical Retrace Greater than 72 Hz",
"CRT Sync - CRT Vertical Retrace Less than 72 Hz",
"Display CRT Pickup Info"};
/*
Find out what the user wants to do ...
*/
switch (sendmenu(crtsyncmenu,4))
{
case 0: /* CRT sync OFF */
/*
Set the Sync Type
*/
birdcrtsynccmd[1] = 0;
/*
Send the Command
*/
if (send_serial_cmd(birdcrtsynccmd,2) != 2)
return(FALSE);
printf("CRT sync OFF command sent to the Bird\n\r");
break;
case 1: /* CRT sync - > 72 Hz */
/*
Set the Sync Type
*/
birdcrtsynccmd[1] = 1;
/*
Send the Command
*/
if (send_serial_cmd(birdcrtsynccmd,2) != 2)
return(FALSE);
printf("CRT sync '1' command sent to the Bird\n\r");
break;
case 2: /* CRT sync - < 72 Hz */
/*
Set the Sync Type
*/
birdcrtsynccmd[1] = 2;
/*
Send the Command
*/
if (send_serial_cmd(birdcrtsynccmd,2) != 2)
return(FALSE);
printf("CRT sync '2' command sent to the Bird\n\r");
break;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -