-
Notifications
You must be signed in to change notification settings - Fork 423
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ESP32 & SAMD - use HardwareSerial instead of SoftwareSerial #39
Conversation
I'm not opposed to the idea, but we need to think about how to integrate it into the interface. You can't use addition argument to specify serial number, |
Yes SAMD are SAMD21 based boards. Right now I've found SoftwareSerial library for Zero (I'm on Platformio and have to install it manually). Maybe the better idea is to use the same approach as with SPI? I mean use pointer to the HardwareSerial object instead of giving some number. What do You think? |
Oh, I didn't check that because I have no module that is using serial. Its getting late here, will try tomorrow. |
@beegee-tokyo that's why we have CI ;) see https://travis-ci.org/jgromes/RadioLib/jobs/582051150 I agree with @Pablo2048's idea, we can just let the user create the HardwareSerial object, then just pass the pointer. Just a thought - would this be compatible with AVR Arduino's |
Well, I'm using this in SAMD sketch |
Last comment before I fall asleep (it's past midnight here). To be honest, I am selfish and I just want to get rid of the SoftwareSerial requirement for ESP32. Because Arduino-ESP32 framework doesn't have SoftwareSerial and the maintainers are very reluctant to add it because the ESP32 has 3 hardware serials and they don't see the need to add it (I agree with them). |
3894cd4
to
de01242
Compare
I tried a similar approach with changed constructors for the modules that use Serial connection. But that would break compatibility for the users that implemented this library on SAMD before with a SoftwareSerial. But at least AVR users would have no problems. And for ESP32 it could still work in most cases, because you can assign RX and TX pins to nearly any GPIO, so it would just replace the SoftwareSerial with a HardwareSerial Serial1 on that pins. I could not find a way to implement it without breaking some backward compatibility. Lets see what Travis says 😁 Btw. I am interested in this automatic checking with travis, but never found time to learn about it. I saw the .travis.yml here and it would match with my libraries as well, if I would know how to add the ESP32 environment to it. @jgromes could you help me how to add ESP32 to the tests? |
450efe1
to
5556866
Compare
Try passing |
Also, could you please build these locally before pushing the changes? Just build the same example for ESP32 and Arduino Uno, then you don't have to wait for Travis to build everything, which might speed things up ;) |
Ok, will try this. |
Ok, it builds now locally for Uno, ATMega 2540, Leonardo, ESP8266 and ESP32. However when I try to preset the Lets see what Travis complains now 😴 |
|
Ok, Changed it. Example compiles locally without problems for Uno, ATMega 2540, Leonardo, ESP8266, SAMD21 and ESP32. |
Thanks, I will test it on ESP32 later today (or tomorrow). @Pablo2048, it would be great if you could try it on SAMD boards. |
Here it is running on two ESP32, one connected to a SX1268, the other one to a SX127x. Which of the modules you support have serial connection? I have some modules laying around, maybe I can test the serial connection on an ESP32. |
Sorry guys for late reply - I do have SAMD21 board with some EBYTE modules so I give it a try also... Thank you anyway... |
ESP32 has no working SoftwareSerial. With a simple #ifdef ESP32 || SAMD a hardware serial will be used instead. Minimum changes without influence on existing installations or usage.
I can confirm the serial connection is working on ESP32 + ESP8266 (though there are some issues in my code related to dynamic memory allocation - I will investigate this further). Thanks for this PR, I will merge and add ESP32 section to the Travis build - release to follow shortly. |
I guess this should also work for STM32 based boards. I can try with STM32F103 aka "BluePill" board (as soon as I learn how to manage GitHub repos with arduino libs and stuff like that). PS.: Found this lib on friday and was stuck with SoftwareSerial. Luckily got back on monday :) And BTW you made me to sign up for GitHub, good job guys. |
Thanks, please let me know if it works (please open an issue if it doesn't). Out of curiosity, which module are you planning to use? There's a few ways to get the library, I recommend one of these two:
|
@mmrein But it should be not too difficult to add the STM32 to it. I just cannot do any changes. If you look into the pull-requests changed files you can see where I added processor specific changes, there you will have to add the STM32. |
@jgromes @beegee-tokyo Thanks for the tips, guys. |
OK, I've cloned the repo, added "|| defined (ARDUINO_ARCH_STM32)" after "defined(SAMD_SERIES)" and built successfully. Now I'm having problems with bootloader / drivers, so I can't upload now. Will check on that tomorrow. EDIT: Up and running. I can see: I will have to set up something to Tx/Rx against for physical testing, but is seems to be basically working... I'm surprised! |
ESP32 has no working SoftwareSerial. With a simple #ifdef ESP32 || SAMD a hardware serial will be used instead.
Minimum changes without influence on existing installations or usage.
Hope this time I did a better job.