Improving the binding to the Serial object and fix SoftwareSerial bug#20
Conversation
ADD: "lib_dir = ../../../" - this is a dirty hack to make projects use the local library to which they belong (PlatformIO did not have the right option) ADD: special "ifdef" for ESP32 (It is possible to create a universal code for this MC. Maybe I'll do it later.) DEL: "lib_deps = EspSoftwareSerial@>=6.7.1" - this lib integrated to Arduino-ESP8266-framework. See: plerup/espsoftwareserial#200
|
Working: https://www.instagram.com/p/CL91-rrHANP/ (i use two SoftwareSerial - for CO2 sensor and PM5003 sensor. |
|
Looks like the platformio travis integration now uses Python 3.7, it was 2.7 when I set it up. In any case, I updated |
The |
avaldebe
left a comment
There was a problem hiding this comment.
You can add a new constructor SerialPM(PMS sensor, SoftwareSerial &serial) if you think it is necessary,
but please keep the SerialPM(PMS sensor, uint8_t rx, uint8_t tx) constructor.
Fixed on 5e9de28. Please update your branch, so the builds succeed |
|
Work in progress... (see topic) |
…x)` (see: #20 (review)) ADD: manual mode - constructor `SerialPM(PMS sensor)` (work in progress!) UPD: `hwSerial` - change to enum ADD: getter/setter for `uart` variable. (setSerialPort, getSerialPort) UPD: `SerialPM::init()` - updating for manual mode FIX: `SerialPM::trigRead()` - add `#ifdef` for `listen`
Serial object
Serial objectSerial object and fix SoftwareSerial bug
avaldebe
left a comment
There was a problem hiding this comment.
This is a minor gripe, I can add back these comments at a later stage
| framework = arduino | ||
|
|
||
| [env:uno] | ||
| ; ATmega328, 5V/16MHz |
There was a problem hiding this comment.
Please leave the comments like this one, I find them useful to keep track of what each env support
There was a problem hiding this comment.
Unfortunately PlatformIO erases comments when you change a file from GUI. I hope they ever fix this bug.
There was a problem hiding this comment.
I can add back these comments at a later stage
You can use custom fields in environment sections. Just add custom_ prefix.
There was a problem hiding this comment.
Thanks, I'll do that whenever I came around to add the comments back
| board = uno | ||
|
|
||
| [env:mini168_3V3] | ||
| ; ATmega168, 3.3V/8MHz |
| board = pro8MHzatmega168 | ||
|
|
||
| [env:mini328_3V3] | ||
| ; ATmega328, 3.3V/8MHz |
| board = pro8MHzatmega328 | ||
|
|
||
| [env:esp01] | ||
| ; ESP8266, 512kB flash |
| build_flags = -D PMS_RX=2 -D PMS_TX=0 | ||
|
|
||
| [env:d1_mini] | ||
| ; ESP8266, 4096kB flash |
|
Thanks for this PR. I learned something the Atmel AVR C++ compiler and the code got better. Thanks again, |

Consider the following situations:
Serial.init(...)is different (this situation already happened with ESP32).Serialinherited fromStream(such as AltSoftSerial).SoftwareSerial, but responding to a different query format. This configuration is valid, and saving pins - is a common phenomenon. (similar to the situation in Need option to disable sending command to sensor (active_mode option) #5)In the current implementation of the library it is problematic to solve these problems (without modifying the library code).
So I decided to expand PR and add more general mechanisms.
In normal projects, the problem of creating objects is solved through the "factory" pattern, but for MK this is superfluous.
It will take some more time to develop (more examples need to be written) and hopefully everyone will like the result.
Russian:
Рассмотрим следующие ситуации:
Serial.init(...)отличается (такая ситуация уже произошла с ESP32).Serialунаследованную отStream(например AltSoftSerial)..SoftwareSerial, но отвечающий на другой формат запроса. Такая конфигурация валидна, и экономия пинов это обычное явление. (похоже на ситуацию в Need option to disable sending command to sensor (active_mode option) #5)В текущей реализации библиотеки решить эти проблемы (без внесения изменений в код библиотеки) проблематично.
Поэтому я решил расширить PR и добавить более общие механизмы.
В обычных проектах проблему создания объектов решают через патерн "фабрика", но для МК это излишне.
Разработка займет еще некоторое время (нужно написать дополнительные примеры) и надеюсь результат понравится всем.
Changes
Core:
SoftwareSerial bug - #19
Improving the binding to the
Serialobject