You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Why is SoftwareSerial defining ISR for all possible PinChangeInterrupt vectors? Even if not all of them are used, the ISR is registered and prevents others (e.g. other libs) from registering PinChangeInterrupts.
For example. If you use SoftwareSerial on Digital Ports 2 and 3 (Arduino Uno/Nano), it is not possible to specify a PinchangeInterrupt for pin A1. (e.g. by using PinChangeInterrupt library).
Reason is, that SoftwareSerial registers on ISR for all ports. Why? Since SoftwareSerial is some kind of system library, to me this behavior seems wrong.
Wouldn't at least something like the following code snippet be useful? (Would prevent users from including their own hacked SoftwareSerial.cpp, missing new updates...)
This modification would leave all existing projects working, but gives future users the ability to ignore ISR creation if they don't need it explicitly.
Kind regards,
Martin
The text was updated successfully, but these errors were encountered:
Why is SoftwareSerial defining ISR for all possible PinChangeInterrupt vectors? Even if not all of them are used, the ISR is registered and prevents others (e.g. other libs) from registering PinChangeInterrupts.
This is indeed an issue, but tricky to fix, because the pin numbers you run SoftwareSerial on are passed to SoftwareSerial on runtime, while it must be decided at compile/link time whether or not the ISR is included or not. Of course, when you only pass constants to the SoftwareSerial, in theory, the compiler could figure out at compiletime which pins you (might) use and include only the ISRs for that. However, there's no easy way to actually do this in C++, unfortunately (you can use template arguments, but that forces the pin numbers to be compile-time constants, duplicates code, and also is trickier to use).
One way that you can use, is explicitly choosing ISRs using the preprocessor, which is essentially what you also propose. This could work, but is also tricky to use in the current Arduino ecosystem, since there is no real supported way for a sketch to influence the preprocessor (not sure if this is intentional or just lacking a properly usable implementation. There are some open issues about this, I think).
Why is SoftwareSerial defining ISR for all possible PinChangeInterrupt vectors? Even if not all of them are used, the ISR is registered and prevents others (e.g. other libs) from registering PinChangeInterrupts.
For example. If you use SoftwareSerial on Digital Ports 2 and 3 (Arduino Uno/Nano), it is not possible to specify a PinchangeInterrupt for pin A1. (e.g. by using PinChangeInterrupt library).
Reason is, that SoftwareSerial registers on ISR for all ports. Why? Since SoftwareSerial is some kind of system library, to me this behavior seems wrong.
Wouldn't at least something like the following code snippet be useful? (Would prevent users from including their own hacked SoftwareSerial.cpp, missing new updates...)
(originally lines 227-244 in SoftwareSerial.cpp)
This modification would leave all existing projects working, but gives future users the ability to ignore ISR creation if they don't need it explicitly.
Kind regards,
Martin
The text was updated successfully, but these errors were encountered: