Skip to content

K902 USB CDC ACM: spurious NUL byte corrupts first command after port open #213

@jclark

Description

@jclark

When satpulsetool opens /dev/ttyACM1 (SinoGNSS K902 via USB-C) and immediately sends a text command, the receiver sometimes rejects it:

Error! Invalid key word!
^@SET PVTFREQ 1

The ^@ is a NUL byte (0x00) prepended to the command. The receiver's parser sees \x00SET PVTFREQ 1 and rejects it. Retrying the same command immediately always succeeds. Never seen it recur mid-session — it's purely an open-time problem.

Happens maybe 1 in 3 attempts, but hard to reproduce on demand. Happens with different commands (SET PVTFREQ, log versiona, ECUTOFF, etc.).

A 200ms post-open delay before the first write seemed to help (0/20 failures vs ~1/3 without), but 20 attempts isn't conclusive. We also tried clearing HUPCL to prevent DTR toggling on close/reopen, but realized term.Restore() puts the original termios back before close, so the clearing was being undone. After reverting both changes, the problem stopped reproducing entirely (0/100), so neither experiment was conclusive.

Metadata

Metadata

Assignees

No one assigned

    Labels

    gpsRelates to gps subsystem

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions