gusmanb / logicanalyzer

24 channel, 100Msps logic analyzer hardware and software
GNU General Public License v3.0
2.18k stars 239 forks source link

CLCapture netconfig option unable to open specified Serial port - RasPiOS [Debian] linux on Raspberry Pi sbc #135

Open DeeJay opened 1 week ago

DeeJay commented 1 week ago

Release v5.1

OS RasPiOS (Debian-based) Bookworm - arm64

CLCapture netconfig fails to open the serial port named on the command line, even though it is valid.

Providing a symbolic link to a lower-cased version of the device name provides a workaround.

The same behaviour is NOT observed when using the capture sub-command.

{dmesg output concludes... }
[701573.688161] usb 1-2: new full-speed USB device number 69 using xhci-hcd
[701573.859792] usb 1-2: New USB device found, idVendor=2e8a, idProduct=000a, bcdDevice= 1.00
[701573.859798] usb 1-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[701573.859801] usb 1-2: Product: Pico
[701573.859803] usb 1-2: Manufacturer: Raspberry Pi
[701573.859805] usb 1-2: SerialNumber: E6616407E346BC28
[701573.892880] cdc_acm 1-2:1.0: ttyACM0: USB ACM device
david@rp54bw64full0512:~/Projects/GusmanLA/clc/linux-arm64 $ 
david@rp54bw64full0512:~/Projects/GusmanLA/clc/linux-arm64 $ 
david@rp54bw64full0512:~/Projects/GusmanLA/clc/linux-arm64 $ ls -al /dev/ttyACM*
crw-rw----+ 1 root plugdev 166, 0 Sep  8 15:10 /dev/ttyACM0
david@rp54bw64full0512:~/Projects/GusmanLA/clc/linux-arm64 $ 
david@rp54bw64full0512:~/Projects/GusmanLA/clc/linux-arm64 $ 
david@rp54bw64full0512:~/Projects/GusmanLA/clc/linux-arm64 $ 
david@rp54bw64full0512:~/Projects/GusmanLA/clc/linux-arm64 $ 
david@rp54bw64full0512:~/Projects/GusmanLA/clc/linux-arm64 $ 
david@rp54bw64full0512:~/Projects/GusmanLA/clc/linux-arm64 $ ./CLCapture netconfig /dev/ttyACM0 Coniston Passphrase 192.168.1.245 4045
Cannot find specified serial port.
david@rp54bw64full0512:~/Projects/GusmanLA/clc/linux-arm64 $ 
david@rp54bw64full0512:~/Projects/GusmanLA/clc/linux-arm64 $ 
david@rp54bw64full0512:~/Projects/GusmanLA/clc/linux-arm64 $ ./CLCapture netconfig /dev/ttyacm0 Coniston Passphrase 192.168.1.245 4045
Opening logic analyzer in port /dev/ttyacm0...
Error detecting Logic Analyzer in port /dev/ttyacm0
david@rp54bw64full0512:~/Projects/GusmanLA/clc/linux-arm64 $ sudo ln -s  /dev/ttyACM0 /dev/ttyacm0
david@rp54bw64full0512:~/Projects/GusmanLA/clc/linux-arm64 $ 
david@rp54bw64full0512:~/Projects/GusmanLA/clc/linux-arm64 $ 
david@rp54bw64full0512:~/Projects/GusmanLA/clc/linux-arm64 $ ./CLCapture netconfig /dev/ttyacm0 Coniston Passphrase 192.168.1.245 4045
Opening logic analyzer in port /dev/ttyacm0...
Conneced to device LOGIC_ANALYZER_WIFI_V5_1 in port /dev/ttyacm0
Done.

david@rp54bw64full0512:~/Projects/GusmanLA/clc/linux-arm64 $ 

The root cause may be at around line 293 of Software/LogicAnalyzer/CLCapture/Program.cs

int Configure(CLNetworkOptions opts)
{
    var ports = SerialPort.GetPortNames();

    if (!ports.Any(p => p.ToLower() == opts.SerialPort))
    {
        Console.WriteLine("Cannot find specified serial port.");
        return -1;
    }

Debian linux device names have mixed UPPER/lower case - /dev/ttyACM0

Forcing the supplied argument .ToLower() may be the reason why the comparison fails?

gusmanb commented 1 week ago

Yes, you're right, it should be if (!ports.Any(p => p.ToLower() == opts.SerialPort.ToLower())).

Will patch it in the next release.