espsoftwareserial icon indicating copy to clipboard operation
espsoftwareserial copied to clipboard

Use GPIO2 as TX

Open marcootaviomello opened this issue 2 years ago • 1 comments

I need to use the GPIO2 as a TX, I know that it is a stap pin, but a PCB version has already been produced considering it as a TX, by default I know that the lib does not allow use, can someone tell me in the source code where I should comment to remove this restriction?

marcootaviomello avatar Nov 29 '22 18:11 marcootaviomello

Have a look at #251 The test is in bool isValidGPIOpin(int8_t pin);

fanfanlatulipe26 avatar Nov 30 '22 08:11 fanfanlatulipe26

The library will be not reverted to allow the use of official strapping pins, this has been stated in prior issues to the same effect here. The issue can be left pending as a reminder, that perhaps some mechanism to override this restrictive tests could be implemented in a future release.

dok-net avatar Dec 14 '22 21:12 dok-net

Здравствуйте, как с вами связаться?

hemchik avatar Feb 09 '23 07:02 hemchik

I am working on implementing this via template syntax. Bear with me.

dok-net avatar Feb 18 '23 12:02 dok-net

@mcspr any opinion on this from the ESP8266 team?

dok-net avatar Feb 18 '23 23:02 dok-net

In master, there is now the BasicUART class template. By providing a custom implementation for GpioCapabilities, one case permit or restrict the use of any GPIOs, strapping pin or not, etc.

dok-net avatar Mar 05 '23 00:03 dok-net

@fanfanlatulipe26 Hi, I hope you will be glad to hear that your request has now been resolved via C++ template syntax. Here's a little advice on what needs to be done, if you are not completely privy to C++:

The default SoftwareSerial class is now a template class, aliased from BasicUART< GpioCapabilities >. Your mission, if you accept it, is to provide a duck typed implementation of IGpioCapabilities, possibly with no checks at all that the given GPIOs conform to the requested capabilities. Say you name that instance class UncheckedGpioCapabilities. You would do that in your code, no need to change the library sources. Then do this: using PromiscuousUART = BasicUART< UncheckedGpioCapabilities >; And there you go, your new PromiscuousUART will allow you to configure it for any GPIO you wish.

It's in the main branch now, will hopefully soon be released as 8.0.0.

dok-net avatar Mar 05 '23 16:03 dok-net

Thanks for the tips. I really need to learn C++ if I want to understand this code ;-)

fanfanlatulipe26 avatar Mar 06 '23 17:03 fanfanlatulipe26

@fanfanlatulipe26 you might ;-) I hope you'll be able to figure out how to copy, paste and modify to get where you need to be, given my hints from earlier. I'm closing this issue because it's resolved.

dok-net avatar Mar 06 '23 19:03 dok-net