Fix Serial pin reassignment on speed change; document LISTEN_ONLY vs emulation wiring#3
Open
jenogc wants to merge 2 commits intoLexOptical:masterfrom
Open
Conversation
In setLowspeedMode() and setHighspeedMode(), calling Serial1.begin() without first calling setRX/setTX could revert to hardware-default pins, causing PIN1 to be used as TX even in LISTEN_ONLY mode (where TX should be routed to the unused PIN5). Fix: explicitly call setRX/setTX before each Serial.begin() call in both speed-change helpers, mirroring the setup() logic. Also update README to clarify that the circuit diagram covers LISTEN_ONLY wiring only, and that non-LISTEN_ONLY (emulation) mode additionally requires PIN1 connected to the LENS7 data line. Fixes LexOptical#1
Contributor
|
@claude I'd also like to pull the pin numbers out into named constants instead of adding more instances of 5 and 9 all over. Can you do that in this PR please |
Add PIN_SERIAL1_RX (0), PIN_SERIAL1_TX_ACTIVE (1), PIN_SERIAL1_TX_LISTEN (5), and PIN_SERIAL2_RX (9) to Constants.h, replacing all raw literals in E-Mount.ino. The three existing control-signal constants (PIN_LENS_CS_BODY, PIN_BODY_CS_LENS, PIN_BODY_VD_LENS) were already named; serial pins now match that convention. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Author
|
@Bostwickenator latest commit addresses your comment above. Thanks for putting this project out there! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1
Problem
Two related issues stemming from the pin-assignment conflict described in #1:
setLowspeedMode()/setHighspeedMode()calledSerial1.begin()without re-applyingsetRX/setTX, which could revert to hardware-default pins on a speed change. InLISTEN_ONLYmode the TX line should be routed to the unused PIN5, but without explicit pin re-assignment it would fall back to PIN1 — the same pin that the emulation mode uses for the lens→body data line.The circuit diagram and README gave no indication that the wiring differs between modes, leaving users to discover the PIN0/PIN1 discrepancy by reading the code.
Changes
E-Mount.inosetLowspeedMode()andsetHighspeedMode(), explicitly callSerial1.setRX(0),Serial1.setTX(LISTEN_ONLY ? 5 : 1), andSerial2.setRX(9)before eachSerial.begin()— mirroring whatsetup()already does.README.md