Page 1 of 3 123 LastLast
Results 1 to 10 of 22
  1. #1
    25+ Posting Member
    Join Date
    Jun 2012
    Location
    Canada
    Posts
    34
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Question Baud Rate - What's too fast?

    Hi Jim,

    First, thanks so much for the work you have done! It's awesome to see the world of Arduino (which I am a huge fan) meeting the world of DIY flight sims! Your solution has me so inspired I have begun looking at building a 737-800 CP... Unfortunately this has kinda given my Arcade Cabinet project a bit of a back seat! LOL Mrs. PacMan will have to wait...

    On to the business end.

    Problem

    I have started playing with your link2fs_inOut_v2 and find that I reach the serial buffer limits using your default 115200 if I add too many outputs. When the serial bytes flood the arduino, it sometimes seems to miss the end of the string of values sent as they have passed the end of the buffer. Of course, this is only an issue when the Refresh timer runs as it flushes all the checked values down the serial interface at once. I considered setting it to 0, but it's there for a reason right? Wouldn't want to have accidentally missed an update and have to wait until the state changes again.

    Work Around

    Anyways, by dropping the Baud rate in the Sketch and in your app to 9600, I don't seem to reach the end f the buffer and can now read the entire string without problems. While this works, do you recommend it and have you run into this in the past?

    Again thanks for your hard work. I hope to be posting some of my results and code soon.

    Dave

  2. #2
    150+ Forum Groupie WJH308's Avatar
    Join Date
    Aug 2008
    Location
    San Francisco, CA
    Posts
    159
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: Baud Rate - What's too fast?

    My MCP using Jim's program is pretty intensive on the serial port and I have not seen any problems. Keep in mind I was able to port Jim's examples to Arduino 1.0+ and the behavior of the serial flush is completely different and the serial communications are now asynchronous.
    Serial.flush will not delete anything, what it now does is keep anything from being sent until the serial port is ready to send.
    I am now porting my MCP to Prosim737 and the arduino talks directly to prosim over the serial port, no 3rd party software. The serial port is more than fast enough for that, at least from the arduino side of things.
    If the end of the strings are missing or being skipped, make sure you have that 11ms or longer delay in there.

  3. #3
    25+ Posting Member
    Join Date
    Jun 2012
    Location
    Canada
    Posts
    34
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: Baud Rate - What's too fast?

    Interesting. I maybe should have mentioned that I am also using Arduino 1.0.1

    I will have to play around a bit more tonight.

  4. #4
    25+ Posting Member
    Join Date
    Jun 2012
    Location
    Canada
    Posts
    34
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: Baud Rate - What's too fast?

    You could be correct, it might be a matter of timing.

    Here is my sample PDE, but for some reason it doesn't work when everything is in there. I am not using Serial.flush, but when I remove most of the repetitive code for each serial command it seems to work fine. ie a minimalistic sketch with only a few serial commands. But when I give it a full go then I get really weird activity in the serial output from the arduino. (Note I am testing by copying a string from link2fs and pasting it into the Arduino Serial Monitor window.

    Maybe I'm hitting a memory ceiling? Although I thought integer was 2 bytes and the ATmega328 had 1024 bytes of memory... with about 110 integers I should be no more than 250 bytes? Again, maybe I am miss understanding it.

    - Unfortunately I can't seem to attach a txt file and the sketch is too long to post. I will go and try from another machine.

  5. #5
    150+ Forum Groupie WJH308's Avatar
    Join Date
    Aug 2008
    Location
    San Francisco, CA
    Posts
    159
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: Baud Rate - What's too fast?

    Use the [ code ] [ /code] forum tags to keep formatting for when displaying code

  6. #6
    25+ Posting Member
    Join Date
    Jun 2012
    Location
    Canada
    Posts
    34
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: Baud Rate - What's too fast?

    Sorry, can't seem to upload attachments will have to be multi-part post as it's too long.

    Part A

    Code:
    // ***************************** MAIN PAGE *****************************
    int intPitch = 0;                       //  A   Pitch
    int intRoll = 0;                        //  B   Roll
    int intAltitude = 0;                    //  C   Altitude
    int intGroundClearance = 0;             //  D   Ground Clearance
    int intForwardAccel = 0;                //  E   Forward Acceleration
    int intPitchAccel = 0;                  //  F   Pitch Acceleration
    int intRollAccel = 0;                   //  G   Roll Acceleration
    int intGForce = 0;                      //  H   G Force
    int intGearPositionNose = 0;            //  I   Gear Position Nose
    int intGearPositionLeft = 0;            //  J   Gear Position Left
    int intGearPositionRight = 0;           //  K   Gear Position Right
    int intStallWarning = 0;                //  L   Stall Warning
    int intFlapsPosition = 0;               //  M   Flaps Position
    int intTrim = 0;                        //  N   Trim
    int intEngine1RPM = 0;                  //  O   Engine 1 RPM
    int intPlaneOnGround = 0;               //  P   Plane on Ground
    int intHeading = 0;                     //  Q   Heading
    int intFuelPercent = 0;                 //  R   Fuel Percent
    int intSpoilersPercent = 0;             //  S   Spoilers Percent
    int intVerticlSpeed = 0;                //  T   Vertical Speed
    int intTurnCoordinatorBall = 0;         //  U   Turn Co-ordinator Ball
    int intGroundSpeed = 0;                 //  V   Ground Speed
    int intAirSpeedIndicated = 0;           //  W   Air Speed Indicated
    int intElectricalMasterSwitch = 0;      //  X   ElectricalMasterSwitch
    int intPlaneLatitude = 0;               //  Y   Plane Latitude (Dec)
    int intPlaneLongitude = 0;              //  Z   Plane Longitude (Dec)
    int intAPCourseSet = 0;                 //  a   Auto Pilot CRS (Course) Set
    int intAPActive = 0;                    //  b   Auto Pilot Active
    int intCurrentMach = 0;                 //  c   Current Mach (Speed)
    int intCom1FreqMhz = 0;                 //  d   Com1 Radio Frequency "MHZ"
    int intCom1FreqKhz = 0;                 //  d   Com1 Radio Frequency "KHZ"
    int intCom1StandbyMhz = 0;              //  e   Com1 Radio Standby Frequency "MHZ"
    int intCom1StandbyKhz = 0;              //  e   Com1 Radio Standby Frequency "KHZ"
    int intCom2FreqMhz = 0;                 //  f   Com2 Radio Frequency "MHZ"
    int intCom2FreqKhz = 0;                 //  f   Com2 Radio Frequency "KHZ"
    int intCom2StandbyMhz = 0;              //  g   Com2 Radio Standby Frequency "MHZ"
    int intCom2StandbyKhz = 0;              //  g   Com2 Radio Standby Frequency "KHZ"
    int intNav1FreqMhz = 0;                 //  h   Nav1 Radio Frequency "MHZ"
    int intNav1FreqKhz = 0;                 //  h   Nav1 Radio Frequency "KHZ"
    int intNav1StandbyMhz = 0;              //  i   Nav1 Radio Standby Frequency "MHZ"
    int intNav1StandbyKhz = 0;              //  i   Nav1 Radio Standby Frequency "KHZ"
    int intNav2FreqMhz = 0;                 //  j   Nav2 Radio Frequency "MHZ"
    int intNav2FreqKhz = 0;                 //  j   Nav2 Radio Frequency "KHZ"
    int intNav2StandbyMhz = 0;              //  k   Nav2 Radio Standby Frequency "MHZ"
    int intNav2StandbyKhz = 0;              //  k   Nav2 Radio Standby Frequency "KHZ"
    int intADF = 0;                         //  l   ADF
    int intTransponderCode = 0;             //  m   Transponder Code
    int intDME1 = 0;                        //  n   Distance Measurement DME1
    int intDME2 = 0;                        //  o   Distance Measurement DME2
    int intAPAltitudeSet = 0;               //  p   Auto Pilot Altitude Set
    int intAPVerticleSpeedSet = 0;          //  q   Auto Pilot VerticleSpeedSet
    int intAPHeadingSet = 0;                //  r   Auto Pilot Heading Set
    int intAPAltitudeLockActive = 0;        //  s   Auto Pilot Altitude Lock Active
    int intAPHeadingLockActive = 0;         //  t   Auto Pilot Heading Lock Active
    int intAPSpeedSet = 0;                  //  u   Auto Pilot Speed Set (Knots)
    int intAPApproachHoldActive = 0;        //  v   Auto Pilot Approach Hold Active
    int intAPBackCourseActive = 0;          //  w   Auto Pilot Back Course Active
    int intAPNav1LockActive = 0;            //  x   Auto Pilot Nav 1 Lock Active
    int intAPWingLevelerActive = 0;         //  y   Auto Pilot Wing Leveler Active
    int intAPFlightDirectorActive = 0;      //  z   Auto Pilot Flight Director Active
    
    // ***************************** MORE EXTRACTIONS *****************************
    int intAPMachSet = 0;                   //  >A  Auto Pilot Mach Set
    int intAPMachActive = 0;                //  >B  Auto Pilot Mach Active
    int intAPGlideslopeHoldActive = 0;      //  >C  Auto Pilot Glideslope Hold Active
    int intAPAirspeedHoldActive = 0;        //  >D  Auto Pilot Airspeed Hold Active
    int intAPAutothrottleArmed = 0;         //  >E  Auto Pilot Autothrottle Armed
    int intAPTakeoffPowerActive = 0;        //  >F  Auto Pilot Takeoff Power Active
    int intAPAutothrottleActive = 0;        //  >G  Auto Pilot Autothrottle Active
    int intPitotHeatOn = 0;                 //  >H  Pitot Heat On
    int intNoSmokingSign = 0;               //  >I  No Smoking Sign (FSX)
    int intSeatbeltSign = 0;                //  >J  Seatbelt Sign (FSX Only)
    int intLightState = 0;                  //  >K  Light State (Mask)
    int intAvionicsMasterSwitch = 0;        //  >L  Avionics Master Switch
    int intHSICDINeedlePosition = 0;        //  >M  HSI CDI Needle Position
    int intHSIGSINeedlePosition = 0;        //  >N  HSI GSI Needle Position
    int intInnerMarker = 0;                 //  >O  Inner Marker
    int intMiddleMarker = 0;                //  >P  Middle Marker
    int intOuterMarker = 0;                 //  >Q  Outer Marker
    int intNav1Sound = 0;                   //  >R  Nav 1 Sound
    int intNav2Sound = 0;                   //  >S  Nav 2 Sound
    int intDMESound = 0;                    //  >T  DME Sound
    int intADFSound0 = 0;                   //  >U  ADF Sound 0
    int intADFSound1 = 0;                   //  >V  ADF Sound 1
    int intMarkerSound = 0;                 //  >W  Marker Sound
    int intCom1Sound = 0;                   //  >X  Com 1 Sound
    int intCom2Sound = 0;                   //  >Y  Com 2 Sound
    int intComAllSound = 0;                 //  >Z  Com All Sound
    int intFuelGallonsLeft = 0;             //  >a  Fuel Gallons Left Tank
    int intFuelGallonsCenter = 0;           //  >b  Fuel Gallons Center Tank
    int intFuelGallonsRight = 0;            //  >c  Fuel Gallons Right Tank
    int intAngleOfAttack = 0;               //  >d  Angle Of Attack
    int intStarterEngine1Position = 0;      //  >e  Starter Engine 1 Position
    int intStarterEngine2Position = 0;      //  >f  Starter Engine 2 Position
    int intThrottle1Position = 0;           //  >g  Throttle 1 Position
    int intThrottle2Position = 0;           //  >h  Throttle 2 Position
    int intPropellor1Position = 0;          //  >i  Propellor 1 Position
    int intPropellor2Position = 0;          //  >j  Propellor 2 Position
    int intMixture1Position = 0;            //  >k  Mixture 1 Position
    int intMixture2Position = 0;            //  >l  Mixture 2 Position
    int intSpoilersArmed = 0;               //  >m  Spoilers Armed
    int intSpoilerHandlePosition = 0;       //  >n  Spoiler Handle Position
    int intParkBrakePosition = 0;           //  >o  Parking Brake Position
    int intEngine2RPM = 0;                  //  >p  Engine 2 RPM
    int intFuelPump1 = 0;                   //  >q  Fuel Pump 1
    int intFuelPump2 = 0;                   //  >r  Fuel Pump 2
    int intEngine1FuelValve = 0;            //  >s  Engine 1 Fuel Valve
    int intEngine2FuelValve = 0;            //  >t  Engine 2 Fuel Valve
    int intBatteryVoltage = 0;              //  >u  Battery Voltage
    int intBatteryAmps = 0;                 //  >v  Battery Amps
    int intMainExitOpen = 0;                //  >w  Main Exit Open
    int intFlapsHandlePosition = 0;         //  >x  Flaps Handle Position
    int intBusVoltage = 0;                  //  >y  Bus Voltage
    int intBusAmps = 0;                     //  >z  Bus Amps
    int intGPWSActive = 0;                  //  =A  GPWS Active (FSX Only)
    int intGPSNav1Active = 0;               //  =B  GPS / NAV 1 Active
    
    // remark this line out if debugging is not required...
    //#define DEBUG
    
    
    // Variables Used for proccessing
    int intIsPosititve = 0;                 // This is a temporary integer used to track positive and negative numbers
    
    
    
    
    void setup() {
      // put your setup code here, to run once:
      Serial.begin(115200); // sets up the baud rate for the serial coms.
    
    }
    
    void loop() {
    
      if (Serial.available() > 0) {
        // Read in the serial data
        ReadSerialData ();
      }
      else {
        // Program your code here
        //Serial.println (intEngine1RPM); 
        //delay(50);
      }
    
    }
    
    
    
    
    
    void ReadSerialData () {
      // read the intial character and decide on the value to pursue
      int inByte = Serial.read();
      delay(10);
    
      switch (inByte) {
    
      case 'A':  // Pitch
        // Determine if it is a positive number
        intIsPosititve = PositiveOrNegative(Serial.read());
        // Reset Pitch to 0
        intPitch = 0;
        // Read first three charaters
        intPitch = AddSerialDigitToInteger(Serial.read(), intPitch);
        intPitch = AddSerialDigitToInteger(Serial.read(), intPitch);
        intPitch = AddSerialDigitToInteger(Serial.read(), intPitch);
        // Discard Decimal Point
        Serial.read();
        // Read last character
        intPitch = AddSerialDigitToInteger(Serial.read(), intPitch);  
        // Make it a negative if required
        if (intIsPosititve == 0)
          intPitch = intPitch - (intPitch * 2);
    #ifdef DEBUG
        Serial.print("intPitch - ");
        Serial.println(intPitch);
        Serial.flush();
    #endif 
        break;
    
      case 'B':  // Roll
        // Determine if it is a positive number
        intIsPosititve = PositiveOrNegative(Serial.read());
        // Reset Roll to 0
        intRoll = 0;
        // Read first three charaters
        intRoll = AddSerialDigitToInteger(Serial.read(), intRoll);
        intRoll = AddSerialDigitToInteger(Serial.read(), intRoll);
        intRoll = AddSerialDigitToInteger(Serial.read(), intRoll);
        // Discard Decimal Point
        Serial.read();
        // Read last character
        intRoll = AddSerialDigitToInteger(Serial.read(), intRoll);  
        // Make it a negative if required
        if (intIsPosititve == 0)
          intRoll = intRoll - (intRoll * 2);
    #ifdef DEBUG
        Serial.print("intRoll - ");
        Serial.println(intRoll);
    #endif 
        break;
    
      case 'C':  // Altitude
        // Reset Altitude to 0
        intAltitude = 0;
        // Read the next five characters
        intAltitude = AddSerialDigitToInteger(Serial.read(), intAltitude);
        intAltitude = AddSerialDigitToInteger(Serial.read(), intAltitude);
        intAltitude = AddSerialDigitToInteger(Serial.read(), intAltitude);
        intAltitude = AddSerialDigitToInteger(Serial.read(), intAltitude);
        intAltitude = AddSerialDigitToInteger(Serial.read(), intAltitude);
    #ifdef DEBUG
        Serial.print("intAltitude - ");
        Serial.println(intAltitude);
    #endif 
        break;
    
      case 'D':  // Ground Clearance    
        // Reset Ground Clearance to 0
        intGroundClearance = 0;
        // Read the next five characters
        intGroundClearance = AddSerialDigitToInteger(Serial.read(), intGroundClearance);
        intGroundClearance = AddSerialDigitToInteger(Serial.read(), intGroundClearance);
        intGroundClearance = AddSerialDigitToInteger(Serial.read(), intGroundClearance);
        intGroundClearance = AddSerialDigitToInteger(Serial.read(), intGroundClearance);
        intGroundClearance = AddSerialDigitToInteger(Serial.read(), intGroundClearance);
    #ifdef DEBUG
        Serial.print("intGroundClearance - ");
        Serial.println(intGroundClearance);
    #endif 
        break;
    
      case 'E':  // Forward Acceleration
        // Determine if it is a positive number
        intIsPosititve = PositiveOrNegative(Serial.read());
        // Reset Forward Acceleration to 0
        intForwardAccel = 0;
        // Read first three charaters
        intForwardAccel = AddSerialDigitToInteger(Serial.read(), intForwardAccel);
        intForwardAccel = AddSerialDigitToInteger(Serial.read(), intForwardAccel);
        intForwardAccel = AddSerialDigitToInteger(Serial.read(), intForwardAccel);
        // Discard Decimal Point
        Serial.read();
        // Read last character
        intForwardAccel = AddSerialDigitToInteger(Serial.read(), intForwardAccel);  
        // Make it a negative if required
        if (intIsPosititve == 0)
          intForwardAccel = intForwardAccel - (intForwardAccel * 2);
    #ifdef DEBUG
        Serial.print("intForwardAccel - ");
        Serial.println(intForwardAccel);
    #endif 
        break;
    
      case 'F':  // Pitch Acceleration
        // Determine if it is a positive number
        intIsPosititve = PositiveOrNegative(Serial.read());
        // Reset Pitch Acceleration to 0
        intPitchAccel = 0;
        // Read first three charaters
        intPitchAccel = AddSerialDigitToInteger(Serial.read(), intPitchAccel);
        intPitchAccel = AddSerialDigitToInteger(Serial.read(), intPitchAccel);
        intPitchAccel = AddSerialDigitToInteger(Serial.read(), intPitchAccel);
        // Discard Decimal Point
        Serial.read();
        // Read last character
        intPitchAccel = AddSerialDigitToInteger(Serial.read(), intPitchAccel);  
        // Make it a negative if required
        if (intIsPosititve == 0)
          intPitchAccel = intPitchAccel - (intPitchAccel * 2);
    #ifdef DEBUG
        Serial.print("intPitchAccel - ");
        Serial.println(intPitchAccel);
    #endif 
        break;
    
      case 'G':  // Roll Acceleration
        // Determine if it is a positive number
        intIsPosititve = PositiveOrNegative(Serial.read());
        // Reset Pitch Acceleration to 0
        intRollAccel = 0;
        // Read first three charaters
        intRollAccel = AddSerialDigitToInteger(Serial.read(), intRollAccel);
        intRollAccel = AddSerialDigitToInteger(Serial.read(), intRollAccel);
        intRollAccel = AddSerialDigitToInteger(Serial.read(), intRollAccel);
        // Discard Decimal Point
        Serial.read();
        // Read last character
        intRollAccel = AddSerialDigitToInteger(Serial.read(), intRollAccel);  
        // Make it a negative if required
        if (intIsPosititve == 0)
          intRollAccel = intRollAccel - (intRollAccel * 2);
    #ifdef DEBUG
        Serial.print("intRollAccel - ");
        Serial.println(intRollAccel);
    #endif 
        break;  
    
      case 'H':  // G Force
        // Determine if it is a positive number
        intIsPosititve = PositiveOrNegative(Serial.read());
        // Reset G Force to 0
        intGForce = 0;
        // Read first three charaters
        intGForce = AddSerialDigitToInteger(Serial.read(), intGForce);
        intGForce = AddSerialDigitToInteger(Serial.read(), intGForce);
        intGForce = AddSerialDigitToInteger(Serial.read(), intGForce);
        // Discard Decimal Point
        Serial.read();
        // Read last character
        intGForce = AddSerialDigitToInteger(Serial.read(), intGForce);  
        // Make it a negative if required
        if (intIsPosititve == 0)
          intGForce = intGForce - (intGForce * 2);
    #ifdef DEBUG
        Serial.print("intGForce - ");
        Serial.println(intGForce);
    #endif 
        break;  
    
      case 'I':  // Gear Position Nose
        // Reset to 0
        intGearPositionNose = 0;
        // Read the 3 digits
        intGearPositionNose = AddSerialDigitToInteger(Serial.read(), intGearPositionNose);
        intGearPositionNose = AddSerialDigitToInteger(Serial.read(), intGearPositionNose);
        intGearPositionNose = AddSerialDigitToInteger(Serial.read(), intGearPositionNose);
    #ifdef DEBUG
        Serial.print("intGearPositionNose - ");
        Serial.println(intGearPositionNose);
    #endif 
        break;  
    
      case 'J':  //  J   Gear Position Left
        // Reset to 0
        intGearPositionLeft = 0;            
        // Read the 3 digits
        intGearPositionLeft = AddSerialDigitToInteger(Serial.read(), intGearPositionLeft);
        intGearPositionLeft = AddSerialDigitToInteger(Serial.read(), intGearPositionLeft);
        intGearPositionLeft = AddSerialDigitToInteger(Serial.read(), intGearPositionLeft);
    #ifdef DEBUG
        Serial.print("intGearPositionLeft - ");
        Serial.println(intGearPositionLeft);
    #endif 
        break;  
    
      case 'K':  //  J   Gear Position Right
        // Reset to 0
        intGearPositionRight = 0;            
        // Read the 3 digits
        intGearPositionRight = AddSerialDigitToInteger(Serial.read(), intGearPositionRight);
        intGearPositionRight = AddSerialDigitToInteger(Serial.read(), intGearPositionRight);
        intGearPositionRight = AddSerialDigitToInteger(Serial.read(), intGearPositionRight);
    #ifdef DEBUG
        Serial.print("intGearPositionRight - ");
        Serial.println(intGearPositionRight);
    #endif 
        break;  
    
      case 'L':  //  L   Stall Warning
        intStallWarning = 0;
        intStallWarning = AddSerialDigitToInteger(Serial.read(), intStallWarning);
    #ifdef DEBUG
        Serial.print("intStallWarning - ");
        Serial.println(intStallWarning);
    #endif 
        break;  
    
      case 'M':  //  M   Flaps Position
        intFlapsPosition = 0;   
        intFlapsPosition = AddSerialDigitToInteger(Serial.read(), intFlapsPosition);
        intFlapsPosition = AddSerialDigitToInteger(Serial.read(), intFlapsPosition);
        intFlapsPosition = AddSerialDigitToInteger(Serial.read(), intFlapsPosition);
    #ifdef DEBUG
        Serial.print("intFlapsPosition - ");
        Serial.println(intFlapsPosition);
    #endif 
        break;
    
      case 'N':  //  N   Trim
        // Determine if it is a positive number
        intIsPosititve = PositiveOrNegative(Serial.read());
        // Reset Trim to 0
        intTrim = 0;
        // Read first three charaters
        intTrim = AddSerialDigitToInteger(Serial.read(), intTrim);
        intTrim = AddSerialDigitToInteger(Serial.read(), intTrim);
        intTrim = AddSerialDigitToInteger(Serial.read(), intTrim);
        // Make it a negative if required
        if (intIsPosititve == 0)
          intTrim = intTrim - (intTrim * 2);
    #ifdef DEBUG
        Serial.print("intTrim - ");
        Serial.println(intTrim);
    #endif 
        break;  
    
      case 'O':  //  O   Engine 1 RPM
        intEngine1RPM = 0;
        intEngine1RPM = AddSerialDigitToInteger(Serial.read(), intEngine1RPM);
        intEngine1RPM = AddSerialDigitToInteger(Serial.read(), intEngine1RPM);
        intEngine1RPM = AddSerialDigitToInteger(Serial.read(), intEngine1RPM);
        intEngine1RPM = AddSerialDigitToInteger(Serial.read(), intEngine1RPM);
        intEngine1RPM = AddSerialDigitToInteger(Serial.read(), intEngine1RPM);
    #ifdef DEBUG
        Serial.print("intEngine1RPM - ");
        Serial.println(intEngine1RPM);
    #endif 
        break;
    
      case 'P':  //  P   Plane on Ground
        intPlaneOnGround = 0;               
        intPlaneOnGround = AddSerialDigitToInteger(Serial.read(), intPlaneOnGround);
    #ifdef DEBUG
        Serial.print("intPlaneOnGround - ");
        Serial.println(intPlaneOnGround);
    #endif 
        break;
    
      case 'Q':  //  Q   Heading
        intHeading = 0;                     
        // Read first three charaters
        intHeading = AddSerialDigitToInteger(Serial.read(), intHeading);
        intHeading = AddSerialDigitToInteger(Serial.read(), intHeading);
        intHeading = AddSerialDigitToInteger(Serial.read(), intHeading);
        // Discard Decimal Point
        Serial.read();
        // Read last character
        intHeading = AddSerialDigitToInteger(Serial.read(), intHeading); 
    #ifdef DEBUG
        Serial.print("intHeading - ");
        Serial.println(intHeading);
    #endif 
        break;
    
      case 'R':   //  R   Fuel Percent
        intFuelPercent = 0;                 
        intFuelPercent = AddSerialDigitToInteger(Serial.read(), intFuelPercent);
        intFuelPercent = AddSerialDigitToInteger(Serial.read(), intFuelPercent);
        intFuelPercent = AddSerialDigitToInteger(Serial.read(), intFuelPercent);
    #ifdef DEBUG
        Serial.print("intFuelPercent - ");
        Serial.println(intFuelPercent);
    #endif 
        break;
    
      case 'S':   //  S   Spoilers Percent
        intSpoilersPercent = 0;             
        intSpoilersPercent = AddSerialDigitToInteger(Serial.read(), intSpoilersPercent);
        intSpoilersPercent = AddSerialDigitToInteger(Serial.read(), intSpoilersPercent);
        intSpoilersPercent = AddSerialDigitToInteger(Serial.read(), intSpoilersPercent);
    #ifdef DEBUG
        Serial.print("intSpoilersPercent - ");
        Serial.println(intSpoilersPercent);
    #endif 
        break;
    
      case 'T':   //  T   Vertical Speed
        // Determine if it is a positive number
        intIsPosititve = PositiveOrNegative(Serial.read());
        // Reset Speed to 0
        intVerticlSpeed = 0;                
        // Read first three charaters
        intVerticlSpeed = AddSerialDigitToInteger(Serial.read(), intVerticlSpeed);
        intVerticlSpeed = AddSerialDigitToInteger(Serial.read(), intVerticlSpeed);
        intVerticlSpeed = AddSerialDigitToInteger(Serial.read(), intVerticlSpeed);
        intVerticlSpeed = AddSerialDigitToInteger(Serial.read(), intVerticlSpeed);
        intVerticlSpeed = AddSerialDigitToInteger(Serial.read(), intVerticlSpeed);
        // Make it a negative if required
        if (intIsPosititve == 0)
          intVerticlSpeed = intVerticlSpeed - (intVerticlSpeed * 2);
    #ifdef DEBUG
        Serial.print("intVerticlSpeed - ");
        Serial.println(intVerticlSpeed);
    #endif 
        break;  
    
      case 'U':  //  U   Turn Co-ordinator Ball
        // Determine if it is a positive number
        intIsPosititve = PositiveOrNegative(Serial.read());
        // Reset to 0
        intTurnCoordinatorBall = 0;                
        // Read first three charaters
        intTurnCoordinatorBall = AddSerialDigitToInteger(Serial.read(), intTurnCoordinatorBall);
        intTurnCoordinatorBall = AddSerialDigitToInteger(Serial.read(), intTurnCoordinatorBall);
        intTurnCoordinatorBall = AddSerialDigitToInteger(Serial.read(), intTurnCoordinatorBall);
        // Make it a negative if required
        if (intIsPosititve == 0)
          intTurnCoordinatorBall = intTurnCoordinatorBall - (intTurnCoordinatorBall * 2);
    #ifdef DEBUG
        Serial.print("intTurnCoordinatorBall - ");
        Serial.println(intTurnCoordinatorBall);
    #endif 
        break;  
    
      case 'V':   //  V   Ground Speed
        intGroundSpeed = 0;                 
        intGroundSpeed = AddSerialDigitToInteger(Serial.read(), intGroundSpeed);
        intGroundSpeed = AddSerialDigitToInteger(Serial.read(), intGroundSpeed);
        intGroundSpeed = AddSerialDigitToInteger(Serial.read(), intGroundSpeed);
    #ifdef DEBUG
        Serial.print("intGroundSpeed - ");
        Serial.println(intGroundSpeed);
    #endif 
        break;    
    
      case 'W':  //  W   Air Speed Indicated
        intAirSpeedIndicated = 0;           
        intAirSpeedIndicated = AddSerialDigitToInteger(Serial.read(), intAirSpeedIndicated);
        intAirSpeedIndicated = AddSerialDigitToInteger(Serial.read(), intAirSpeedIndicated);
        intAirSpeedIndicated = AddSerialDigitToInteger(Serial.read(), intAirSpeedIndicated);
    #ifdef DEBUG
        Serial.print("intAirSpeedIndicated - ");
        Serial.println(intAirSpeedIndicated);
    #endif 
        break;  
    
      case 'X':  //  X   ElectricalMasterSwitch
        intElectricalMasterSwitch = 0;
        intElectricalMasterSwitch = AddSerialDigitToInteger(Serial.read(), intElectricalMasterSwitch);
    #ifdef DEBUG
        Serial.print("intElectricalMasterSwitch - ");
        Serial.println(intElectricalMasterSwitch);
    #endif 
        break;
    
      case 'Y':  //  Y   Plane Latitude (Dec)
        ///////////////////////////////////////////////////////////////THIS WONT WORK!!!!/////////////////////////////
        intIsPosititve = PositiveOrNegative(Serial.read());
        intPlaneLatitude = 0;               
        intPlaneLatitude = AddSerialDigitToInteger(Serial.read(), intPlaneLatitude);
        intPlaneLatitude = AddSerialDigitToInteger(Serial.read(), intPlaneLatitude);
        intPlaneLatitude = AddSerialDigitToInteger(Serial.read(), intPlaneLatitude);
        Serial.read();  // Discard Decimal
        intPlaneLatitude = 0;               
        intPlaneLatitude = AddSerialDigitToInteger(Serial.read(), intPlaneLatitude);
        intPlaneLatitude = AddSerialDigitToInteger(Serial.read(), intPlaneLatitude);
        intPlaneLatitude = 0;     
        intPlaneLatitude = AddSerialDigitToInteger(Serial.read(), intPlaneLatitude);
        intPlaneLatitude = AddSerialDigitToInteger(Serial.read(), intPlaneLatitude);
        intPlaneLatitude = AddSerialDigitToInteger(Serial.read(), intPlaneLatitude);
    #ifdef DEBUG
        Serial.print("intPlaneLatitude - ");
        Serial.println(intPlaneLatitude);
    #endif 
        break;
    
      case 'Z':  //  Z   Plane Longitude (Dec)
        ///////////////////////////////////////////////////////////////THIS WONT WORK!!!!/////////////////////////////
        intIsPosititve = PositiveOrNegative(Serial.read());
        intPlaneLongitude = 0;               
        intPlaneLongitude = AddSerialDigitToInteger(Serial.read(), intPlaneLongitude);
        intPlaneLongitude = AddSerialDigitToInteger(Serial.read(), intPlaneLongitude);
        intPlaneLongitude = AddSerialDigitToInteger(Serial.read(), intPlaneLongitude);
        Serial.read();  // Discard Decimal
        intPlaneLongitude = 0;               
        intPlaneLongitude = AddSerialDigitToInteger(Serial.read(), intPlaneLongitude);
        intPlaneLongitude = AddSerialDigitToInteger(Serial.read(), intPlaneLongitude);
        intPlaneLongitude = 0;     
        intPlaneLongitude = AddSerialDigitToInteger(Serial.read(), intPlaneLongitude);
        intPlaneLongitude = AddSerialDigitToInteger(Serial.read(), intPlaneLongitude);
        intPlaneLongitude = AddSerialDigitToInteger(Serial.read(), intPlaneLongitude);
    #ifdef DEBUG
        Serial.print("intPlaneLongitude - ");
        Serial.println(intPlaneLongitude);
    #endif 
        break;

  7. #7
    25+ Posting Member
    Join Date
    Jun 2012
    Location
    Canada
    Posts
    34
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: Baud Rate - What's too fast?

    Part B

    Code:
      case 'a':   //  a   Auto Pilot CRS (Course) Set
        intAPCourseSet = 0;                 
        intAPCourseSet = AddSerialDigitToInteger(Serial.read(), intAPCourseSet);
        intAPCourseSet = AddSerialDigitToInteger(Serial.read(), intAPCourseSet);
        intAPCourseSet = AddSerialDigitToInteger(Serial.read(), intAPCourseSet);
    #ifdef DEBUG
        Serial.print("intAPCourseSet - ");
        Serial.println(intAPCourseSet);
    #endif 
        break;
    
      case 'b':  //  b   Auto Pilot Active
        intAPActive = 0; 
        intAPActive = AddSerialDigitToInteger(Serial.read(), intAPActive);
    #ifdef DEBUG
        Serial.print("intAPActive - ");
        Serial.println(intAPActive);
    #endif 
        break;
    
      case 'c':  //  c   Current Mach (Speed)
        intCurrentMach = 0;                 
        intCurrentMach = AddSerialDigitToInteger(Serial.read(), intCurrentMach);
        Serial.read();  // Discard Decimal
        intCurrentMach = AddSerialDigitToInteger(Serial.read(), intCurrentMach);
        intCurrentMach = AddSerialDigitToInteger(Serial.read(), intCurrentMach);
        intCurrentMach = AddSerialDigitToInteger(Serial.read(), intCurrentMach);
    #ifdef DEBUG
        Serial.print("intCurrentMach - ");
        Serial.println(intCurrentMach);
    #endif 
        break;
    
      case 'd':  //  d   Com1 Radio Frequency
        // Reset the values to 0
        intCom1FreqMhz = 0;
        intCom1FreqKhz = 0;
        // Read the Mhz frequency
        intCom1FreqMhz = AddSerialDigitToInteger(Serial.read(), intCom1FreqMhz);
        intCom1FreqMhz = AddSerialDigitToInteger(Serial.read(), intCom1FreqMhz);
        intCom1FreqMhz = AddSerialDigitToInteger(Serial.read(), intCom1FreqMhz);
        // Discard Decimal
        Serial.read();  
        // Read the Khz Frequency
        intCom1FreqKhz = AddSerialDigitToInteger(Serial.read(), intCom1FreqKhz);
        intCom1FreqKhz = AddSerialDigitToInteger(Serial.read(), intCom1FreqKhz);
        intCom1FreqKhz = AddSerialDigitToInteger(Serial.read(), intCom1FreqKhz);
    #ifdef DEBUG
        Serial.print("intCom1FreqMhz - ");
        Serial.print(intCom1FreqMhz);
        Serial.print(".");
        Serial.println(intCom1FreqKhz);
    #endif 
        break;
    
      case 'e':  //  e   Com1 Standby Frequency
        // Reset the values to 0
        intCom1StandbyMhz = 0;
        intCom1StandbyKhz = 0;
        // Read the Mhz frequency
        intCom1StandbyMhz = AddSerialDigitToInteger(Serial.read(), intCom1StandbyMhz);
        intCom1StandbyMhz = AddSerialDigitToInteger(Serial.read(), intCom1StandbyMhz);
        intCom1StandbyMhz = AddSerialDigitToInteger(Serial.read(), intCom1StandbyMhz);
        // Discard Decimal
        Serial.read();  
        // Read the Khz Frequency
        intCom1StandbyKhz = AddSerialDigitToInteger(Serial.read(), intCom1StandbyKhz);
        intCom1StandbyKhz = AddSerialDigitToInteger(Serial.read(), intCom1StandbyKhz);
        intCom1StandbyKhz = AddSerialDigitToInteger(Serial.read(), intCom1StandbyKhz);
    #ifdef DEBUG
        Serial.print("intCom1StandbyMhz - ");
        Serial.print(intCom1StandbyMhz);
        Serial.print(".");
        Serial.println(intCom1StandbyKhz);
    #endif 
        break;
    
      case 'f':  //  f   Com2 Radio Frequency
        // Reset the values to 0
        intCom2FreqMhz = 0;
        intCom2FreqKhz = 0;
        // Read the Mhz frequency
        intCom2FreqMhz = AddSerialDigitToInteger(Serial.read(), intCom2FreqMhz);
        intCom2FreqMhz = AddSerialDigitToInteger(Serial.read(), intCom2FreqMhz);
        intCom2FreqMhz = AddSerialDigitToInteger(Serial.read(), intCom2FreqMhz);
        // Discard Decimal
        Serial.read();  
        // Read the Khz Frequency
        intCom2FreqKhz = AddSerialDigitToInteger(Serial.read(), intCom2FreqKhz);
        intCom2FreqKhz = AddSerialDigitToInteger(Serial.read(), intCom2FreqKhz);
        intCom2FreqKhz = AddSerialDigitToInteger(Serial.read(), intCom2FreqKhz);
    #ifdef DEBUG
        Serial.print("intCom2FreqMhz - ");
        Serial.print(intCom2FreqMhz);
        Serial.print(".");
        Serial.println(intCom2FreqKhz);
    #endif 
        break;
    
      case 'g':  //  g   Com2 Standby Frequency
        // Reset the values to 0
        intCom2StandbyMhz = 0;
        intCom2StandbyKhz = 0;
        // Read the Mhz frequency
        intCom2StandbyMhz = AddSerialDigitToInteger(Serial.read(), intCom2StandbyMhz);
        intCom2StandbyMhz = AddSerialDigitToInteger(Serial.read(), intCom2StandbyMhz);
        intCom2StandbyMhz = AddSerialDigitToInteger(Serial.read(), intCom2StandbyMhz);
        // Discard Decimal
        Serial.read();  
        // Read the Khz Frequency
        intCom2StandbyKhz = AddSerialDigitToInteger(Serial.read(), intCom2StandbyKhz);
        intCom2StandbyKhz = AddSerialDigitToInteger(Serial.read(), intCom2StandbyKhz);
        intCom2StandbyKhz = AddSerialDigitToInteger(Serial.read(), intCom2StandbyKhz);
    #ifdef DEBUG
        Serial.print("intCom2Standby - ");
        Serial.print(intCom2StandbyMhz);
        Serial.print(".");
        Serial.println(intCom2StandbyKhz);
    #endif 
        break;
    
      case 'h':  //  h   Nav1 Radio Frequency
        // Reset the values to 0
        intNav1FreqMhz = 0;
        intNav1FreqKhz = 0;
        // Read the Mhz frequency
        intNav1FreqMhz = AddSerialDigitToInteger(Serial.read(), intNav1FreqMhz);
        intNav1FreqMhz = AddSerialDigitToInteger(Serial.read(), intNav1FreqMhz);
        intNav1FreqMhz = AddSerialDigitToInteger(Serial.read(), intNav1FreqMhz);
        // Discard Decimal
        Serial.read();  
        // Read the Khz Frequency
        intNav1FreqKhz = AddSerialDigitToInteger(Serial.read(), intNav1FreqKhz);
        intNav1FreqKhz = AddSerialDigitToInteger(Serial.read(), intNav1FreqKhz);
    #ifdef DEBUG
        Serial.print("intNav1Freq - ");
        Serial.print(intNav1FreqMhz);
        Serial.print(".");
        Serial.println(intNav1FreqKhz);
    #endif 
        break;
    
      case 'i':  //  i   Nav1 Standby Frequency
        // Reset the values to 0
        intNav1StandbyMhz = 0;
        intNav1StandbyKhz = 0;
        // Read the Mhz frequency
        intNav1StandbyMhz = AddSerialDigitToInteger(Serial.read(), intNav1StandbyMhz);
        intNav1StandbyMhz = AddSerialDigitToInteger(Serial.read(), intNav1StandbyMhz);
        intNav1StandbyMhz = AddSerialDigitToInteger(Serial.read(), intNav1StandbyMhz);
        // Discard Decimal
        Serial.read();  
        // Read the Khz Frequency
        intNav1StandbyKhz = AddSerialDigitToInteger(Serial.read(), intNav1StandbyKhz);
        intNav1StandbyKhz = AddSerialDigitToInteger(Serial.read(), intNav1StandbyKhz);
    #ifdef DEBUG
        Serial.print("intNav1Standby - ");
        Serial.print(intNav1StandbyMhz);
        Serial.print(".");
        Serial.println(intNav1StandbyKhz);
    #endif 
        break;
    
      case 'j':  //  j   Nav2 Radio Frequency
        // Reset the values to 0
        intNav2FreqMhz = 0;
        intNav2FreqKhz = 0;
        // Read the Mhz frequency
        intNav2FreqMhz = AddSerialDigitToInteger(Serial.read(), intNav2FreqMhz);
        intNav2FreqMhz = AddSerialDigitToInteger(Serial.read(), intNav2FreqMhz);
        intNav2FreqMhz = AddSerialDigitToInteger(Serial.read(), intNav2FreqMhz);
        // Discard Decimal
        Serial.read();  
        // Read the Khz Frequency
        intNav2FreqKhz = AddSerialDigitToInteger(Serial.read(), intNav2FreqKhz);
        intNav2FreqKhz = AddSerialDigitToInteger(Serial.read(), intNav2FreqKhz);
    #ifdef DEBUG
        Serial.print("intNav2Freq - ");
        Serial.print(intNav2FreqMhz);
        Serial.print(".");
        Serial.println(intNav2FreqKhz);
    #endif 
        break;
    
      case 'k':  //  k   Nav2 Standby Frequency
        // Reset the values to 0
        intNav2StandbyMhz = 0;
        intNav2StandbyKhz = 0;
        // Read the Mhz frequency
        intNav2StandbyMhz = AddSerialDigitToInteger(Serial.read(), intNav2StandbyMhz);
        intNav2StandbyMhz = AddSerialDigitToInteger(Serial.read(), intNav2StandbyMhz);
        intNav2StandbyMhz = AddSerialDigitToInteger(Serial.read(), intNav2StandbyMhz);
        // Discard Decimal
        Serial.read();  
        // Read the Khz Frequency
        intNav2StandbyKhz = AddSerialDigitToInteger(Serial.read(), intNav2StandbyKhz);
        intNav2StandbyKhz = AddSerialDigitToInteger(Serial.read(), intNav2StandbyKhz);
    #ifdef DEBUG
        Serial.print("intNav2Standby - ");
        Serial.print(intNav2StandbyMhz);
        Serial.print(".");
        Serial.println(intNav2StandbyKhz);
    #endif 
        break;
    
      case 'l':  //  l   ADF
        intADF = 0;                         
        intADF = AddSerialDigitToInteger(Serial.read(), intADF);
        intADF = AddSerialDigitToInteger(Serial.read(), intADF);
        intADF = AddSerialDigitToInteger(Serial.read(), intADF);
        intADF = AddSerialDigitToInteger(Serial.read(), intADF);
        Serial.read();  // Discard Decimal
        intADF = AddSerialDigitToInteger(Serial.read(), intADF);
    #ifdef DEBUG
        Serial.print("intADF - ");
        Serial.println(intADF);
    #endif 
        break;
    
      case 'm':  //  m   Transponder Code 
        intTransponderCode = 0;             
        intTransponderCode = AddSerialDigitToInteger(Serial.read(), intTransponderCode);
        intTransponderCode = AddSerialDigitToInteger(Serial.read(), intTransponderCode);
        intTransponderCode = AddSerialDigitToInteger(Serial.read(), intTransponderCode);
        intTransponderCode = AddSerialDigitToInteger(Serial.read(), intTransponderCode);
    #ifdef DEBUG
        Serial.print("intTransponderCode - ");
        Serial.println(intTransponderCode);
    #endif 
        break;
    
      case 'n':  //  n   Distance Measurement DME1
        intDME1 = 0;  
        intDME1 = AddSerialDigitToInteger(Serial.read(), intDME1);
        intDME1 = AddSerialDigitToInteger(Serial.read(), intDME1);
        intDME1 = AddSerialDigitToInteger(Serial.read(), intDME1);
        Serial.read();  // Discard Decimal
        intDME1 = AddSerialDigitToInteger(Serial.read(), intDME1);
    #ifdef DEBUG
        Serial.print("intDME1 - ");
        Serial.println(intDME1);
    #endif 
        break;
    
      case 'o':  //  n   Distance Measurement DME2
        intDME2 = 0;  
        intDME2 = AddSerialDigitToInteger(Serial.read(), intDME2);
        intDME2 = AddSerialDigitToInteger(Serial.read(), intDME2);
        intDME2 = AddSerialDigitToInteger(Serial.read(), intDME2);
        Serial.read();  // Discard Decimal
        intDME2 = AddSerialDigitToInteger(Serial.read(), intDME2);
    #ifdef DEBUG
        Serial.print("intDME2 - ");
        Serial.println(intDME2);
    #endif 
        break;
    
      case 'p':  //  p   Auto Pilot Altitude Set
        intAPAltitudeSet = 0;               
        intAPAltitudeSet = AddSerialDigitToInteger(Serial.read(), intAPAltitudeSet);
        intAPAltitudeSet = AddSerialDigitToInteger(Serial.read(), intAPAltitudeSet);
        intAPAltitudeSet = AddSerialDigitToInteger(Serial.read(), intAPAltitudeSet);
        intAPAltitudeSet = AddSerialDigitToInteger(Serial.read(), intAPAltitudeSet);
        intAPAltitudeSet = AddSerialDigitToInteger(Serial.read(), intAPAltitudeSet);
    #ifdef DEBUG
        Serial.print("intAPAltitudeSet - ");
        Serial.println(intAPAltitudeSet);
    #endif 
        break;
    
      case 'q':  //  q   Auto Pilot VerticleSpeedSet
        // Determine if it is a positive number
        intIsPosititve = PositiveOrNegative(Serial.read());
        // Reset Speed to 0
        intAPVerticleSpeedSet = 0;                
        // Read first three charaters
        intAPVerticleSpeedSet = AddSerialDigitToInteger(Serial.read(), intAPVerticleSpeedSet);
        intAPVerticleSpeedSet = AddSerialDigitToInteger(Serial.read(), intAPVerticleSpeedSet);
        intAPVerticleSpeedSet = AddSerialDigitToInteger(Serial.read(), intAPVerticleSpeedSet);
        intAPVerticleSpeedSet = AddSerialDigitToInteger(Serial.read(), intAPVerticleSpeedSet);
        // Make it a negative if required
        if (intIsPosititve == 0)
          intAPVerticleSpeedSet = intAPVerticleSpeedSet - (intAPVerticleSpeedSet * 2);
    #ifdef DEBUG
        Serial.print("intAPVerticleSpeedSet - ");
        Serial.println(intAPVerticleSpeedSet);
    #endif 
        break; 
    
      case 'r':  //  r   Auto Pilot Heading Set
        intAPHeadingSet = 0;                
        intAPHeadingSet = AddSerialDigitToInteger(Serial.read(), intAPHeadingSet);
        intAPHeadingSet = AddSerialDigitToInteger(Serial.read(), intAPHeadingSet);
        intAPHeadingSet = AddSerialDigitToInteger(Serial.read(), intAPHeadingSet);
    #ifdef DEBUG
        Serial.print("intAPHeadingSet - ");
        Serial.println(intAPHeadingSet);
    #endif 
        break;
    
      case 's':  //  s   Auto Pilot Altitude Lock Active
        intAPAltitudeLockActive = 0;        
        intAPAltitudeLockActive = AddSerialDigitToInteger(Serial.read(), intAPAltitudeLockActive);
    #ifdef DEBUG
        Serial.print("intAPAltitudeLockActive - ");
        Serial.println(intAPAltitudeLockActive);
    #endif 
        break;
    
      case 't':  //  t   Auto Pilot Heading Lock Active
        intAPHeadingLockActive = 0;
        intAPHeadingLockActive = AddSerialDigitToInteger(Serial.read(), intAPHeadingLockActive);
    #ifdef DEBUG
        Serial.print("intAPHeadingLockActive - ");
        Serial.println(intAPHeadingLockActive);
    #endif 
        break;
    
      case 'u':  //  u   Auto Pilot Speed Set (Knots)
        intAPSpeedSet = 0; 
        intAPSpeedSet = AddSerialDigitToInteger(Serial.read(), intAPSpeedSet);
        intAPSpeedSet = AddSerialDigitToInteger(Serial.read(), intAPSpeedSet);
        intAPSpeedSet = AddSerialDigitToInteger(Serial.read(), intAPSpeedSet);
    #ifdef DEBUG
        Serial.print("intAPSpeedSet - ");
        Serial.println(intAPSpeedSet);
    #endif 
        break;
    
      case 'v':  //  v   Auto Pilot Approach Hold Active
        intAPApproachHoldActive = 0;        
        intAPApproachHoldActive = AddSerialDigitToInteger(Serial.read(), intAPApproachHoldActive);
    #ifdef DEBUG
        Serial.print("intAPApproachHoldActive - ");
        Serial.println(intAPApproachHoldActive);
    #endif 
        break;
    
      case 'w':  //  w   Auto Pilot Back Course Active
        intAPBackCourseActive = 0;        
        intAPBackCourseActive = AddSerialDigitToInteger(Serial.read(), intAPBackCourseActive);
    #ifdef DEBUG
        Serial.print("intAPBackCourseActive - ");
        Serial.println(intAPBackCourseActive);
    #endif 
        break;
    
      case 'x':  //  x   Auto Pilot Nav 1 Lock Active
        intAPNav1LockActive = 0;        
        intAPNav1LockActive = AddSerialDigitToInteger(Serial.read(), intAPNav1LockActive);
    #ifdef DEBUG
        Serial.print("intAPNav1LockActive - ");
        Serial.println(intAPNav1LockActive);
    #endif 
        break;
    
      case 'y':  //  y   Auto Pilot Wing Leveler Active
        intAPWingLevelerActive = 0;        
        intAPWingLevelerActive = AddSerialDigitToInteger(Serial.read(), intAPWingLevelerActive);
    #ifdef DEBUG
        Serial.print("intAPWingLevelerActive - ");
        Serial.println(intAPWingLevelerActive);
    #endif 
        break;
    
      case 'z':  //  z   Auto Pilot Flight Director Active
        intAPFlightDirectorActive = 0;        
        intAPFlightDirectorActive = AddSerialDigitToInteger(Serial.read(), intAPFlightDirectorActive);
    #ifdef DEBUG
        Serial.print("intAPFlightDirectorActive - ");
        Serial.println(intAPFlightDirectorActive);
    #endif 
        break;
    
    
        // ***************************** MORE EXTRACTIONS *****************************
    
      case '>':  // This is the Greater Than Symbol Section
        inByte = Serial.read();
        switch (inByte) { 
    
        case 'A':  //  >A  Auto Pilot Mach Set
          intAPMachSet = 0;                  
          intAPMachSet = AddSerialDigitToInteger(Serial.read(), intAPMachSet);
          Serial.read();  // Discard Decimal
          intAPMachSet = AddSerialDigitToInteger(Serial.read(), intAPMachSet);
          intAPMachSet = AddSerialDigitToInteger(Serial.read(), intAPMachSet);
    #ifdef DEBUG
          Serial.print("intAPMachSet - ");
          Serial.println(intAPMachSet);
    #endif 
          break;
    
        case 'B':  //  >B  Auto Pilot Mach Active
          intAPMachActive = 0;            
          intAPMachActive = AddSerialDigitToInteger(Serial.read(), intAPMachActive);
    #ifdef DEBUG
          Serial.print("intAPMachActive - ");
          Serial.println(intAPMachActive);
    #endif 
          break;
    
        case 'C':  //  >C  Auto Pilot Glideslope Hold Active
          intAPGlideslopeHoldActive = 0;
          intAPGlideslopeHoldActive = AddSerialDigitToInteger(Serial.read(), intAPGlideslopeHoldActive);
    #ifdef DEBUG
          Serial.print("intAPGlideslopeHoldActive - ");
          Serial.println(intAPGlideslopeHoldActive);
    #endif 
          break;
    
        case 'D':  //  >D  Auto Pilot Airspeed Hold Active
          intAPAirspeedHoldActive = 0;        
          intAPAirspeedHoldActive = AddSerialDigitToInteger(Serial.read(), intAPAirspeedHoldActive);
    #ifdef DEBUG
          Serial.print("intAPAirspeedHoldActive - ");
          Serial.println(intAPAirspeedHoldActive);
    #endif 
          break;
    
        case 'E':  //  >E  Auto Pilot Autothrottle Armed
          intAPAutothrottleArmed = 0;         
          intAPAutothrottleArmed = AddSerialDigitToInteger(Serial.read(), intAPAutothrottleArmed);
    #ifdef DEBUG
          Serial.print("intAPAutothrottleArmed - ");
          Serial.println(intAPAutothrottleArmed);
    #endif 
          break;
    
        case 'F':  //  >F  Auto Pilot Takeoff Power Active
          intAPTakeoffPowerActive = 0;         
          intAPTakeoffPowerActive = AddSerialDigitToInteger(Serial.read(), intAPTakeoffPowerActive);
    #ifdef DEBUG
          Serial.print("intAPTakeoffPowerActive - ");
          Serial.println(intAPTakeoffPowerActive);
    #endif 
          break;
    
        case 'G':  //  >G  Auto Pilot Autothrottle Active
          intAPAutothrottleActive = 0;        
          intAPAutothrottleActive = AddSerialDigitToInteger(Serial.read(), intAPAutothrottleActive);
    #ifdef DEBUG
          Serial.print("intAPAutothrottleActive - ");
          Serial.println(intAPAutothrottleActive);
    #endif 
          break;
    
        case 'H':  //  >H  Pitot Heat On
          intPitotHeatOn = 0;      
          intPitotHeatOn = AddSerialDigitToInteger(Serial.read(), intPitotHeatOn);
    #ifdef DEBUG
          Serial.print("intPitotHeatOn - ");
          Serial.println(intPitotHeatOn);
    #endif 
          break;
    
        case 'I':  //  >I  No Smoking Sign (FSX)
          intNoSmokingSign = 0;     
          intNoSmokingSign = AddSerialDigitToInteger(Serial.read(), intNoSmokingSign);
    #ifdef DEBUG
          Serial.print("intNoSmokingSign - ");
          Serial.println(intNoSmokingSign);
    #endif 
          break;
    
        case 'J':  //  >J  Seatbelt Sign (FSX Only)
          intSeatbeltSign = 0;        
          intSeatbeltSign = AddSerialDigitToInteger(Serial.read(), intSeatbeltSign);
    #ifdef DEBUG
          Serial.print("intSeatbeltSign - ");
          Serial.println(intSeatbeltSign);
    #endif 
          break;
    
        case 'K':  //  >K  Light State (Mask)
          intLightState = 0;                  
          intLightState = AddSerialDigitToInteger(Serial.read(), intLightState);
          intLightState = AddSerialDigitToInteger(Serial.read(), intLightState);
          intLightState = AddSerialDigitToInteger(Serial.read(), intLightState);
          intLightState = AddSerialDigitToInteger(Serial.read(), intLightState);
    #ifdef DEBUG
          Serial.print("intLightState - ");
          Serial.println(intLightState);
    #endif 
          break;
    
        case 'L':  //  >L  Avionics Master Switch
          intAvionicsMasterSwitch = 0;        
          intAvionicsMasterSwitch = AddSerialDigitToInteger(Serial.read(), intAvionicsMasterSwitch);
    #ifdef DEBUG
          Serial.print("intAvionicsMasterSwitch - ");
          Serial.println(intAvionicsMasterSwitch);
    #endif 
          break;
    
        case 'M':  //  >M  HSI CDI Needle Position
          // Determine if it is a positive number
          intIsPosititve = PositiveOrNegative(Serial.read());
          // Reset to 0
          intHSICDINeedlePosition = 0;                
          // Read first three charaters
          intHSICDINeedlePosition = AddSerialDigitToInteger(Serial.read(), intHSICDINeedlePosition);
          intHSICDINeedlePosition = AddSerialDigitToInteger(Serial.read(), intHSICDINeedlePosition);
          intHSICDINeedlePosition = AddSerialDigitToInteger(Serial.read(), intHSICDINeedlePosition);
          // Make it a negative if required
          if (intIsPosititve == 0)
            intHSICDINeedlePosition = intHSICDINeedlePosition - (intHSICDINeedlePosition * 2);
    #ifdef DEBUG
          Serial.print("intHSICDINeedlePosition - ");
          Serial.println(intHSICDINeedlePosition);
    #endif 
          break; 
    
        case 'N':  //  >N  HSI GSI Needle Position
          // Determine if it is a positive number
          intIsPosititve = PositiveOrNegative(Serial.read());
          // Reset to 0
          intHSIGSINeedlePosition = 0;                
          // Read first three charaters
          intHSIGSINeedlePosition = AddSerialDigitToInteger(Serial.read(), intHSIGSINeedlePosition);
          intHSIGSINeedlePosition = AddSerialDigitToInteger(Serial.read(), intHSIGSINeedlePosition);
          intHSIGSINeedlePosition = AddSerialDigitToInteger(Serial.read(), intHSIGSINeedlePosition);
          // Make it a negative if required
          if (intIsPosititve == 0)
            intHSIGSINeedlePosition = intHSIGSINeedlePosition - (intHSIGSINeedlePosition * 2);
    #ifdef DEBUG
          Serial.print("intHSIGSINeedlePosition - ");
          Serial.println(intHSIGSINeedlePosition);
    #endif 
          break; 
    
        case 'O':    //  >O  Inner Marker
          intInnerMarker = 0;           
          intInnerMarker = AddSerialDigitToInteger(Serial.read(), intInnerMarker);
    #ifdef DEBUG
          Serial.print("intInnerMarker - ");
          Serial.println(intInnerMarker);
    #endif 
          break;
    
        case 'P':    //  >P  Middle Marker
          intMiddleMarker = 0;           
          intMiddleMarker = AddSerialDigitToInteger(Serial.read(), intMiddleMarker);
    #ifdef DEBUG
          Serial.print("intMiddleMarker - ");
          Serial.println(intMiddleMarker);
    #endif 
          break;
    
        case 'Q':    //  >Q  Outer Marker
          intOuterMarker = 0;           
          intOuterMarker = AddSerialDigitToInteger(Serial.read(), intOuterMarker);
    #ifdef DEBUG
          Serial.print("intOuterMarker - ");
          Serial.println(intOuterMarker);
    #endif 
          break;
    
        case 'R':    //  >R  Nav 1 Sound
          intNav1Sound = 0;           
          intNav1Sound = AddSerialDigitToInteger(Serial.read(), intNav1Sound);
    #ifdef DEBUG
          Serial.print("intNav1Sound - ");
          Serial.println(intNav1Sound);
    #endif 
          break;
    
        case 'S':    //  >S  Nav 2 Sound
          intNav2Sound = 0;           
          intNav2Sound = AddSerialDigitToInteger(Serial.read(), intNav2Sound);
    #ifdef DEBUG
          Serial.print("intNav2Sound - ");
          Serial.println(intNav2Sound);
    #endif 
          break;
    
        case 'T':    //  >T  DME Sound
          intDMESound = 0;           
          intDMESound = AddSerialDigitToInteger(Serial.read(), intDMESound);
    #ifdef DEBUG
          Serial.print("intDMESound - ");
          Serial.println(intDMESound);
    #endif 
          break;
    
        case 'U':    //  >U  ADF Sound 0
          intADFSound0 = 0;           
          intADFSound0 = AddSerialDigitToInteger(Serial.read(), intADFSound0);
    #ifdef DEBUG
          Serial.print("intADFSound0 - ");
          Serial.println(intADFSound0);
    #endif 
          break;
    
        case 'V':    //  >V  ADF Sound 1
          intADFSound1 = 0;           
          intADFSound1 = AddSerialDigitToInteger(Serial.read(), intADFSound1);
    #ifdef DEBUG
          Serial.print("intADFSound1 - ");
          Serial.println(intADFSound1);
    #endif 
          break;
    
        case 'W':    //  >W  Marker Sound
          intMarkerSound = 0;           
          intMarkerSound = AddSerialDigitToInteger(Serial.read(), intMarkerSound);
    #ifdef DEBUG
          Serial.print("intMarkerSound - ");
          Serial.println(intMarkerSound);
    #endif 
          break;
    
        case 'X':    //  >X  Com 1 Sound
          intCom1Sound = 0;           
          intCom1Sound = AddSerialDigitToInteger(Serial.read(), intCom1Sound);
    #ifdef DEBUG
          Serial.print("intCom1Sound - ");
          Serial.println(intCom1Sound);
    #endif 
          break;
    
        case 'Y':    //  >Y  Com 2 Sound
          intCom2Sound = 0;           
          intCom2Sound = AddSerialDigitToInteger(Serial.read(), intCom2Sound);
    #ifdef DEBUG
          Serial.print("intCom2Sound - ");
          Serial.println(intCom2Sound);
    #endif 
          break;
    
        case 'Z':    //  >Z  Com All Sound
          intComAllSound = 0;           
          intComAllSound = AddSerialDigitToInteger(Serial.read(), intComAllSound);
    #ifdef DEBUG
          Serial.print("intComAllSound - ");
          Serial.println(intComAllSound);
    #endif 
          break;
    
        case 'a':    //  >a  Fuel Gallons Left Tank
          intFuelGallonsLeft = 0;             
          intFuelGallonsLeft = AddSerialDigitToInteger(Serial.read(), intFuelGallonsLeft);
          intFuelGallonsLeft = AddSerialDigitToInteger(Serial.read(), intFuelGallonsLeft);
          intFuelGallonsLeft = AddSerialDigitToInteger(Serial.read(), intFuelGallonsLeft);
          intFuelGallonsLeft = AddSerialDigitToInteger(Serial.read(), intFuelGallonsLeft);
    #ifdef DEBUG
          Serial.print("intFuelGallonsLeft - ");
          Serial.println(intFuelGallonsLeft);
    #endif 
          break;
    
        case 'b':    //  >b  Fuel Gallons Center Tank
          intFuelGallonsCenter = 0;             
          intFuelGallonsCenter = AddSerialDigitToInteger(Serial.read(), intFuelGallonsCenter);
          intFuelGallonsCenter = AddSerialDigitToInteger(Serial.read(), intFuelGallonsCenter);
          intFuelGallonsCenter = AddSerialDigitToInteger(Serial.read(), intFuelGallonsCenter);
          intFuelGallonsCenter = AddSerialDigitToInteger(Serial.read(), intFuelGallonsCenter);
    #ifdef DEBUG
          Serial.print("intFuelGallonsCenter - ");
          Serial.println(intFuelGallonsCenter);
    #endif 
          break;
    
        case 'c':    //  >c  Fuel Gallons Right Tank
          intFuelGallonsRight = 0;             
          intFuelGallonsRight = AddSerialDigitToInteger(Serial.read(), intFuelGallonsRight);
          intFuelGallonsRight = AddSerialDigitToInteger(Serial.read(), intFuelGallonsRight);
          intFuelGallonsRight = AddSerialDigitToInteger(Serial.read(), intFuelGallonsRight);
          intFuelGallonsRight = AddSerialDigitToInteger(Serial.read(), intFuelGallonsRight);
    #ifdef DEBUG
          Serial.print("intFuelGallonsRight - ");
          Serial.println(intFuelGallonsRight);
    #endif 
          break;
    
        case 'd':   //  >d  Angle Of Attack
          intAngleOfAttack = 0;    
          intAngleOfAttack = AddSerialDigitToInteger(Serial.read(), intAngleOfAttack);
    #ifdef DEBUG
          Serial.print("intAngleOfAttack - ");
          Serial.println(intAngleOfAttack);
    #endif 
          break;
    
        case 'e':  //  >e  Starter Engine 1 Position
          intStarterEngine1Position = 0;  
          intStarterEngine1Position = AddSerialDigitToInteger(Serial.read(), intStarterEngine1Position);
    #ifdef DEBUG
          Serial.print("intStarterEngine1Position - ");
          Serial.println(intStarterEngine1Position);
    #endif 
          break;
    
        case 'f':  //  >f  Starter Engine 2 Position
          intStarterEngine2Position = 0;  
          intStarterEngine2Position = AddSerialDigitToInteger(Serial.read(), intStarterEngine2Position);
    #ifdef DEBUG
          Serial.print("intStarterEngine2Position - ");
          Serial.println(intStarterEngine2Position);
    #endif 
          break;

  8. #8
    25+ Posting Member
    Join Date
    Jun 2012
    Location
    Canada
    Posts
    34
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: Baud Rate - What's too fast?

    Part C

    Code:
        case 'g':  //  >g  Throttle 1 Position
          // Determine if it is a positive number
          intIsPosititve = PositiveOrNegative(Serial.read());
          // Reset to 0
          intThrottle1Position = 0;                
          // Read first three charaters
          intThrottle1Position = AddSerialDigitToInteger(Serial.read(), intThrottle1Position);
          intThrottle1Position = AddSerialDigitToInteger(Serial.read(), intThrottle1Position);
          intThrottle1Position = AddSerialDigitToInteger(Serial.read(), intThrottle1Position);
          // Make it a negative if required
          if (intIsPosititve == 0)
            intThrottle1Position = intThrottle1Position - (intThrottle1Position * 2);
    #ifdef DEBUG
          Serial.print("intThrottle1Position - ");
          Serial.println(intThrottle1Position);
    #endif 
          break; 
    
        case 'h':  //  >h  Throttle 2 Position
          // Determine if it is a positive number
          intIsPosititve = PositiveOrNegative(Serial.read());
          // Reset to 0
          intThrottle2Position = 0;                
          // Read first three charaters
          intThrottle2Position = AddSerialDigitToInteger(Serial.read(), intThrottle2Position);
          intThrottle2Position = AddSerialDigitToInteger(Serial.read(), intThrottle2Position);
          intThrottle2Position = AddSerialDigitToInteger(Serial.read(), intThrottle2Position);
          // Make it a negative if required
          if (intIsPosititve == 0)
            intThrottle2Position = intThrottle2Position - (intThrottle2Position * 2);
    #ifdef DEBUG
          Serial.print("intThrottle2Position - ");
          Serial.println(intThrottle2Position);
    #endif 
          break; 
    
        case 'i':  //  >i  Propellor 1 Position
          intPropellor1Position = 0;  
          intPropellor1Position = AddSerialDigitToInteger(Serial.read(), intPropellor1Position);
          intPropellor1Position = AddSerialDigitToInteger(Serial.read(), intPropellor1Position);
          intPropellor1Position = AddSerialDigitToInteger(Serial.read(), intPropellor1Position);
    #ifdef DEBUG
          Serial.print("intPropellor1Position - ");
          Serial.println(intPropellor1Position);
    #endif 
          break;
    
        case 'j':  //  >j  Propellor 2 Position
          intPropellor2Position = 0;  
          intPropellor2Position = AddSerialDigitToInteger(Serial.read(), intPropellor2Position);
          intPropellor2Position = AddSerialDigitToInteger(Serial.read(), intPropellor2Position);
          intPropellor2Position = AddSerialDigitToInteger(Serial.read(), intPropellor2Position);
    #ifdef DEBUG
          Serial.print("intPropellor2Position - ");
          Serial.println(intPropellor2Position);
    #endif 
          break;
    
        case 'k':  //  >k  Mixture 1 Position
          intMixture1Position = 0;  
          intMixture1Position = AddSerialDigitToInteger(Serial.read(), intMixture1Position);
          intMixture1Position = AddSerialDigitToInteger(Serial.read(), intMixture1Position);
          intMixture1Position = AddSerialDigitToInteger(Serial.read(), intMixture1Position);
    #ifdef DEBUG
          Serial.print("intMixture1Position - ");
          Serial.println(intMixture1Position);
    #endif 
          break;
    
        case 'l':  //  >l  Mixture 2 Position
          intMixture2Position = 0;  
          intMixture2Position = AddSerialDigitToInteger(Serial.read(), intMixture2Position);
          intMixture2Position = AddSerialDigitToInteger(Serial.read(), intMixture2Position);
          intMixture2Position = AddSerialDigitToInteger(Serial.read(), intMixture2Position);
    #ifdef DEBUG
          Serial.print("intMixture2Position - ");
          Serial.println(intMixture2Position);
    #endif 
          break;
    
        case 'm':  //  >m  Spoilers Armed
          intSpoilersArmed = 0;  
          intSpoilersArmed = AddSerialDigitToInteger(Serial.read(), intSpoilersArmed);
    #ifdef DEBUG
          Serial.print("intSpoilersArmed - ");
          Serial.println(intSpoilersArmed);
    #endif 
          break;
    
        case 'n':  //  >n  Spoiler Handle Position
          intSpoilerHandlePosition = 0;  
          intSpoilerHandlePosition = AddSerialDigitToInteger(Serial.read(), intSpoilerHandlePosition);
          intSpoilerHandlePosition = AddSerialDigitToInteger(Serial.read(), intSpoilerHandlePosition);
          intSpoilerHandlePosition = AddSerialDigitToInteger(Serial.read(), intSpoilerHandlePosition);
    #ifdef DEBUG
          Serial.print("intSpoilerHandlePosition - ");
          Serial.println(intSpoilerHandlePosition);
    #endif 
          break;
    
        case 'o':  //  >o  Parking Brake Position
          intParkBrakePosition = 0;  
          intParkBrakePosition = AddSerialDigitToInteger(Serial.read(), intParkBrakePosition);
    #ifdef DEBUG
          Serial.print("intParkBrakePosition - ");
          Serial.println(intParkBrakePosition);
    #endif 
          break;
    
        case 'p':  //  >p  Engine 2 RPM
          intEngine2RPM = 0;  
          intEngine2RPM = AddSerialDigitToInteger(Serial.read(), intEngine2RPM);
          intEngine2RPM = AddSerialDigitToInteger(Serial.read(), intEngine2RPM);
          intEngine2RPM = AddSerialDigitToInteger(Serial.read(), intEngine2RPM);
          intEngine2RPM = AddSerialDigitToInteger(Serial.read(), intEngine2RPM);
          intEngine2RPM = AddSerialDigitToInteger(Serial.read(), intEngine2RPM);
    #ifdef DEBUG
          Serial.print("intEngine2RPM - ");
          Serial.println(intEngine2RPM);
    #endif 
          break;
    
        case 'q':  //  >q  Fuel Pump 1
          intFuelPump1 = 0;  
          intFuelPump1 = AddSerialDigitToInteger(Serial.read(), intFuelPump1);
    #ifdef DEBUG
          Serial.print("intFuelPump1 - ");
          Serial.println(intFuelPump1);
    #endif 
          break;
    
        case 'r':  //  >r  Fuel Pump 2
          intFuelPump2 = 0;  
          intFuelPump2 = AddSerialDigitToInteger(Serial.read(), intFuelPump2);
    #ifdef DEBUG
          Serial.print("intFuelPump2 - ");
          Serial.println(intFuelPump2);
    #endif 
          break;
    
        case 's':  //  >s  Engine 1 Fuel Valve
          intEngine1FuelValve = 0;  
          intEngine1FuelValve = AddSerialDigitToInteger(Serial.read(), intEngine1FuelValve);
    #ifdef DEBUG
          Serial.print("intEngine1FuelValve - ");
          Serial.println(intEngine1FuelValve);
    #endif 
          break;
    
        case 't':  //  >t  Engine 2 Fuel Valve
          intEngine2FuelValve = 0;  
          intEngine2FuelValve = AddSerialDigitToInteger(Serial.read(), intEngine2FuelValve);
    #ifdef DEBUG
          Serial.print("intEngine2FuelValve - ");
          Serial.println(intEngine2FuelValve);
    #endif 
          break;
    
        case 'u':  //  >u  Battery Voltage
          intBatteryVoltage = 0;                  
          intBatteryVoltage = AddSerialDigitToInteger(Serial.read(), intBatteryVoltage);
          intBatteryVoltage = AddSerialDigitToInteger(Serial.read(), intBatteryVoltage);
          Serial.read();  // Discard Decimal
          intBatteryVoltage = AddSerialDigitToInteger(Serial.read(), intBatteryVoltage);
    #ifdef DEBUG
          Serial.print("intBatteryVoltage - ");
          Serial.println(intBatteryVoltage);
    #endif 
          break;
    
        case 'v':  //  >v  Battery Amps
          // Determine if it is a positive number
          intIsPosititve = PositiveOrNegative(Serial.read());
          // Reset to 0
          intBatteryAmps = 0;                
          // Read first three charaters
          intBatteryAmps = AddSerialDigitToInteger(Serial.read(), intBatteryAmps);
          intBatteryAmps = AddSerialDigitToInteger(Serial.read(), intBatteryAmps);
          Serial.read();  // Discard Decimal
          intBatteryAmps = AddSerialDigitToInteger(Serial.read(), intBatteryAmps);
          // Make it a negative if required
          if (intIsPosititve == 0)
            intBatteryAmps = intBatteryAmps - (intBatteryAmps * 2);
    #ifdef DEBUG
          Serial.print("intBatteryAmps - ");
          Serial.println(intBatteryAmps);
    #endif 
          break; 
    
        case 'w':  //  >w  Main Exit Open
          intMainExitOpen = 0;  
          intMainExitOpen = AddSerialDigitToInteger(Serial.read(), intMainExitOpen);
          intMainExitOpen = AddSerialDigitToInteger(Serial.read(), intMainExitOpen);
          intMainExitOpen = AddSerialDigitToInteger(Serial.read(), intMainExitOpen);
    #ifdef DEBUG
          Serial.print("intMainExitOpen - ");
          Serial.println(intMainExitOpen);
    #endif 
          break;
    
        case 'x':  //  >x  Flaps Handle Position
          intFlapsHandlePosition = 0;  
          intFlapsHandlePosition = AddSerialDigitToInteger(Serial.read(), intFlapsHandlePosition);
          intFlapsHandlePosition = AddSerialDigitToInteger(Serial.read(), intFlapsHandlePosition);
          intFlapsHandlePosition = AddSerialDigitToInteger(Serial.read(), intFlapsHandlePosition);
    #ifdef DEBUG
          Serial.print("intFlapsHandlePosition - ");
          Serial.println(intFlapsHandlePosition);
    #endif 
          break;
    
        case 'y':  //  >y  Bus Voltage
          intBusVoltage = 0;                  
          intBusVoltage = AddSerialDigitToInteger(Serial.read(), intBusVoltage);
          intBusVoltage = AddSerialDigitToInteger(Serial.read(), intBusVoltage);
          Serial.read();  // Discard Decimal
          intBusVoltage = AddSerialDigitToInteger(Serial.read(), intBusVoltage);
    #ifdef DEBUG
          Serial.print("intBusVoltage - ");
          Serial.println(intBusVoltage);
    #endif 
          break;
    
        case 'z':  //  >z  Bus Amps
          // Determine if it is a positive number
          intIsPosititve = PositiveOrNegative(Serial.read());
          // Reset to 0
          intBusAmps = 0;                
          // Read first three charaters
          intBusAmps = AddSerialDigitToInteger(Serial.read(), intBusAmps);
          intBusAmps = AddSerialDigitToInteger(Serial.read(), intBusAmps);
          Serial.read();  // Discard Decimal
          intBusAmps = AddSerialDigitToInteger(Serial.read(), intBusAmps);
          // Make it a negative if required
          if (intIsPosititve == 0)
            intBusAmps = intBusAmps - (intBusAmps * 2);
    #ifdef DEBUG
          Serial.print("intBusAmps - ");
          Serial.println(intBusAmps);
    #endif 
          break; 
    
        default:
          // This is the end of the '>' case statement
    #ifdef DEBUG
          Serial.println("Invalid Serial Input Recieved");
    #endif 
          break;
        }
    
    
        // ***************************** MORE EXTRACTIONS *****************************
    
      case '=':  // This is the Equal Sign Section
        inByte = Serial.read();
        switch (inByte) { 
    
        case 'A':  //  =A  GPWS Active (FSX Only)
          intGPWSActive = 0;  
          intGPWSActive = AddSerialDigitToInteger(Serial.read(), intGPWSActive);
    #ifdef DEBUG
          Serial.print("intGPWSActive - ");
          Serial.println(intGPWSActive);
    #endif 
          break;
    
        case 'B':  //  =B  GPS / NAV 1 Active
          intGPSNav1Active = 0;  
          intGPSNav1Active = AddSerialDigitToInteger(Serial.read(), intGPSNav1Active);
    #ifdef DEBUG
          Serial.print("intGPSNav1Active - ");
          Serial.println(intGPSNav1Active);
    #endif 
          break;
    
        default:
          // This is the end of the '>' case statement
    #ifdef DEBUG
          Serial.println("Invalid Serial Input Recieved");
    #endif 
          break;
        }
    
      default:
        // this is the end of the first case statement
    #ifdef DEBUG
        Serial.println("Invalid Serial Input Recieved");
    #endif 
        break;
      }
    
    }
    
    int PositiveOrNegative (int inByte) {
      // This function returns a 1 if it is a positive or a 0 if it is a negative
      switch (inByte) {
      case '+':
        return 1;
        break;
      case '-':
        return 0;
        break;
      }
    }
    
    int AddSerialDigitToInteger (int inByte, int inValue) {
      // This function adds the incoming byte read from the serial port to the incoming value
      // eg byte read is 3 and incoming value is 46 then result is 463
      return ((inValue * 10) + CharToInteger(inByte));
    }
    
    int CharToInteger (int inByte) {
      // This function converts an incoming Char to an actual integer...
      switch (inByte) {
      case '1':    
        return 1;
        break;    
      case '2':    
        return 2;
        break;
      case '3':    
        return 3;
        break;
      case '4':    
        return 4;
        break;
      case '5':    
        return 5;
        break;
      case '6':    
        return 6;
        break;
      case '7':    
        return 7;
        break;
      case '8':    
        return 8;
        break;
      case '9':    
        return 9;
        break;
      default:    
        return 0;
        break;
      }
    }

  9. #9
    150+ Forum Groupie WJH308's Avatar
    Join Date
    Aug 2008
    Location
    San Francisco, CA
    Posts
    159
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: Baud Rate - What's too fast?

    May I ask why are you collecting the data for everything even if your not going to use everything? Not very efficient way of doing things, especially with an 8bit microprocessor.

    In my own opinion, the highest level of reform is simplicity. Keep it simple and things tend to work right.

  10. #10
    25+ Posting Member
    Join Date
    Jun 2012
    Location
    Canada
    Posts
    34
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: Baud Rate - What's too fast?

    While I am not planning on using it all, I figured I could use a good majority. I was also going to share a copy so people could just rip out the code they needed. I haven't found many people sharing their code around here.

    Mostly though, I wanted to stress it as I am a bit concerned about performance if I was to build the solution out. Sometimes while something works well with only one input/output, a complete solution doesn't work so well.

    I was considering building out some slave Arduinos using the I2C protocol which would allow multiple arduinos to talk over a control bus. The Master would handle the Serial to I2C and then each slave would handle it's subset of roles. ie. one for MCP inputs, one or two for MCP Outputs(LEDS/digits), a couple here and there for overhead etc. By using I2C with a single serial master I could limit the number of running copies of Link2FS required as well as the number of Arduinos with USB/Serial interfaces which are more expensive and not sitting in a parts drawer on my workbench but most importantly limit the complexity from that end.

    My biggest challenge has been trying to visualize and end state and an end architecture. Maybe I'm going down the wrong path here.

Page 1 of 3 123 LastLast