Skip to content
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

fix openlcb velocity 14 28 ss conversions #804

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

bakerstu
Copy link
Owner

@bakerstu bakerstu commented Jan 2, 2025

The conversion math for the 14 and 28 SS "set" methods was inverted for the MPH factor. This pull requests corrects it.

@balazsracz
Copy link
Collaborator

balazsracz commented Jan 2, 2025 via email

@bakerstu
Copy link
Owner Author

bakerstu commented Jan 2, 2025

Why do we actually need these functions? Could we delete them?

That's really up to @atanisoft, as I believe he is using them, and in his application, getting them in "DCC" format might have actually been helpful. I'm open to a different API if it is more useful for @atanisoft.

@atanisoft
Copy link
Collaborator

Why do we actually need these functions?

They are integrated in a number of the DccTrain implementations for generating the DCC speed packets. I'd suggest for now we keep them as it's entirely possible others are using them that we are not aware of.

But if there is a better (newer) API that could replace it we could then shift to that instead and mark these deprecated.

@balazsracz
Copy link
Collaborator

The dcc::Train implementations do not use these functions.
There is a packet generation library: https://github.com/bakerstu/openmrn/blob/master/src/dcc/Packet.cxx#L125
which takes unsigned speed input but is otherwise stateless.

Then there is the dcc::Train implementation which uses that to render actual packets based on state: https://github.com/bakerstu/openmrn/blob/master/src/dcc/Loco.hxx#L478 and https://github.com/bakerstu/openmrn/blob/master/src/dcc/Loco.cxx#L160

Confusing the stateful and stateless parts in the APIs is what makes the code unnecessarily complicated and difficult to use and test.

@atanisoft
Copy link
Collaborator

The dcc::Train implementations do not use these functions.

Ahh, I stand corrected on that assertion. A very quick scan of all of OpenMRN code shows that these methods are not used internally.

Perhaps we should consider marking these as deprecated and to shift API usage to call mph() with caller code clamping to respective ranges?

@atanisoft
Copy link
Collaborator

I believe he is using them, and in his application, getting them in "DCC" format might have actually been helpful

I was initially using them as it was a convenient way to extract them for sending over to non-LCC CS side of things. But I've reworked that code to not leverage these functions anywhere now. I've added a utility function that consumes a Velocity and outputs a DCC speed byte and a similar function that extracts a raw DCC speed step (0-X where X is dependent on the speed step mode).

I think it would make sense to mark these functions all as deprecated and schedule removal since they are complex and mixing two different data types into a single class. We could shift a utility for conversion to the dcc tree if there is a specific need for it there possibly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants