📄 birdcmds.c
字号:
data_ready_char = (unsigned char) answer;
}
while (invalid);
break;
case 7: /* Set ON ERROR Mask */
/*
Set the Parameter number and the command size
*/
birdchangevaluecmd[1] = 11;
cmdsize = 3;
/*
Ask the user the Error Mask Mode
*/
switch(sendmenu(errormaskmenu,3))
{
case 0: /* Fatal Error Blink and Stop system */
birdchangevaluecmd[2] = 0x00;
break;
case 1: /* Fatal Error Blink and system resumes */
birdchangevaluecmd[2] = 0x01;
break;
case 2: /* Fatal Error Does NOT Blink and system resumes */
birdchangevaluecmd[2] = 0x03;
break;
case ESC_SEL:
return(ESC_SEL);
}
printf("\n\r");
break;
case 8: /* Set DC Filter Constant Table */
/*
Set the Parameter number and the command size
*/
birdchangevaluecmd[1] = 12;
cmdsize = 16;
/*
Ask the user to enter the DC Filter Table
*/
for (i=0;i<7;i++)
{
printf("\n\rFor the range %s, current value is %d (decimal)\n\r",
dcfiltermsg[i],dcfiltervalue[i]);
printf("\n\rEnter the new value for this range, or ESC for no change: ");
if ((answer = getnumber()) != ESC_SEL)
dcfiltervalue[i] = answer;
/*
Store the Value in the command string
*/
j = dcfiltervalue[i];
*(unsigned char *)&birdchangevaluecmd[2 + (i*2)] =
j & 0xff;
*(unsigned char *)&birdchangevaluecmd[2 + (i*2) + 1] =
((j & 0xff00) >> 8);
}
break;
case 9: /* Filter Constant Table - Alpha Max */
/*
Set the Parameter number and the command size
*/
birdchangevaluecmd[1] = 13;
cmdsize = 16;
/*
Set all 7 table entries
*/
for (i=0; i < 7; i++)
{
/*
Get the Filter Value from the User..with validation
0 to 0.99996
*/
do
{
invalid = FALSE;
printf ("For the range %s,\n\rInput the New Filter Value (0 to 0.99996): ",
dcfiltermsg[i]);
if (getfloatstring(floatstring) != NULL)
floatvalue = atof(floatstring);
else
return(ESC_SEL);
/*
Validate the number
*/
if ((floatvalue < 0.0) || (floatvalue >= 1.00))
{
invalid = TRUE;
printf("** ERROR ** invalid value\n\r");
}
}
while(invalid);
/*
Convert float to word 0 to 32767 and store in the command
*/
j = (unsigned)(floatvalue * FTW);
*(unsigned char *)&birdchangevaluecmd[2 + (i*2)] =
j & 0xff;
*(unsigned char *)&birdchangevaluecmd[2 + (i*2) + 1] =
((j & 0xff00) >> 8);
}
break;
case 10: /* Glitch Checking */
/*
Set the Parameter number and the command size
*/
birdchangevaluecmd[1] = 14;
cmdsize = 3;
/*
Ask the User if they want to Enable Glitch Checking
*/
birdchangevaluecmd[2] = FALSE;
if ((answer = askyesno("Do you want to Block Sudden Output Changes")) == YES)
birdchangevaluecmd[2] = TRUE;
else if (answer == ESC_SEL)
return(ESC_SEL);
break;
case 11: /* Set XYZ Reference Frame */
/*
Set the Parameter number and the command size
*/
birdchangevaluecmd[1] = 17;
cmdsize = 3;
/*
Ask user about value to send
*/
if ((answer = askyesno("Do you want to define Reference Frame")) == YES)
*(unsigned char *) &birdchangevaluecmd[2] = 1;
else
*(unsigned char *) &birdchangevaluecmd[2] = 0;
break;
case 12: /* Set FBB Host Delay */
/*
Set the Parameter number and the command size
*/
birdchangevaluecmd[1] = 32;
cmdsize = 4;
/*
Ask the user to enter the FBB Response Delay
*/
printf("\n\rEnter the desired delay in units of microseconds: ");
if ((answer = getnumber()) == ESC_SEL)
return(ESC_SEL);
/*
Setup for units of 10 uS
*/
if (answer < 200)
answer = 20; /* 200 uS minimum */
else
{
if (answer % 10)
answer = (answer / 10) + 1;
else
answer = (answer / 10);
}
*(unsigned char *) &birdchangevaluecmd[2] = answer & 0xff;
*(unsigned char *) &birdchangevaluecmd[3] = ((answer & 0xff00) >> 8);
break;
case 13: /* Set FBB Configuration */
/*
Set the Parameter number and the command size
*/
birdchangevaluecmd[1] = 33;
cmdsize = 7;
/*
Ask the user for the Configuration Mode
*/
switch(sendmenu(configmodemenu,2))
{
case 0: /* standalone */
birdchangevaluecmd[2] = 0x00;
break;
case 1: /* one trans/ n rec */
birdchangevaluecmd[2] = 0x01;
break;
case ESC_SEL:
return(ESC_SEL);
}
/*
Ask the user for the FBB Device Numbers
*/
do
{
printf("\n\rFBB Devices..");
for (i=1;i<=14;i++)
{
printf("\n\rDevice at FBB address %d is ", i);
if ((0x1 << i) & fbbdevices)
printf("ACTIVE");
else
printf("NOT ACTIVE");
}
printf("\n\n\rEnter the FBB address to change, 0 if complete: ");
if ((answer = getnumber()) == ESC_SEL)
return(ESC_SEL);
else if (answer != 0)
fbbdevices ^= (0x1 << answer); /* flip the bit state */
}
while (answer != 0);
*(unsigned char *) &birdchangevaluecmd[3] = fbbdevices & 0xff;
*(unsigned char *) &birdchangevaluecmd[4] = ((fbbdevices & 0xff00) >> 8);
/*
Ask the user for the FBB Dependents
*/
do
{
printf("\n\rFBB Dependents..");
for (i=1;i<=14;i++)
{
/*
Only Active devices can be dependentsc
*/
if ((0x1 << i) & fbbdevices)
{
printf("\n\rDevice at FBB address %d is ", i);
if ((0x1 << i) & fbbdependents)
printf("DEPENDENT");
else
printf("NOT DEPENDENT");
}
}
printf("\n\n\rEnter the FBB address to change, 0 if complete: ");
if ((answer = getnumber()) == ESC_SEL)
return(ESC_SEL);
else
{
if (((0x1 << answer) & fbbdevices) && (answer != 0))
fbbdependents ^= (0x1 << answer); /* flip the bit state */
else /* device is not active */
printf("\n\rDevice at FBB address %d is NOT ACTIVE\n\r", answer);
}
}
while (answer != 0);
*(unsigned char *) &birdchangevaluecmd[5] = fbbdependents & 0xff;
*(unsigned char *) &birdchangevaluecmd[6] = ((fbbdependents & 0xff00) >> 8);
break;
case 14: /* Set FBB ARMed */
/*
Set the Parameter number and the command size
*/
birdchangevaluecmd[1] = 34;
cmdsize = 3;
/*
Ask the user if they want to ARM the Bird
*/
if ((answer = askyesno("Do you want to ARM the Bird")) == YES)
birdchangevaluecmd[2] = TRUE;
else if (answer == ESC_SEL)
return(ESC_SEL);
break;
case 15: /* Enable/Disable Group Mode */
/*
Set the Parameter number and the command size
*/
birdchangevaluecmd[1] = 35;
cmdsize = 3;
/*
This command will only go to the device the computer
is connected to
*/
rs232tofbbaddr = 0;
/*
Indicate that we are in the Group Mode
*/
fbbgroupdataflg = FALSE;
/*
Ask the user if they want to Save the Configuration
*/
if ((answer = askyesno("Do you want to Enable the Group Data Mode")) == YES)
{
birdchangevaluecmd[2] = TRUE;
fbbgroupdataflg = TRUE;
}
else if (answer == ESC_SEL)
{
rs232tofbbaddr = temprs232tofbbaddr;
return(ESC_SEL);
}
break;
case 16: /* FBB Auto Configuration - 1 Trans/N Rec */
/*
Set the Parameter number and the command size
*/
birdchangevaluecmd[1] = 50;
cmdsize = 3;
/*
Preset the RS232 to Destination address to 1 for
this command if the RS232 to FBB command is active
*/
if (rs232tofbbaddr != 0)
rs232tofbbaddr = 1;
/*
Ask the user to enter the number of receivers
*/
printf("\
NOTE: This Auto Configuration mode assumes that Bird 1 will be a\n\r\
Master and Birds 2 through N will be Slaves");
do
{
invalid = FALSE;
printf ("\n\rEnter the number of Bird Units in the Flock: ");
if ((answer = getnumber()) == ESC_SEL)
return(ESC_SEL);
if ((answer < 1) || (answer > numfbbaddrs))
{
invalid = TRUE;
printf("\n\r** ERROR ** invalid entry, try again\n\r");
hitkeycontinue();
}
}
while(invalid);
birdchangevaluecmd[2] = (unsigned char) answer;
/*
Store the number of Units in the Flock
...for use by other routines
*/
flocksize = answer;
displaymultidataflg = TRUE;
break;
}
/*
Send the Command to the Bird
*/
if (send_serial_cmd(birdchangevaluecmd,cmdsize) != cmdsize)
{
rs232tofbbaddr = temprs232tofbbaddr;
return(FALSE);
}
/*
Restore the rs232tofbbaddr
*/
rs232tofbbaddr = temprs232tofbbaddr;
printf("\n\rNew Value(s) sent to the Bird\n\r");
hitkeycontinue();
/*
If the Command was the Autoconfiguration...than
get the current system status
*/
if (menusel == 16)
{
if (getsystemstatus())
{
displayflocksys(&fbbsystemstatus[1]);
}
else
return(FALSE);
}
return(TRUE);
}
/*
bird_examinevalue - Implements the Examine Value Commmand
Prototype in: birdcmds.h
Parameters Passed: void
Return Value: TRUE if Command was sent to the Bird
FALSE if could not send the command
ESC_SEL if the User selected ESC
Remarks:
*/
int bird_examinevalue()
{
unsigned short i;
short rxchar;
short answer;
char ** dcfiltermsg;
static unsigned char birdexaminevaluecmd[] = {'O',0};
unsigned char parameter[30]; /* room for a 30 byte response */
float measurementrate;
static char * examinevaluemenu[] = {"Select Parameter to Examine:",
"Previous Menu",
"Bird System Status",
"Software Revision",
"Bird CPU Crystal Frequency",
"Maximum Range Scaling",
"Filter ON/OFF Status",
"Filter Const - Alpha_Min",
"Bird Measurement Rate",
"Data Ready Output",
"Data Ready Character",
"Error Code",
"ON ERROR Mask",
"Filter Const - Vm",
"Filter Const - Alpha_Max",
"Sudden Output Changes",
"Model",
"Expanded Error Code",
"XYZ Reference Frame",
"FBB Host Delay",
"FBB Configuration",
"FBB ARMed",
"Group Data Mode",
"Flock System Status",
"FBB Auto Config - 1 Trans/N Rec"};
/*
Parameternumbers for menu items
*/
static unsigned short examinevalueparanumber[] =
{0,0,1,2,3,4,5,6,8,9,10,11,12,13,14,15,16,17,32,33,34,35,36,50};
/*
Number of characters in the response for each menu item
*/
static unsigned short examinevaluerspsize[] =
{0,2,2,2,2,2,14,2,1,1,1,1,14,14,1,10,2,1,2,5,14,1,14,5};
static char * bird_dcfiltermsg[] = {"0 to 12 inches",
"12 to 15 inches",
"15 to 19 inches",
"19 to 24 inches",
"24 to 30 inches",
"30 to 38 inches",
"38+ inches"};
static char * erc_dcfiltermsg[] = {"0 to 35 inches",
"35 to 49 inches",
"49 to 63 inches",
"63 to 79 inches",
"79 to 96 inches",
"96 to 116 inches",
"116+ inches"};
/*
Set up for ERC or 6DFOB
*/
if (posk == POSK144)
dcfiltermsg = erc_dcfiltermsg;
else
dcfiltermsg = bird_dcfiltermsg;
/*
Find out which Value the User wants to look at and take
appropriate action
*/
if ((answer = sendmenu(examinevaluemenu,24)) > 0)
{
/*
Check the command and only inquire about address mode
when the user request a function that needs the information
*/
if ( answer==19 || answer==20 || answer==22 || answer==23 ) {
/*
Get the Number of FBB Addrs
*/
if (getaddrmode() == 0)
return(FALSE);
/*
Update the Response size for the FBB CONFIG, FBB ARM
FBB AUTOCONFIG and the FBB SYSTEM STATUS
*/
if (numfbbaddrs == 14) {
examinevaluerspsize[19] = 5;
examinevaluerspsize[20] = 14;
examinevaluerspsize[22] = 14;
examinevaluerspsize[23] = 5;
} else {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -