gpio-netsender: getPinNumber() incorrectly returns error for 1 digit pin numbers
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)
-
-
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.
-
Yeah, that's what I saw too. I agree with your last para.
-
Let's deprecate getPinNumber. That exists only because Stavros (of old) used pins with a trailing *. We don't use that any more though.
-
- changed status to resolved
getPinNumber has been removed.
- Log in to comment
The docs actually say that there should be 2 or 3 digits, though just above that give and example with only 1. What does a trailing asterisk mean?