📄 cmdutil.c
字号:
printf("%s\n\r",promptstrg);
/*
Get Angle Info from user, 3 floating point (double) variables
*/
do
{
invalid = FALSE;
printf("Input %s: ",anglepromptmsg[i]);
/*
Get a float value from the user
*/
if (getfloatstring(floatstring) != NULL)
angle[i] = (float) atof(floatstring);
else
return(ESC_SEL);
if ((angle[i] < anglevalidlow[i]) || (angle[i] > anglevalidhigh[i]))
{
invalid = TRUE;
printf("%s",invalidanglemsg);
}
else
{
i++;
}
}
while ((invalid) || (i<3));
return(TRUE);
}
/*
getcrystalfreq - Get the Crystal Frequency from the Bird
Prototype in: cmdutil.h
Parameters Passed: void
Return Value: TRUE if got OK, sets the Global crystalfreq
FALSE if could not get the crystal frequency
Remarks: Gets the crystal frequency from the Bird via the
Examine CMD function 2.
*/
int getcrystalfreq()
{
short i;
short j;
unsigned char parameter[2];
static unsigned char birdgetcrystalcmd[] = {'O',2};
/*
Send the Command to the Bird
*/
if (send_serial_cmd(birdgetcrystalcmd,2) != 2)
return(FALSE);
/*
Get the 2 byte response response
*/
for (i=0; i<2; i++)
{
j = waitforchar();
if (j < 0)
{
printf("**ERROR** could not read data back from the Bird\n\r");
return(FALSE);
}
parameter[i] = j;
}
/*
Set the crystal frequency variable
*/
crystalfreq = parameter[0];
return(TRUE);
}
/*
getaddrmode Get the current Addressing Mode
Prototype in: cmdutil.h
Parameters Passed: void
Return Value: 30 if in Expanded Address Mode
14 if in Normal Address Mode
FALSE if an Error Occurs
Remarks: The routine gets the Bird Status from the Master
and uses bit 12 to determine if the flock is in
expanded address mode
*/
int getaddrmode()
{
short i;
short rxchar;
unsigned char parameter[2];
static unsigned char birdgetaddrmodecmd[] = {'O',0};
/*
Send the Examine Value Comand with Parameter 0 and wait for a 2
byte response
*/
printf("Checking System Status...");
if (send_serial_cmd(birdgetaddrmodecmd,2) !=2)
return(FALSE);
/*
Get the 2 byte response
*/
for (i=0; i<2; i++)
{
rxchar = waitforchar();
parameter[i] = (unsigned char) rxchar;
if (rxchar < 0)
{
printf("** ERROR ** could not read Bird Status\n\r");
hitkeycontinue();
return(FALSE);
}
}
/*
Assume a normal addressing mode
*/
numfbbaddrs = 14;
/*
Check bit 12 in the Status Word...or bit 2 in the second byte
and return the proper value
*/
if (parameter[1] & 0x04)
{
printf ("\n\r...Flock is setup to the Expanded Addressing Mode\n\n\r");
numfbbaddrs = 30;
fbbaddrbits = 0x1f;
cmdbitshft = 5;
return(30);
}
else
{
printf ("\n\r...Flock is setup to the Normal Addressing Mode\n\n\r");
numfbbaddrs = 14;
fbbaddrbits = 0x0f;
cmdbitshft = 4;
return(14);
}
}
/*
getsystemstatus Get System Status
Prototype in: cmdutil.h
Parameters Passed: void
Return Value: TRUE if all goes OK
FALSE if an Error Occurs
Remarks: Gets the System Status from the Bird
*/
int getsystemstatus()
{
short i;
short rxchar;
short temprs232tofbbaddr;
static unsigned char birdgetsysstatuscmd[] = {'O',36};
/*
Save the Current Address, but only send this command to
the device we are connected to..DO NOT USE the RS232 To FBB Command
*/
temprs232tofbbaddr = rs232tofbbaddr;
rs232tofbbaddr = 0;
/*
Send the Examine Value Comand with Parameter 0 and wait for a 2
byte response
*/
if (send_serial_cmd(birdgetsysstatuscmd,2) !=2)
{
rs232tofbbaddr = temprs232tofbbaddr;
return(FALSE);
}
/*
Get the 14 or 30 byte response
*/
for (i=1; i<=numfbbaddrs; i++)
{
rxchar = waitforchar();
if (rxchar < 0)
{
rs232tofbbaddr = temprs232tofbbaddr;
printf("** ERROR ** could not read Bird Status\n\r");
hitkeycontinue();
return(FALSE);
}
else
{
fbbsystemstatus[i] = (unsigned char) rxchar;
}
}
/*
Go through the List and Fill in the number of receivers
and the start and stop addresses of currently Running Devices
*/
numfbbrcvrs = 0;
displayliststartaddr = 99; /* Start with a illegal and High value */
displayliststopaddr = 1;
for (i=1; i<=numfbbaddrs; i++)
{
if (fbbsystemstatus[i] & 0x40) /* Device is Running */
{
/*
On the First time through setup the start address
..rs232tofbbstartaddr was initialized to 99
*/
if (rs232tofbbstartaddr > 30)
if (i < rs232tofbbstartaddr)
rs232tofbbstartaddr = i;
if (fbbsystemstatus[i] & 0x20) /* Device has a receiver */
{
if (i < displayliststartaddr)
displayliststartaddr = i;
displayliststopaddr = i;
numfbbrcvrs++;
}
}
}
rs232tofbbaddr = temprs232tofbbaddr;
return(TRUE);
}
/*
checkerrorstatus Check 6DFOB Error Status
Prototype in: cmdutil.h
Parameters Passed: void
Return Value: errnum > 0
-1 if could not get the error
0 if no error
Remarks: The routine gets the Bird Error Status
*/
int checkerrorstatus(displayon)
unsigned char displayon;
{
short i;
short rxchar;
unsigned char parameter[2];
unsigned char errnum;
unsigned char exterrnum;
static unsigned char birdgetaddrmodecmd[] = {'O',16};
/*
Send the Examine Value Comand with Parameter 0 and wait for a 2
byte response
*/
if (send_serial_cmd(birdgetaddrmodecmd,2) !=2)
return(-1);
/*
Get the 2 byte response
*/
for (i=0; i<2; i++)
{
rxchar = waitforchar();
parameter[i] = (unsigned char) rxchar;
if (rxchar < 0)
{
printf("** ERROR ** could not read Bird Error Status\n\r");
hitkeycontinue();
return(-1);
}
}
errnum = parameter[0];
exterrnum = parameter[1];
/*
Display the Error Type if one exists and the display is enabled
*/
if (errnum && displayon)
displayerror (errnum,exterrnum,TRUE);
return(errnum);
}
/*
displayerror Display the Current Error Status
Prototype in: cmdutil.h
Parameters Passed: errnum - Error Code
exterrnum - Expanded Error Code
Return Value: void
Remarks:
*/
void displayerror(errnum,exterrnum,displayexpinfo)
unsigned char errnum;
unsigned char exterrnum;
unsigned char displayexpinfo;
{
/*
Display the Error Number
*/
printf ("\n\rError Code is %u (decimal) ",(unsigned char) errnum);
/*
Display a message describing the Error
*/
switch (errnum)
{
case 0:
printf("...No Errors Have Occurred");
break;
case 1:
printf("...System RAM Test Error");
break;
case 2:
printf("...Non-Volatile Storage Write Failure");
break;
case 3:
printf("...System EEPROM Configuration Corrupt");
break;
case 4:
printf("...Transmitter EEPROM Configuration Corrupt");
break;
case 5:
printf("...Receiver EEPROM Configuration Corrupt");
break;
case 6:
printf("...Invalid RS232 Command");
break;
case 7:
printf("...Not an FBB Master");
break;
case 8:
printf("...No 6DFOBs are Active");
break;
case 9:
printf("...6DFOB has not been Initialized");
break;
case 10:
printf("...FBB Receive Error - Intra Bird Bus");
break;
case 11:
printf("...RS232 Overrun and/or Framing Error");
break;
case 12:
printf("...FBB Receive Error - FBB Host Bus");
break;
case 13:
printf("...No FBB Command Response from Device at address %d",exterrnum & fbbaddrbits);
if (displayexpinfo)
{
printf ("\n\rExpanded Error Code Address is %u (decimal)",exterrnum & fbbaddrbits);
printf ("\n\rExpanded Error Code Command is %u (decimal)\n\r",(unsigned char) ((exterrnum & ~fbbaddrbits) >> cmdbitshft));
}
break;
case 14:
printf("...Invalid FBB Host Command");
break;
case 15:
printf("...FBB Run Time Error");
break;
case 16:
printf("...Invalid CPU Speed");
break;
case 17:
printf("...Slave No Data Error");
break;
case 18:
printf("...Illegal Baud Rate");
break;
case 19:
printf("...Slave Acknowledge Error");
break;
case 20:
printf("...CPU Overflow Error - call factory");
break;
case 21:
printf("...Array Bounds Error - call factory");
break;
case 22:
printf("...Unused Opcode Error - call factory");
break;
case 23:
printf("...Escape Opcode Error - call factory");
break;
case 24:
printf("...Reserved Int 9 - call factory");
break;
case 25:
printf("...Reserved Int 10 - call factory");
break;
case 26:
printf("...Reserved Int 11 - call factory");
break;
case 27:
printf("...Numeric CPU Error - call factory");
break;
case 28:
printf("...CRT Syncronization Error");
break;
case 29:
printf("...Transmitter Not Active Error");
break;
case 30:
printf("...ERC Extended Range Transmitter Not Attached Error");
break;
case 31:
printf("...CPU Time Overflow Error");
break;
case 32:
printf("...Receiver Saturated Error");
break;
case 33:
printf("...Slave Configuration Error");
break;
case 34:
printf("...ERC Watchdog Error");
break;
case 35:
printf("...ERC Overtemp Error");
break;
default:
printf("...UNKNOWN ERROR... check user manual");
break;
}
return;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -