Skip to content

Bug when settting Analalog Inputs to digital input or utput. #6

Description

@GoogleCodeExporter
An indexoutofrange exception is raised when setting A5 on Arduino Uno to 
digital input or output.

I've traced the exception and came up with a solution. The problem is caused by 
the Handle(DigitalMessage message) function in EasyFirmata.cs

Modified code that works:

        public void Handle(DigitalMessage message)
        {
            var pinStart = (byte)(8*message.Port);
            for (byte i = 0; i < 8; i++)
            {
               int index = i + pinStart;
               if (index < Pins.Count) Pins[index].CurrentValue = message.PinStates[i] ? 1 : 0;
            }

            OnNewDigitalValue(message.Port,message.PinStates);
        }


Original issue reported on code.google.com by ruzsinszki.gabor on 21 May 2013 at 11:40

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions