On Wed, Aug 23, 2023 at 6:20 PM Jeffrey Walton <noloader(a)gmail.com> wrote:
On Wed, Aug 23, 2023 at 5:21 PM Steve Underwood <coppice12(a)gmail.com> wrote:
>
> Has anyone used wireshark while using USB serial ports with Fedora 37?
> As soon as I start wireshark the communication on my serial ports
> breaks. Thinking this might be something to do with wireshark scanning
> for available interfaces, I tried starting wireshark with "wireshark -i
> enp3c0", but it still seems to list all the interfaces, and it still
> messes up my serial communication. I'm sure I was doing things like this
> in 2022 without any trouble.
I have not found myself in your position, so I can't comment on
Wireshark and serial ports.
But I have been in the position of NetworkManager messing with my
serial ports. To work around it in my code, I made the file descriptor
exclusive so NetworkManager could not open it:
/* Open the modem. It will be configured for exclusive use below. */
s_modem = open(device_path, O_RDWR | O_NOCTTY | O_SYNC);
ret = errno;
if (s_modem == -1) {
log_error("Failed to open device %s: %s\n", device_path,
strerror(errno));
s_modem = 0; errno = ret;
goto finished;
}
/* Verify the modem is a terminal we can configure and control */
if (!isatty(s_modem))
{
log_error("Device %s is not a tty\n", device_path);
close(s_modem); s_modem = 0;
ret = errno = ENOTTY;
goto finished;
}
/* Get exclusive access to the modem. */
/* Don't allow NetworkManager and ModemManager access */
if (ioctl(s_modem, TIOCEXCL, NULL) == -1) {
log_warn("Failed to set TIOCEXCL on device: %s\n", strerror(errno));
}
Oh, and I forgot to mention... if I recall correctly (going back
several years)... open() is supposed to use O_EXCL. But I seem to
recall it is silently ignored in this case. Hence the need for the
ioct() and TIOCEXCL to set an exclusive mode.
Jeff