On Mon, Jul 8, 2024 at 11:56 AM Lee <ler...@gmail.com> wrote:
>
> On Sun, Jul 7, 2024 at 8:51 PM Andy Smith wrote:
> >
> > On Sun, Jul 07, 2024 at 06:02:18PM -0400, Lee wrote:
> > > I tried plugging the dongle into my debian laptop but it didn't
> > > recognize it :(
> >
> > In my experience USB serial gadgets on Linux tend to just work or
> > will never work.
>
> It worked this time!
> Other than plugging it into a windows machine that had the proper
> drivers first, I don't know what changed.
>
> > > And what program are you using to talk to something over the serial
> > > link?  pterm or something else?
> >
> > I use either minicom or GNU Screen. You'll need to know the baud
> > rate that the device expects, though you can just try a few common
> > ones and see what works. e.g.
> >
> > # screen /dev/ttyUSB0 115200
>
> Great!  I had to add myself to the dialout group to be able to talk to
> the device, but
> screen /dev/ttyUSB0 38400
> works.

You should also add TIOCEXCL on the file descriptor to ensure
exclusive access to the device. Otherwise, other programs will try to
open the modem and probe it by sending commands to it. It will screw
up your reads on the fd.

    /* NetworkManager and ModemManager will try to open our device */
    /* on occasion. Set TIOCEXCL to ensure we get exclusive access */
    if (ioctl(fd, TIOCEXCL, NULL) == -1) {
        log_warn("Failed to set TIOCEXCL on device: %s\n", strerror(errno));
    }

Jeff

Reply via email to