stephendpmurphy / shost

💻 shost - GUI, CLI and static library for connecting to FTDI MPSSE capable devices
MIT License
2 stars 1 forks source link

Fixed: 'Expected an option. Instead got: -c' when using spi #1

Closed NoeelMoeskops closed 2 years ago

NoeelMoeskops commented 2 years ago

Fixed Expected an option. Instead got: -c when using any spi command

old behaviour:

# ./mpsse-cli spi -c 0 -w -l 2 -d 0x40,0x00
Expected an option. Instead got: -c
# ./mpsse-cli spi-c 0 -w -l 2 -d 0x40,0x00 
Invalid arguments given.
# ./mpsse-cli spi -c 0 -w -l 2 -d 0x40,0x00
Expected an option. Instead got: -c
# ./mpsse-cli spi -c 0 -x w -l 2 -d 0x40,0x00
Expected an option. Instead got: -c
# ./mpsse-cli spi -c 0 -x w -l 8 -d 0xDD,0xEE,0xAA,0xDD,0xBB,0xEE,0xEE,0xFF
Expected an option. Instead got: -c
# ./mpsse-cli spi -x w -l 8 -d 0xDD,0xEE,0xAA,0xDD,0xBB,0xEE,0xEE,0xFF 
Expected an option. Instead got: -x
# ./mpsse-cli spi --xfer w -l 8 -d 0xDD,0xEE,0xAA,0xDD,0xBB,0xEE,0xEE,0xFF
Expected an option. Instead got: --xfer
# ./mpsse-cli spi -h
usage: mpsse-cli spi [...option]

new behaviour:

# mpsse-cli spi -c 0 -x w -l 8 -d 0xDD,0xEE,0xAA,0xDD,0xBB,0xEE,0xEE,0xFF
Starting a WRITE on channel 0 with a len of 8 bytes at 100000Hz.
8 bytes written over spi.
stephendpmurphy commented 2 years ago

@NoeelMoeskops I can't reproduce this problem. A couple of the command examples you gave have incorrect options such as -w but on others that have fully correct options, you see a failure when I get a success.

$ ./mpsse-cli spi --xfer w -l 8 -d 0xDD,0xEE,0xAA,0xDD,0xBB,0xEE,0xEE,0xFF
Starting a WRITE on channel 0 with a len of 8 bytes at 100000Hz.
No MPSSE channels available.
0 bytes written over spi.

Here is an example of a clean clone, compile and execution

$ stephen@stephen-razer:/media/stephen/SanDisk/Program Files/personal$ git clone https://github.com/stephendpmurphy/mpsse-cli.git
Cloning into 'mpsse-cli'...
remote: Enumerating objects: 64, done.
remote: Counting objects: 100% (64/64), done.
remote: Compressing objects: 100% (44/44), done.
remote: Total 64 (delta 24), reused 50 (delta 14), pack-reused 0
Unpacking objects: 100% (64/64), 15.85 KiB | 318.00 KiB/s, done.
$ stephen@stephen-razer:/media/stephen/SanDisk/Program Files/personal$ cd mpsse-cli/
$ stephen@stephen-razer:/media/stephen/SanDisk/Program Files/personal/mpsse-cli(main)$ git submodule update --init --recursive
Submodule 'libMPSSE' (https://github.com/stephendpmurphy/libMPSSE.git) registered for path 'libMPSSE'
Cloning into '/media/stephen/SanDisk/Program Files/personal/mpsse-cli/libMPSSE'...
Submodule path 'libMPSSE': checked out 'd62d4a06fcce74160f07aa2cf83b1ff4c61ef08d'
$ stephen@stephen-razer:/media/stephen/SanDisk/Program Files/personal/mpsse-cli(main)$ mkdir build && cd build
$ stephen@stephen-razer:/media/stephen/SanDisk/Program Files/personal/mpsse-cli/build(main)$ cmake -DCMAKE_BUILD_TYPE=Debug ..
-- The C compiler identification is GNU 9.3.0
-- The CXX compiler identification is GNU 9.3.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: /media/stephen/SanDisk/Program Files/personal/mpsse-cli/build
$ stephen@stephen-razer:/media/stephen/SanDisk/Program Files/personal/mpsse-cli/build(main)$ make -j8
[ 11%] Building C object libMPSSE/CMakeFiles/MPSSE.dir/src/ftdi_common.c.o
[ 33%] Building C object libMPSSE/CMakeFiles/MPSSE.dir/src/ftdi_infra.c.o
[ 55%] Building C object libMPSSE/CMakeFiles/MPSSE.dir/src/ftdi_i2c.c.o
[ 55%] Building C object libMPSSE/CMakeFiles/MPSSE.dir/src/ftdi_mid.c.o
[ 55%] Building C object libMPSSE/CMakeFiles/MPSSE.dir/src/ftdi_spi.c.o
[ 66%] Linking C static library ../lib/libMPSSE.a
[ 66%] Built target MPSSE
[ 77%] Building C object CMakeFiles/mpsse-cli.dir/src/spi.c.o
[ 88%] Building C object CMakeFiles/mpsse-cli.dir/src/mpsse-cli.c.o
/media/stephen/SanDisk/Program Files/personal/mpsse-cli/src/mpsse-cli.c: In function ‘printMPSSEchannelInfo’:
/media/stephen/SanDisk/Program Files/personal/mpsse-cli/src/mpsse-cli.c:120:43: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
  120 |             printf("    ftHandle=0x%x\n", (unsigned int)devList.ftHandle); /*is 0 unless open*/
      |                                           ^
[100%] Linking C executable ../output/mpsse-cli
[100%] Built target mpsse-cli
$ stephen@stephen-razer:/media/stephen/SanDisk/Program Files/personal/mpsse-cli/build(main)$ cd ../output/
$ stephen@stephen-razer:/media/stephen/SanDisk/Program Files/personal/mpsse-cli/output(main)$ sudo ./mpsse-cli spi -x w -d 0x00,0x01
Starting a write on channel 0 with a len of 2 bytes at 100000Hz.
No MPSSE channels available.
0 bytes written over spi.
stephendpmurphy commented 2 years ago

@NoeelMoeskops you're change looks fine to me however and seems to still work on my end. Closing.

NoeelMoeskops commented 2 years ago

Great! thanks for merging. Yea I don't really understand the problem. But when debugging it seems that the firstChar was not "-" but instead '0'. I'm usign gcc version 11.2.1 on Fedora 34. And I see from your output that your using version 9.3.0