Thread: User_Byte
View Single Post
  #3   Spotlight this post!  
Unread 20-03-2005, 09:21
Gary Bonner Gary Bonner is offline
Registered User
FRC #3974
 
Join Date: Jan 2002
Rookie Year: 2000
Location: PA
Posts: 120
Gary Bonner has a spectacular aura aboutGary Bonner has a spectacular aura about
Re: User_Byte

What does this function do? It uses all the user_byte variables.

Thanks

Code:
/*******************************************************************************
* FUNCTION NAME: Handle_Panel_Data
* PURPOSE:       State machine for incomming Breaker Panel data.  
*
*
* NOTE:          Normally device specific code should reside in another file but
*                for the purpose of simplification we chose to put it here. 
*
* CALLED FROM:   CheckUartInts
* ARGUMENTS:     1
*     Argument       Type             IO   Description
*     --------       -------------    --   -----------
*     data           unsigned char    I    incoming data byte
* LIMITATIONS:   The data from the breaker panel does not contain a checksum.
*				 See the breaker-panel-packet-definitions.pdf file for more info.
*******************************************************************************/

void Handle_Panel_Data(unsigned char data)  
{
  switch (IntState)
  {
    case 0:  // 1st 0xC9
      IntState = 0;
      if (data == 0xC9) IntState = 1;
      break;
    case 1 : // 2nd 0x17
      IntState = 0;
      if (data == 0x17) IntState = 2;
      break;
    case 2 : //get DATA1
      dataIn.data1Byte.allbits = data;
      txdata.user_byte3 = data;
      aBreakerWasTripped = (int) dataIn.data1Byte.bitselect.tripped;
      IntState = 3;
      break;
    case 3 : //get DATA2
      dataIn.data2 = data;
      txdata.user_byte4 = data;
      IntState = 4;
      break;
    case 4 : //get DATA3
      dataIn.data3 = data;
      txdata.user_byte5 = data;
      IntState = 5;
      break;
    case 5 : //get DATA4
      dataIn.data4 = data;
      txdata.user_byte6 = data;
      IntState = 0;
      break;
    default:
      IntState= 0;
      break;
  }
}