Fix PinOne DOF output silently dropped on Linux (sp_open return ignored)#53
Closed
dynajoe wants to merge 1 commit into
Closed
Fix PinOne DOF output silently dropped on Linux (sp_open return ignored)#53dynajoe wants to merge 1 commit into
dynajoe wants to merge 1 commit into
Conversation
NamedPipeServer ignored sp_open's return value, and the `if (m_serialPort)`
guard is ineffective on Linux because sp_get_port_by_name does not validate
the device — m_serialPort is non-null for any name, including the class
default "comm1" or a Windows "COMx". So a bad/default port name failed to
open silently and every subsequent write vanished into a dead fd: outputs
dead, inputs fine, no error reported.
Changes:
- Check sp_open's return; on failure log the port name + errno and null
m_serialPort so the existing write guard correctly skips.
- Fix a teardown deadlock: the server thread blocked forever in accept(),
so StopServer()'s join() never returned. Bound accept() with SO_RCVTIMEO
so the loop periodically re-checks m_isRunning.
- Log short/failed serial writes.
Verified against a real PinOne over WSL2 usbipd: sp_open("/dev/ttyACM0")
succeeds and the 9-byte DOF frame reaches the serial fd; a bad port name now
logs a clear diagnostic instead of failing silently.
Collaborator
|
Hello. Thanks for the PR! Converting this to draft as per the contributing rules. (I was behind in getting them added as was just done in Visual Pinball). It's going to take time to review these. libdof is currently is use by several users with a variety of devices, and we have yet to receive issues about this. Also this definitely needs thorough testing with the actual hardware. |
jsm174
marked this pull request as draft
July 5, 2026 18:09
Merged
Contributor
Author
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.
Fix
NamedPipeServerignoredsp_open()'s return value and wrote to the port handle regardless.sp_get_port_by_name()succeeds for any name (including the class defaultcomm1), so theif (m_serialPort)guard never catches a bad port — a failed open left every write hitting a dead handle. Now: checksp_open(), log the error, and null the handle on failure. (Also unblocks the server thread'saccept()on shutdown so teardown doesn't hang.)Why it matters
On Linux the PinOne's outputs are completely dead while inputs work, and nothing is logged — every DOF write is silently dropped. Addresses vpinball/vpinball#2962.
Related
Part of the PinOne-on-Linux cluster surfaced in #31. The teardown half also addresses the
Updater thread did not quit within timeoutseen there — an unclean shutdown that can leave a solenoid powered on.