gpio-netsender: getPinNumber() incorrectly returns error for 1 digit pin numbers

Issue #8 resolved
Jack Richardson created an issue

The input to getPinNumber() strips the leading letter for the pin name: pin, err := getPinNumber(name[1:])

inside however, there is a check to see if the input is of size >= 2:

if len(name) < 2 {
    return -1, errors.New("Invalid pin name")
}

For pins such as A0, gpio-netsender won't initialise as net sender.Init() fails.

We either need to change < 2 to < 1 or not strip leading letter.

Comments (5)

  1. Jack Richardson reporter

    All I can see referring to that is "External pins are "X" followed by 2 or 3 digits" with no standard for other pin types (correct me if I'm wrong). I believe thats the case (despite the example in the doc) however analog pins can be 1 digit as 0-7 is what the MCP3008 library expects.

    We could pad these numbers to 2 digits however I think if we want to assert 2 digits for x pins, we should not drop the letter as we pass the pin to getPinNumber() and do a smarter check for only X pins.

  2. Alan Noble

    Let's deprecate getPinNumber. That exists only because Stavros (of old) used pins with a trailing *. We don't use that any more though.

  3. Log in to comment