{"action":"created","issue":{"url":"https://api.github.com/repos/espressif/arduino-esp32/issues/1607","repository_url":"https://api.github.com/repos/espressif/arduino-esp32","labels_url":"https://api.github.com/repos/espressif/arduino-esp32/issues/1607/labels{/name}","comments_url":"https://api.github.com/repos/espressif/arduino-esp32/issues/1607/comments","events_url":"https://api.github.com/repos/espressif/arduino-esp32/issues/1607/events","html_url":"https://github.com/espressif/arduino-esp32/issues/1607","id":338865460,"node_id":"MDU6SXNzdWUzMzg4NjU0NjA=","number":1607,"title":"'TX' / 'RX' Defns in 'pins_arduino.h' Variant Files Appear Unused","user":{"login":"mrwgx3","id":23343823,"node_id":"MDQ6VXNlcjIzMzQzODIz","avatar_url":"https://avatars2.githubusercontent.com/u/23343823?v=4","gravatar_id":"","url":"https://api.github.com/users/mrwgx3","html_url":"https://github.com/mrwgx3","followers_url":"https://api.github.com/users/mrwgx3/followers","following_url":"https://api.github.com/users/mrwgx3/following{/other_user}","gists_url":"https://api.github.com/users/mrwgx3/gists{/gist_id}","starred_url":"https://api.github.com/users/mrwgx3/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mrwgx3/subscriptions","organizations_url":"https://api.github.com/users/mrwgx3/orgs","repos_url":"https://api.github.com/users/mrwgx3/repos","events_url":"https://api.github.com/users/mrwgx3/events{/privacy}","received_events_url":"https://api.github.com/users/mrwgx3/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-07-06T09:16:05Z","updated_at":"2018-07-08T13:18:41Z","closed_at":null,"author_association":"NONE","body":"### Description\r\n\r\nWhile researching issue (#1577), I noticed that the RX and TX definitions within ['pins_arduino.h' variant file for the Adafruit ESP32 Feather][txrx_feather] were different from all the others defined in the 'variants' folder:\r\n```\r\nstatic const uint8_t TX = 17;    // Esp32 Feather\r\nstatic const uint8_t RX = 16;\r\n```\r\nversus\r\n```\r\nstatic const uint8_t TX = 1;     // All the rest\r\nstatic const uint8_t RX = 3;\r\n```\r\n\r\nThis made me curious on how RX and TX were used, hence I search the ESP32 repository for all their occurances. To my surprise, I found no usage of either TX or RX in any active code, only their definitions in the 'variant' files.\r\n\r\nIf this is confirmed, should the RX/TX pin definitions be depreciated or even removed from the 'pins_arduio.h' variant files?\r\n\r\n[txrx_feather]:\r\nhttps://github.com/espressif/arduino-esp32/blob/master/variants/feather_esp32/pins_arduino.h#L17#L18"},"comment":{"url":"https://api.github.com/repos/espressif/arduino-esp32/issues/comments/403287300","html_url":"https://github.com/espressif/arduino-esp32/issues/1607#issuecomment-403287300","issue_url":"https://api.github.com/repos/espressif/arduino-esp32/issues/1607","id":403287300,"node_id":"MDEyOklzc3VlQ29tbWVudDQwMzI4NzMwMA==","user":{"login":"mrwgx3","id":23343823,"node_id":"MDQ6VXNlcjIzMzQzODIz","avatar_url":"https://avatars2.githubusercontent.com/u/23343823?v=4","gravatar_id":"","url":"https://api.github.com/users/mrwgx3","html_url":"https://github.com/mrwgx3","followers_url":"https://api.github.com/users/mrwgx3/followers","following_url":"https://api.github.com/users/mrwgx3/following{/other_user}","gists_url":"https://api.github.com/users/mrwgx3/gists{/gist_id}","starred_url":"https://api.github.com/users/mrwgx3/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mrwgx3/subscriptions","organizations_url":"https://api.github.com/users/mrwgx3/orgs","repos_url":"https://api.github.com/users/mrwgx3/repos","events_url":"https://api.github.com/users/mrwgx3/events{/privacy}","received_events_url":"https://api.github.com/users/mrwgx3/received_events","type":"User","site_admin":false},"created_at":"2018-07-08T13:18:41Z","updated_at":"2018-07-08T13:18:41Z","author_association":"NONE","body":"@stickbreaker, I propose that the following changes be made to resolve the disconnect between the variant files and ```HardwareSerial.begin()```:\r\n\r\nFor every 'pins_arduino.h' variant file, we replace the RX/TX definition with the following default extended version.\r\n\r\nReplace\r\n```\r\nstatic const uint8_t TX = 1;\r\nstatic const uint8_t RX = 3;\r\n```\r\nwith\r\n```\r\n// Default physical UART / TX pin / RX pin assignments\r\n// UARTA = 0   TXA =  1   RXA =  3\r\n// UARTB = 1   TXB = 10   RXB =  9\r\n// UARTC = 2   TXC = 17   RXC = 16\r\n\r\nstatic const uint8_t UARTA =  0;     // Default 'Serial'\r\nstatic const uint8_t   TXA =  1;\r\nstatic const uint8_t   RXA =  3;\r\n\r\nstatic const uint8_t UARTB =  1;     // Default 'Serial1'\r\nstatic const uint8_t   TXB = 10;\r\nstatic const uint8_t   RXB =  9;\r\n\r\nstatic const uint8_t UARTC =  2;     // Default 'Serial2'\r\nstatic const uint8_t   TXC = 17;\r\nstatic const uint8_t   RXC = 16;\r\n```\r\nNote that the TX/RX definitions paired with each physical UART are the pins required for enhanced digital mode, the same ones used in the original ```HardwareSerial.begin()```.\r\n\r\n\r\nThe following changes are made to ../esp32/cores/esp32/HardwareSerial.cpp\r\n\r\n1) Replace\r\n```\r\n#if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_SERIAL)\r\nHardwareSerial Serial(0);\r\nHardwareSerial Serial1(1);\r\nHardwareSerial Serial2(2);\r\n#endif\r\n```\r\nwith\r\n```\r\n#if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_SERIAL)\r\nHardwareSerial Serial ( UARTA );\r\nHardwareSerial Serial1( UARTB );\r\nHardwareSerial Serial2( UARTC );\r\n#endif\r\n```\r\nto allow pairing of a specific physical UART with a given 'Serial' instance.\r\n\r\n2) Replace the original ```HardwareSerial.begin()```\r\n\r\n```\r\nvoid HardwareSerial::begin(unsigned long baud, uint32_t config, int8_t rxPin, int8_t txPin, bool invert)\r\n{\r\n    if(0 > _uart_nr || _uart_nr > 2) {\r\n        log_e(\"Serial number is invalid, please use 0, 1 or 2\");\r\n        return;\r\n    }\r\n    if(_uart) {\r\n        end();\r\n    }\r\n    if(_uart_nr == 0 && rxPin < 0 && txPin < 0) {\r\n        rxPin = 3;\r\n        txPin = 1;\r\n    }\r\n    if(_uart_nr == 1 && rxPin < 0 && txPin < 0) {\r\n        rxPin = 9;\r\n        txPin = 10;\r\n    }\r\n    if(_uart_nr == 2 && rxPin < 0 && txPin < 0) {\r\n        rxPin = 16;\r\n        txPin = 17;\r\n    }\r\n    _uart = uartBegin(_uart_nr, baud, config, rxPin, txPin, 256, invert);\r\n}\r\n```\r\nwith\r\n```\r\nvoid HardwareSerial::begin(unsigned long baud, uint32_t config, int8_t rxPin, int8_t txPin, bool invert)\r\n{\r\n    if(0 > _uart_nr || _uart_nr > 2) {\r\n        log_e(\"Serial number is invalid, please use 0, 1 or 2\");\r\n        return;\r\n    }\r\n    if(_uart) {\r\n        end();\r\n    }\r\n    if(_uart_nr == UARTA && rxPin < 0 && txPin < 0) {\r\n        rxPin = RXA;\r\n        txPin = TXA;\r\n    }\r\n    if(_uart_nr == UARTB && rxPin < 0 && txPin < 0) {\r\n        rxPin = RXB;\r\n        txPin = TXB;\r\n    }\r\n    if(_uart_nr == UARTC && rxPin < 0 && txPin < 0) {\r\n        rxPin = RXC;\r\n        txPin = TXC;\r\n    }\r\n    _uart = uartBegin(_uart_nr, baud, config, rxPin, txPin, 256, invert);\r\n}\r\n```\r\nto re-connect the symbolic constants in the variant 'pins_arduino.h' files.\r\n\r\n@ladyada, we can now pair the global 'Serial1' instance with physical UART2 within the 'feather_esp32' variant 'pins_arduino.h' file, and no longer need to modify any of the 'Adafruit_GPS' files.\r\n\r\nReplace \r\n```\r\nstatic const uint8_t TX = 17;\r\nstatic const uint8_t RX = 16;\r\n```\r\nwith\r\n```\r\n// Default physical UART / TX pin / RX pin assignments\r\n// UARTA = 0   TXA =  1   RXA =  3\r\n// UARTB = 1   TXB = 10   RXB =  9\r\n// UARTC = 2   TXC = 17   RXC = 16\r\n\r\nstatic const uint8_t UARTA =  0;   // Default 'Serial'\r\nstatic const uint8_t   TXA =  1;\r\nstatic const uint8_t   RXA =  3;\r\n\r\nstatic const uint8_t UARTB =  2;   // Non-default 'Serial1'\r\nstatic const uint8_t   TXB = 17;\r\nstatic const uint8_t   RXB = 16;\r\n\r\nstatic const uint8_t UARTC =  1;   // Non-default 'Serial2'\r\nstatic const uint8_t   TXC = 10;\r\nstatic const uint8_t   RXC =  9;\r\n```\r\n\r\n@me-no-dev, please refer to [Fix TelnetToSerial sketch][fix_tele]\r\n\r\nIf the following changes are accepted, you'll have to revert and modify the original 'Serial1' instance to some unique name then initialize with the long form of ```HardwareSerial.begin()``` in order to insure the original Uart/Pin pairing.\r\n\r\n[fix_tele]:\r\nhttps://github.com/espressif/arduino-esp32/commit/659c8ad528f806c3eba564a671d465c263de4944"}}
{"actor":{"display_login":"mrwgx3"}}