kersing / packet_forwarder

Multi protocol packet forwarder supporting the TTN gateway-connector protocol.
Other
85 stars 56 forks source link

Does it work with RAK2247 USB Version? #38

Closed chron0 closed 2 years ago

chron0 commented 2 years ago

Hi, thanks for the new stack. I wanted to migrate away from the old udp-forwarder and tried basicstation, but it turned out that it only supports SPI communication and not the SPI over USB versions of the RAK2247 module. Is the same true here?

kersing commented 2 years ago

The software can configured for both SPI and USB. Make sure to configure lora_gateway this depends on to use USB.

chron0 commented 2 years ago

@kersing: great, thanks for the heads up, I'll try to get it to work with special consideration for lora_gateway.

chron0 commented 2 years ago

Alright, after a little while of trying to automate the build in docker I think I am getting somewhere. But i cant really tell if the communication with the module is working and it doesnt seem to connect to TTN:

root@f277fdb70e21:/tmp/packet_forwarder/mp_pkt_fwd# ./mp_pkt_fwd 
17:55:55  *** Multi Protocol Packet Forwarder for Lora Gateway ***
Version: 3.0.26
17:55:55  *** Lora concentrator HAL library version info ***
Version: 5.0.1; Options: ftdi;
***
17:55:55  INFO: Little endian host
17:55:55  INFO: found global configuration file global_conf.json, parsing it
17:55:55  INFO: global_conf.json does not contain a JSON object named frequency_plan
17:55:55  INFO: global_conf.json does contain a JSON object named SX1301_conf, parsing SX1301 parameters
17:55:55  INFO: lorawan_public 1, clksrc 0
17:55:55  INFO: no configuration for LBT
17:55:55  INFO: antenna_gain 0 dBi
17:55:55  INFO: Configuring TX LUT with 16 indexes
17:55:55  INFO: radio 0 enabled (type SX1257), center frequency 867500000, RSSI offset -166.000000, tx enabled 1
17:55:55  INFO: radio 1 enabled (type SX1257), center frequency 868500000, RSSI offset -166.000000, tx enabled 0
17:55:55  INFO: Lora multi-SF channel 0>  radio 1, IF -400000 Hz, 125 kHz bw, SF 7 to 12
17:55:55  INFO: Lora multi-SF channel 1>  radio 1, IF -200000 Hz, 125 kHz bw, SF 7 to 12
17:55:55  INFO: Lora multi-SF channel 2>  radio 1, IF 0 Hz, 125 kHz bw, SF 7 to 12
17:55:55  INFO: Lora multi-SF channel 3>  radio 0, IF -400000 Hz, 125 kHz bw, SF 7 to 12
17:55:55  INFO: Lora multi-SF channel 4>  radio 0, IF -200000 Hz, 125 kHz bw, SF 7 to 12
17:55:55  INFO: Lora multi-SF channel 5>  radio 0, IF 0 Hz, 125 kHz bw, SF 7 to 12
17:55:55  INFO: Lora multi-SF channel 6>  radio 0, IF 200000 Hz, 125 kHz bw, SF 7 to 12
17:55:55  INFO: Lora multi-SF channel 7>  radio 0, IF 400000 Hz, 125 kHz bw, SF 7 to 12
17:55:55  INFO: Lora std channel> radio 1, IF -200000 Hz, 250000 Hz bw, SF 7
17:55:55  INFO: FSK channel> radio 1, IF 300000 Hz, 125000 Hz bw, 50000 bps datarate
17:55:55  INFO: global_conf.json does contain a JSON object named gateway_conf, parsing gateway parameters
17:55:55  INFO: gateway MAC address is configured to AA555A0000000000
17:55:55  INFO: Found 1 servers in array.
17:55:55  INFO: Server 0 configured to "router.eu.thethings.network"
17:55:55  INFO: ghost hostname or IP address is configured to "127.0.0.1"
17:55:55  INFO: ghost port is configured to "1918"
17:55:55  INFO: format is configured to "semtech"
17:55:55  INFO: filename for statistical performance is configured to "stats.txt"
17:55:55  INFO: Damping for statistical info is configured to  50%
17:55:55  INFO: downstream keep-alive interval is configured to 10 seconds
17:55:55  INFO: statistics display interval is configured to 30 seconds
17:55:55  INFO: upstream PUSH_DATA time-out is configured to 100 ms
17:55:55  INFO: packets received with a valid CRC will be forwarded
17:55:55  INFO: packets received with a CRC error will NOT be forwarded
17:55:55  INFO: packets received with no CRC will NOT be forwarded
17:55:55  INFO: GPS serial port path is configured to "/dev/ttyAMA0"
17:55:55  INFO: GPS is disabled
17:55:55  INFO: Upstream data is enabled
17:55:55  INFO: Downstream data is enabled
17:55:55  INFO: Ghoststream data is disabled
17:55:55  INFO: Radiostream data is enabled
17:55:55  INFO: Statusstream data is enabled
17:55:55  INFO: Beacon is disabled
17:55:55  INFO: Packet logger is enabled
17:55:55  INFO: Flush output after statistics is disabled
17:55:55  INFO: Flush after each line of output is disabled
17:55:55  INFO: Watchdog is disabled
17:55:55  INFO: Platform configured to "MultiTech-x86"
17:55:55  INFO: Contact email configured to "operator@gateway.tst"
17:55:55  INFO: Description configured to "Update me"
17:55:55  INFO: found local configuration file local_conf.json, parsing it
17:55:55  INFO: redefined parameters will overwrite global parameters
17:55:55  INFO: local_conf.json does not contain a JSON object named frequency_plan
17:55:55  INFO: local_conf.json does not contain a JSON object named SX1301_conf
17:55:55  INFO: local_conf.json does contain a JSON object named gateway_conf, parsing gateway parameters
17:55:55  INFO: gateway MAC address is configured to 00000000B00BCAFE
17:55:55  INFO: Found 1 servers in array.
17:55:55  INFO: Server 0 configured to "eu1.cloud.thethings.network"
17:55:55  INFO: packets received with a valid CRC will be forwarded
17:55:55  INFO: packets received with a CRC error will NOT be forwarded
17:55:55  INFO: packets received with no CRC will NOT be forwarded
17:55:55  INFO: Reference latitude is configured to 48.000000 deg
17:55:55  INFO: Reference longitude is configured to 11.000000 deg
17:55:55  INFO: Reference altitude is configured to 25 meters
17:55:55  INFO: GPS is enabled
17:55:55  INFO: Using fake GPS coordinates instead of real.
17:55:55  INFO: Upstream data is enabled
17:55:55  INFO: Downstream data is enabled
17:55:55  INFO: Ghoststream data is disabled
17:55:55  INFO: Radiostream data is enabled
17:55:55  INFO: Statusstream data is enabled
17:55:55  INFO: Beacon is disabled
17:55:55  INFO: Packet logger is enabled
17:55:55  INFO: Flush output after statistics is disabled
17:55:55  INFO: Flush after each line of output is disabled
17:55:55  INFO: Watchdog is disabled
17:55:55  INFO: Contact email configured to "ttn@mydomain.org"
17:55:55  INFO: Description configured to "Apollo-NG Test GW"
17:55:55  INFO: [Transports] Initializing protocol for 1 servers
17:55:55  ERROR: [TTN] Connection to server "eu1.cloud.thethings.network" failed, retry in 30 seconds

I've tried setting debug_reg, debug_hal and debug_pkt_fwd but I'm not really getting any more output. I am not sure if I set things in TTN correctly, is serv_gw_key the TTN gw API key? And what is the difference between gateway_ID and serv_gw_id?

This is my local conf:

{    "gateway_conf": {
        "gateway_ID": "b00bcafedeadbeef",
        "contact_email" : "ttn@maydomain.org",
        "description": "Apollo-NG Test GW",
        "servers": [
            {
                "serv_type": "ttn",
                "server_address": "eu1.cloud.thethings.network",
                "serv_gw_id": "b00bcafedeadbeef",
                "serv_gw_key": "NNSXS.ECF5BBXCURLYRHI5FE5B5ONBZUGHIBP57FIDLLA.FLMDYMTI5XRS36JJVCXI6HJIDQZ4HCXCO7GKJVN5XGK6Y7NWJHOQ",
                "serv_enabled": true
            }
        ],
        "gps": true,
        "fake_gps": true,
        "ref_latitude": 48.000,   /* put your latitude here */
        "ref_longitude": 11.000,  /* put your longitude here */
        "ref_altitude": 25
    },
    "debug_pkt_fwd": true,
    "debug_hal": true,
    "debug_reg": true
}

Any more hints/tips?

kersing commented 2 years ago

Check https://github.com/kersing/ttn-resin-gateway-rpi-1 Your server_address needs adding :1881 to it for the port

chron0 commented 2 years ago

ah yes, I worked thru run.py and changed ports and EUI/gw-id accordingly, and the gateway is now able to connect:

root@f277fdb70e21:/tmp/packet_forwarder/mp_pkt_fwd# ./mp_pkt_fwd 
20:02:55  *** Multi Protocol Packet Forwarder for Lora Gateway ***
Version: 3.0.26
20:02:55  *** Lora concentrator HAL library version info ***
Version: 5.0.1; Options: ftdi;
***
20:02:55  INFO: Little endian host
20:02:55  INFO: found global configuration file global_conf.json, parsing it
20:02:55  INFO: global_conf.json does not contain a JSON object named frequency_plan
20:02:55  INFO: global_conf.json does contain a JSON object named SX1301_conf, parsing SX1301 parameters
20:02:55  INFO: lorawan_public 1, clksrc 0
20:02:55  INFO: no configuration for LBT
20:02:55  INFO: antenna_gain 0 dBi
20:02:55  INFO: Configuring TX LUT with 16 indexes
20:02:55  INFO: radio 0 enabled (type SX1257), center frequency 867500000, RSSI offset -166.000000, tx enabled 1
20:02:55  INFO: radio 1 enabled (type SX1257), center frequency 868500000, RSSI offset -166.000000, tx enabled 0
20:02:55  INFO: Lora multi-SF channel 0>  radio 1, IF -400000 Hz, 125 kHz bw, SF 7 to 12
20:02:55  INFO: Lora multi-SF channel 1>  radio 1, IF -200000 Hz, 125 kHz bw, SF 7 to 12
20:02:55  INFO: Lora multi-SF channel 2>  radio 1, IF 0 Hz, 125 kHz bw, SF 7 to 12
20:02:55  INFO: Lora multi-SF channel 3>  radio 0, IF -400000 Hz, 125 kHz bw, SF 7 to 12
20:02:55  INFO: Lora multi-SF channel 4>  radio 0, IF -200000 Hz, 125 kHz bw, SF 7 to 12
20:02:55  INFO: Lora multi-SF channel 5>  radio 0, IF 0 Hz, 125 kHz bw, SF 7 to 12
20:02:55  INFO: Lora multi-SF channel 6>  radio 0, IF 200000 Hz, 125 kHz bw, SF 7 to 12
20:02:55  INFO: Lora multi-SF channel 7>  radio 0, IF 400000 Hz, 125 kHz bw, SF 7 to 12
20:02:55  INFO: Lora std channel> radio 1, IF -200000 Hz, 250000 Hz bw, SF 7
20:02:55  INFO: FSK channel> radio 1, IF 300000 Hz, 125000 Hz bw, 50000 bps datarate
20:02:55  INFO: global_conf.json does not contain a JSON object named gateway_conf
20:02:55  INFO: found local configuration file local_conf.json, parsing it
20:02:55  INFO: redefined parameters will overwrite global parameters
20:02:55  INFO: local_conf.json does not contain a JSON object named frequency_plan
20:02:55  INFO: local_conf.json does not contain a JSON object named SX1301_conf
20:02:55  INFO: local_conf.json does contain a JSON object named gateway_conf, parsing gateway parameters
20:02:55  INFO: gateway MAC address is configured to 057318EC2F67D194
20:02:55  INFO: Found 1 servers in array.
20:02:55  INFO: Server 0 configured to "eu1.cloud.thethings.network"
20:02:55  INFO: packets received with a valid CRC will be forwarded
20:02:55  INFO: packets received with a CRC error will NOT be forwarded
20:02:55  INFO: packets received with no CRC will NOT be forwarded
20:02:55  INFO: Reference latitude is configured to 48.000000 deg
20:02:55  INFO: Reference longitude is configured to 11.000000 deg
20:02:55  INFO: Reference altitude is configured to 25 meters
20:02:55  INFO: GPS is enabled
20:02:55  INFO: Using fake GPS coordinates instead of real.
20:02:55  INFO: Upstream data is enabled
20:02:55  INFO: Downstream data is enabled
20:02:55  INFO: Ghoststream data is disabled
20:02:55  INFO: Radiostream data is enabled
20:02:55  INFO: Statusstream data is enabled
20:02:55  INFO: Beacon is disabled
20:02:55  INFO: Packet logger is enabled
20:02:55  INFO: Flush output after statistics is disabled
20:02:55  INFO: Flush after each line of output is disabled
20:02:55  INFO: Watchdog is disabled
20:02:55  INFO: Contact email configured to "ttn@open-resource.org"
20:02:55  INFO: Description configured to "Apollo-NG Test GW"
20:02:55  INFO: [Transports] Initializing protocol for 1 servers
20:02:56  INFO: [TTN] server "eu1.cloud.thethings.network" connected
20:02:56  INFO: [main] Starting the concentrator
20:02:56  ERROR: [main] failed to start the concentrator

Screenshot_2022-02-21_20-05-25

Now it still doesnt seem to communicate with the RAK2247, I saw the GPIO reset routines in run.py but they dont really apply to USB, do they? I also saw some code that would do that via FTDI, but I dont know if that is the actual issue. Where should I put the debug_reg and debug_hal to get more info about whats going on there? (also, how does it know which /dev/ttyUSB* to use?) - Thank you very much for your assistance!

kersing commented 2 years ago

Tty used is determined based on the VID/PID as specified for lora_gateway/libloragw. Reset should be handled by the code. Test with test_loragw_reg etc, the test tools that are part of lora_gateway/libloragw build. If those do not run successfully the packet forwarder won't either.

chron0 commented 2 years ago

I tried that first, as per notes in lora_gateway, but that was unsuccessful:

root@f277fdb70e21:/tmp/lora_gateway/libloragw# ./test_loragw_reg 
Beginning of test for loragw_reg.c
ERROR: CONCENTRATOR UNCONNECTED
IMPLICIT_PAYLOAD_LENGHT = 0 (should be 197)
FRAME_SYNCH_PEAK2_POS = 0 (should be 11)
PREAMBLE_SYMB1_NB = 0 (should be 49253)
ADJUST_MODEM_START_OFFSET_SF12_RDX4 = 0 (should be 3173)
IF_FREQ_1 = 0 (should be -1947)
End of test for loragw_reg.c

it is a privileged docker container and both ttyUSB0/1 are available in there. The basic same setup works for the udp_forwarder, and without further debugging info I'm at a loss right now...

chron0 commented 2 years ago
[99003.073390] usb 1-6: new high-speed USB device number 10 using xhci_hcd
[99003.200000] usb 1-6: New USB device found, idVendor=0403, idProduct=6010, bcdDevice= 7.00
[99003.200003] usb 1-6: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[99003.200004] usb 1-6: Product: Dual RS232-HS
[99003.200006] usb 1-6: Manufacturer: FTDI
[99003.202163] ftdi_sio 1-6:1.0: FTDI USB Serial Device converter detected
[99003.202176] usb 1-6: Detected FT2232H
[99003.202268] usb 1-6: FTDI USB Serial Device converter now attached to ttyUSB0
[99003.202402] ftdi_sio 1-6:1.1: FTDI USB Serial Device converter detected
[99003.202413] usb 1-6: Detected FT2232H
[99003.202499] usb 1-6: FTDI USB Serial Device converter now attached to ttyUSB1
openat(AT_FDCWD, "/", O_RDONLY|O_NOFOLLOW|O_CLOEXEC|O_PATH) = 6
openat(6, "sys", O_RDONLY|O_NOFOLLOW|O_CLOEXEC|O_PATH) = 7
fstat(7, {st_mode=S_IFDIR|0555, st_size=0, ...}) = 0
close(6)                                = 0
openat(7, "devices", O_RDONLY|O_NOFOLLOW|O_CLOEXEC|O_PATH) = 6
fstat(6, {st_mode=S_IFDIR|0755, st_size=0, ...}) = 0
close(7)                                = 0
openat(6, "pci0000:00", O_RDONLY|O_NOFOLLOW|O_CLOEXEC|O_PATH) = 7
fstat(7, {st_mode=S_IFDIR|0755, st_size=0, ...}) = 0
close(6)                                = 0
openat(7, "0000:00:14.0", O_RDONLY|O_NOFOLLOW|O_CLOEXEC|O_PATH) = 6
fstat(6, {st_mode=S_IFDIR|0755, st_size=0, ...}) = 0
close(7)                                = 0
openat(6, "usb1", O_RDONLY|O_NOFOLLOW|O_CLOEXEC|O_PATH) = 7
fstat(7, {st_mode=S_IFDIR|0755, st_size=0, ...}) = 0
close(6)                                = 0
close(7)                                = 0
access("/sys/devices/pci0000:00/0000:00:14.0/usb1/uevent", F_OK) = 0
openat(AT_FDCWD, "/sys/devices/pci0000:00/0000:00:14.0/usb1/uevent", O_RDONLY|O_CLOEXEC) = 6
fstat(6, {st_mode=S_IFREG|0644, st_size=4096, ...}) = 0
fstat(6, {st_mode=S_IFREG|0644, st_size=4096, ...}) = 0
read(6, "MAJOR=189\nMINOR=0\nDEVNAME=bus/us"..., 4096) = 124
read(6, "", 4096)                       = 0
close(6)                                = 0
getrandom("\x39\x28\x1d\xf7\x51\xe4\xa7\x58\xa1\x2b\x02\xab\x4c\xad\xc9\x31", 16, GRND_NONBLOCK) = 16
getrandom("\x47\x27\x5b\x7a\x9f\x00\x1c\x6f\x35\x0a\x9d\x68\x26\xc0\x29\x55", 16, GRND_NONBLOCK) = 16
openat(AT_FDCWD, "/sys/bus/usb/devices/usb1/busnum", O_RDONLY) = 6
fstat(6, {st_mode=S_IFREG|0444, st_size=4096, ...}) = 0
read(6, "1\n", 4096)                    = 2
close(6)                                = 0
openat(AT_FDCWD, "/sys/bus/usb/devices/usb1/devnum", O_RDONLY) = 6
fstat(6, {st_mode=S_IFREG|0444, st_size=4096, ...}) = 0
read(6, "1\n", 4096)                    = 2
close(6)                                = 0
openat(AT_FDCWD, "/sys/bus/usb/devices/usb1/speed", O_RDONLY) = 6
fstat(6, {st_mode=S_IFREG|0444, st_size=4096, ...}) = 0
read(6, "480\n", 4096)                  = 4
close(6)                                = 0
openat(AT_FDCWD, "/sys/bus/usb/devices/usb1/descriptors", O_RDONLY) = 6
read(6, "\22\1\0\2\t\0\1@k\35\2\0\25\5\3\2\1\1\t\2\31\0\1\1\0\340\0\t\4\0\0\1"..., 1024) = 43
close(6)                                = 0
openat(AT_FDCWD, "/", O_RDONLY|O_NOFOLLOW|O_CLOEXEC|O_PATH) = 6
openat(6, "sys", O_RDONLY|O_NOFOLLOW|O_CLOEXEC|O_PATH) = 7
fstat(7, {st_mode=S_IFDIR|0555, st_size=0, ...}) = 0
close(6)                                = 0
openat(7, "devices", O_RDONLY|O_NOFOLLOW|O_CLOEXEC|O_PATH) = 6
fstat(6, {st_mode=S_IFDIR|0755, st_size=0, ...}) = 0
close(7)                                = 0
openat(6, "pci0000:00", O_RDONLY|O_NOFOLLOW|O_CLOEXEC|O_PATH) = 7
fstat(7, {st_mode=S_IFDIR|0755, st_size=0, ...}) = 0
close(6)                                = 0
openat(7, "0000:00:14.0", O_RDONLY|O_NOFOLLOW|O_CLOEXEC|O_PATH) = 6
fstat(6, {st_mode=S_IFDIR|0755, st_size=0, ...}) = 0
close(7)                                = 0
openat(6, "usb1", O_RDONLY|O_NOFOLLOW|O_CLOEXEC|O_PATH) = 7
fstat(7, {st_mode=S_IFDIR|0755, st_size=0, ...}) = 0
close(6)                                = 0
openat(7, "1-1", O_RDONLY|O_NOFOLLOW|O_CLOEXEC|O_PATH) = 6
fstat(6, {st_mode=S_IFDIR|0755, st_size=0, ...}) = 0
close(7)                                = 0
close(6)                                = 0
access("/sys/devices/pci0000:00/0000:00:14.0/usb1/1-1/uevent", F_OK) = 0
openat(AT_FDCWD, "/sys/devices/pci0000:00/0000:00:14.0/usb1/1-1/uevent", O_RDONLY|O_CLOEXEC) = 6
fstat(6, {st_mode=S_IFREG|0644, st_size=4096, ...}) = 0
fstat(6, {st_mode=S_IFREG|0644, st_size=4096, ...}) = 0
read(6, "MAJOR=189\nMINOR=1\nDEVNAME=bus/us"..., 4096) = 124
read(6, "", 4096)                       = 0
close(6)                                = 0
getrandom("\xc3\xc3\x56\x17\xaf\xf1\xb7\x5d\x93\xda\x3d\x4c\xa6\x89\x47\x7d", 16, GRND_NONBLOCK) = 16
getrandom("\x27\x05\xcf\x42\x9b\x5a\x35\x45\x3b\x6e\x6c\x17\x22\x42\x7d\x58", 16, GRND_NONBLOCK) = 16
openat(AT_FDCWD, "/sys/bus/usb/devices/1-1/busnum", O_RDONLY) = 6
fstat(6, {st_mode=S_IFREG|0444, st_size=4096, ...}) = 0
read(6, "1\n", 4096)                    = 2
close(6)                                = 0
openat(AT_FDCWD, "/sys/bus/usb/devices/1-1/devnum", O_RDONLY) = 6
fstat(6, {st_mode=S_IFREG|0444, st_size=4096, ...}) = 0
read(6, "2\n", 4096)                    = 2
close(6)                                = 0
openat(AT_FDCWD, "/sys/bus/usb/devices/1-1/speed", O_RDONLY) = 6
fstat(6, {st_mode=S_IFREG|0444, st_size=4096, ...}) = 0
read(6, "12\n", 4096)                   = 3
close(6)                                = 0
openat(AT_FDCWD, "/sys/bus/usb/devices/1-1/descriptors", O_RDONLY) = 6
read(6, "\22\1\20\1\0\0\0\20\t\t\34\0\0\1\1\2\0\1\t\2\t\1\4\1\0\2002\t\4\0\0\0"..., 1024) = 283
close(6)                                = 0
openat(AT_FDCWD, "/", O_RDONLY|O_NOFOLLOW|O_CLOEXEC|O_PATH) = 6
openat(6, "sys", O_RDONLY|O_NOFOLLOW|O_CLOEXEC|O_PATH) = 7
fstat(7, {st_mode=S_IFDIR|0555, st_size=0, ...}) = 0
close(6)                                = 0
openat(7, "devices", O_RDONLY|O_NOFOLLOW|O_CLOEXEC|O_PATH) = 6
fstat(6, {st_mode=S_IFDIR|0755, st_size=0, ...}) = 0
close(7)                                = 0
openat(6, "pci0000:00", O_RDONLY|O_NOFOLLOW|O_CLOEXEC|O_PATH) = 7
fstat(7, {st_mode=S_IFDIR|0755, st_size=0, ...}) = 0
close(6)                                = 0
openat(7, "0000:00:14.0", O_RDONLY|O_NOFOLLOW|O_CLOEXEC|O_PATH) = 6
fstat(6, {st_mode=S_IFDIR|0755, st_size=0, ...}) = 0
close(7)                                = 0
openat(6, "usb1", O_RDONLY|O_NOFOLLOW|O_CLOEXEC|O_PATH) = 7
fstat(7, {st_mode=S_IFDIR|0755, st_size=0, ...}) = 0
close(6)                                = 0
openat(7, "1-5", O_RDONLY|O_NOFOLLOW|O_CLOEXEC|O_PATH) = 6
fstat(6, {st_mode=S_IFDIR|0755, st_size=0, ...}) = 0
close(7)                                = 0
close(6)                                = 0
access("/sys/devices/pci0000:00/0000:00:14.0/usb1/1-5/uevent", F_OK) = 0
openat(AT_FDCWD, "/sys/devices/pci0000:00/0000:00:14.0/usb1/1-5/uevent", O_RDONLY|O_CLOEXEC) = 6
fstat(6, {st_mode=S_IFREG|0644, st_size=4096, ...}) = 0
fstat(6, {st_mode=S_IFREG|0644, st_size=4096, ...}) = 0
read(6, "MAJOR=189\nMINOR=2\nDEVNAME=bus/us"..., 4096) = 126
read(6, "", 4096)                       = 0
close(6)                                = 0
getrandom("\x60\xe7\xb8\xde\x5c\xe1\x77\x8b\x49\x2e\xae\x42\x83\x5d\x56\x25", 16, GRND_NONBLOCK) = 16
getrandom("\xc5\x1b\x88\x5c\x9f\xcf\x03\x87\x48\x59\xa9\x49\x01\xb5\xec\xed", 16, GRND_NONBLOCK) = 16
openat(AT_FDCWD, "/sys/bus/usb/devices/1-5/busnum", O_RDONLY) = 6
fstat(6, {st_mode=S_IFREG|0444, st_size=4096, ...}) = 0
read(6, "1\n", 4096)                    = 2
close(6)                                = 0
openat(AT_FDCWD, "/sys/bus/usb/devices/1-5/devnum", O_RDONLY) = 6
fstat(6, {st_mode=S_IFREG|0444, st_size=4096, ...}) = 0
read(6, "3\n", 4096)                    = 2
close(6)                                = 0
openat(AT_FDCWD, "/sys/bus/usb/devices/1-5/speed", O_RDONLY) = 6
fstat(6, {st_mode=S_IFREG|0444, st_size=4096, ...}) = 0
read(6, "12\n", 4096)                   = 3
close(6)                                = 0
openat(AT_FDCWD, "/sys/bus/usb/devices/1-5/descriptors", O_RDONLY) = 6
read(6, "\22\1\1\2\0\0\0\10\217\5@\225 \1\1\2\0\1\t\2]\0\1\1\0\240\31\t\4\0\0\3"..., 1024) = 111
close(6)                                = 0
openat(AT_FDCWD, "/", O_RDONLY|O_NOFOLLOW|O_CLOEXEC|O_PATH) = 6
openat(6, "sys", O_RDONLY|O_NOFOLLOW|O_CLOEXEC|O_PATH) = 7
fstat(7, {st_mode=S_IFDIR|0555, st_size=0, ...}) = 0
close(6)                                = 0
openat(7, "devices", O_RDONLY|O_NOFOLLOW|O_CLOEXEC|O_PATH) = 6
fstat(6, {st_mode=S_IFDIR|0755, st_size=0, ...}) = 0
close(7)                                = 0
openat(6, "pci0000:00", O_RDONLY|O_NOFOLLOW|O_CLOEXEC|O_PATH) = 7
fstat(7, {st_mode=S_IFDIR|0755, st_size=0, ...}) = 0
close(6)                                = 0
openat(7, "0000:00:14.0", O_RDONLY|O_NOFOLLOW|O_CLOEXEC|O_PATH) = 6
fstat(6, {st_mode=S_IFDIR|0755, st_size=0, ...}) = 0
close(7)                                = 0
openat(6, "usb1", O_RDONLY|O_NOFOLLOW|O_CLOEXEC|O_PATH) = 7
fstat(7, {st_mode=S_IFDIR|0755, st_size=0, ...}) = 0
close(6)                                = 0
openat(7, "1-6", O_RDONLY|O_NOFOLLOW|O_CLOEXEC|O_PATH) = 6
fstat(6, {st_mode=S_IFDIR|0755, st_size=0, ...}) = 0
close(7)                                = 0
close(6)                                = 0
access("/sys/devices/pci0000:00/0000:00:14.0/usb1/1-6/uevent", F_OK) = 0
openat(AT_FDCWD, "/sys/devices/pci0000:00/0000:00:14.0/usb1/1-6/uevent", O_RDONLY|O_CLOEXEC) = 6
fstat(6, {st_mode=S_IFREG|0644, st_size=4096, ...}) = 0
fstat(6, {st_mode=S_IFREG|0644, st_size=4096, ...}) = 0
read(6, "MAJOR=189\nMINOR=9\nDEVNAME=bus/us"..., 4096) = 126
read(6, "", 4096)                       = 0
close(6)                                = 0
getrandom("\x47\xc6\xbc\xa0\x7a\x6f\x4b\x3b\x9c\x1e\x57\xb7\xe2\xcc\xe0\x2e", 16, GRND_NONBLOCK) = 16
getrandom("\xeb\x0b\x5e\x02\xfe\xad\xf6\x78\xda\x4e\xe9\x69\x19\x8a\x87\xa4", 16, GRND_NONBLOCK) = 16
openat(AT_FDCWD, "/sys/bus/usb/devices/1-6/busnum", O_RDONLY) = 6
fstat(6, {st_mode=S_IFREG|0444, st_size=4096, ...}) = 0
read(6, "1\n", 4096)                    = 2
close(6)                                = 0
openat(AT_FDCWD, "/sys/bus/usb/devices/1-6/devnum", O_RDONLY) = 6
fstat(6, {st_mode=S_IFREG|0444, st_size=4096, ...}) = 0
read(6, "10\n", 4096)                   = 3
close(6)                                = 0
openat(AT_FDCWD, "/sys/bus/usb/devices/1-6/speed", O_RDONLY) = 6
fstat(6, {st_mode=S_IFREG|0444, st_size=4096, ...}) = 0
read(6, "480\n", 4096)                  = 4
close(6)                                = 0
openat(AT_FDCWD, "/sys/bus/usb/devices/1-6/descriptors", O_RDONLY) = 6
read(6, "\22\1\0\2\0\0\0@\3\4\20`\0\7\1\2\0\1\t\0027\0\2\1\0\200\372\t\4\0\0\2"..., 1024) = 73
close(6)                                = 0
openat(AT_FDCWD, "/", O_RDONLY|O_NOFOLLOW|O_CLOEXEC|O_PATH) = 6
openat(6, "sys", O_RDONLY|O_NOFOLLOW|O_CLOEXEC|O_PATH) = 7
fstat(7, {st_mode=S_IFDIR|0555, st_size=0, ...}) = 0
close(6)                                = 0
openat(7, "devices", O_RDONLY|O_NOFOLLOW|O_CLOEXEC|O_PATH) = 6
fstat(6, {st_mode=S_IFDIR|0755, st_size=0, ...}) = 0
close(7)                                = 0
openat(6, "pci0000:00", O_RDONLY|O_NOFOLLOW|O_CLOEXEC|O_PATH) = 7
fstat(7, {st_mode=S_IFDIR|0755, st_size=0, ...}) = 0
close(6)                                = 0
openat(7, "0000:00:14.0", O_RDONLY|O_NOFOLLOW|O_CLOEXEC|O_PATH) = 6
fstat(6, {st_mode=S_IFDIR|0755, st_size=0, ...}) = 0
close(7)                                = 0
openat(6, "usb1", O_RDONLY|O_NOFOLLOW|O_CLOEXEC|O_PATH) = 7
fstat(7, {st_mode=S_IFDIR|0755, st_size=0, ...}) = 0
close(6)                                = 0
openat(7, "1-7", O_RDONLY|O_NOFOLLOW|O_CLOEXEC|O_PATH) = 6
fstat(6, {st_mode=S_IFDIR|0755, st_size=0, ...}) = 0
close(7)                                = 0
close(6)                                = 0
access("/sys/devices/pci0000:00/0000:00:14.0/usb1/1-7/uevent", F_OK) = 0
openat(AT_FDCWD, "/sys/devices/pci0000:00/0000:00:14.0/usb1/1-7/uevent", O_RDONLY|O_CLOEXEC) = 6
fstat(6, {st_mode=S_IFREG|0644, st_size=4096, ...}) = 0
fstat(6, {st_mode=S_IFREG|0644, st_size=4096, ...}) = 0
read(6, "MAJOR=189\nMINOR=4\nDEVNAME=bus/us"..., 4096) = 127
read(6, "", 4096)                       = 0
close(6)                                = 0
getrandom("\x53\x26\xd6\x52\x0c\xa2\xca\x5d\xc9\x82\xf4\x6c\xa5\x98\xf5\x98", 16, GRND_NONBLOCK) = 16
getrandom("\x7e\x20\x0f\x8d\x9c\xb5\x64\x31\x03\xce\x59\xf9\x1f\x76\x70\x94", 16, GRND_NONBLOCK) = 16
openat(AT_FDCWD, "/sys/bus/usb/devices/1-7/busnum", O_RDONLY) = 6
fstat(6, {st_mode=S_IFREG|0444, st_size=4096, ...}) = 0
read(6, "1\n", 4096)                    = 2
close(6)                                = 0
openat(AT_FDCWD, "/sys/bus/usb/devices/1-7/devnum", O_RDONLY) = 6
fstat(6, {st_mode=S_IFREG|0444, st_size=4096, ...}) = 0
read(6, "5\n", 4096)                    = 2
close(6)                                = 0
openat(AT_FDCWD, "/sys/bus/usb/devices/1-7/speed", O_RDONLY) = 6
fstat(6, {st_mode=S_IFREG|0444, st_size=4096, ...}) = 0
read(6, "12\n", 4096)                   = 3
close(6)                                = 0
openat(AT_FDCWD, "/sys/bus/usb/devices/1-7/descriptors", O_RDONLY) = 6
read(6, "\22\1\0\2\340\1\1@\207\200+\n\20\0\0\0\0\1\t\2\261\0\2\1\0\3402\t\4\0\0\3"..., 1024) = 195
close(6)                                = 0
openat(AT_FDCWD, "/", O_RDONLY|O_NOFOLLOW|O_CLOEXEC|O_PATH) = 6
openat(6, "sys", O_RDONLY|O_NOFOLLOW|O_CLOEXEC|O_PATH) = 7
fstat(7, {st_mode=S_IFDIR|0555, st_size=0, ...}) = 0
close(6)                                = 0
openat(7, "devices", O_RDONLY|O_NOFOLLOW|O_CLOEXEC|O_PATH) = 6
fstat(6, {st_mode=S_IFDIR|0755, st_size=0, ...}) = 0
close(7)                                = 0
openat(6, "pci0000:00", O_RDONLY|O_NOFOLLOW|O_CLOEXEC|O_PATH) = 7
fstat(7, {st_mode=S_IFDIR|0755, st_size=0, ...}) = 0
close(6)                                = 0
openat(7, "0000:00:14.0", O_RDONLY|O_NOFOLLOW|O_CLOEXEC|O_PATH) = 6
fstat(6, {st_mode=S_IFDIR|0755, st_size=0, ...}) = 0
close(7)                                = 0
openat(6, "usb1", O_RDONLY|O_NOFOLLOW|O_CLOEXEC|O_PATH) = 7
fstat(7, {st_mode=S_IFDIR|0755, st_size=0, ...}) = 0
close(6)                                = 0
openat(7, "1-8", O_RDONLY|O_NOFOLLOW|O_CLOEXEC|O_PATH) = 6
fstat(6, {st_mode=S_IFDIR|0755, st_size=0, ...}) = 0
close(7)                                = 0
close(6)                                = 0
access("/sys/devices/pci0000:00/0000:00:14.0/usb1/1-8/uevent", F_OK) = 0
openat(AT_FDCWD, "/sys/devices/pci0000:00/0000:00:14.0/usb1/1-8/uevent", O_RDONLY|O_CLOEXEC) = 6
fstat(6, {st_mode=S_IFREG|0644, st_size=4096, ...}) = 0
fstat(6, {st_mode=S_IFREG|0644, st_size=4096, ...}) = 0
read(6, "MAJOR=189\nMINOR=5\nDEVNAME=bus/us"..., 4096) = 127
read(6, "", 4096)                       = 0
close(6)                                = 0
getrandom("\x2a\xa5\x96\x70\x8b\x65\x44\x4a\xa7\x1c\xdc\x0d\x40\x70\x00\x23", 16, GRND_NONBLOCK) = 16
getrandom("\x7d\x04\xf9\x56\x90\x5b\x23\x60\xc7\xee\x8a\xb3\x3f\xeb\x4e\x93", 16, GRND_NONBLOCK) = 16
openat(AT_FDCWD, "/sys/bus/usb/devices/1-8/busnum", O_RDONLY) = 6
fstat(6, {st_mode=S_IFREG|0444, st_size=4096, ...}) = 0
read(6, "1\n", 4096)                    = 2
close(6)                                = 0
openat(AT_FDCWD, "/sys/bus/usb/devices/1-8/devnum", O_RDONLY) = 6
fstat(6, {st_mode=S_IFREG|0444, st_size=4096, ...}) = 0
read(6, "6\n", 4096)                    = 2
close(6)                                = 0
openat(AT_FDCWD, "/sys/bus/usb/devices/1-8/speed", O_RDONLY) = 6
fstat(6, {st_mode=S_IFREG|0444, st_size=4096, ...}) = 0
read(6, "480\n", 4096)                  = 4
close(6)                                = 0
openat(AT_FDCWD, "/sys/bus/usb/devices/1-8/descriptors", O_RDONLY) = 6
read(6, "\22\1\0\2\357\2\1@\312\4fp\23\0\1\2\0\1\t\2>\4\2\1\0\200\372\10\v\0\2\16"..., 1024) = 1024
read(6, "\t\4\1\7\1\16\2\0\0\7\5\201\5\200\n\1\t\4\1\10\1\16\2\0\0\7\5\201\5 \v\1"..., 1024) = 80
close(6)                                = 0
openat(AT_FDCWD, "/", O_RDONLY|O_NOFOLLOW|O_CLOEXEC|O_PATH) = 6
openat(6, "sys", O_RDONLY|O_NOFOLLOW|O_CLOEXEC|O_PATH) = 7
fstat(7, {st_mode=S_IFDIR|0555, st_size=0, ...}) = 0
close(6)                                = 0
openat(7, "devices", O_RDONLY|O_NOFOLLOW|O_CLOEXEC|O_PATH) = 6
fstat(6, {st_mode=S_IFDIR|0755, st_size=0, ...}) = 0
close(7)                                = 0
openat(6, "pci0000:00", O_RDONLY|O_NOFOLLOW|O_CLOEXEC|O_PATH) = 7
fstat(7, {st_mode=S_IFDIR|0755, st_size=0, ...}) = 0
close(6)                                = 0
openat(7, "0000:00:14.0", O_RDONLY|O_NOFOLLOW|O_CLOEXEC|O_PATH) = 6
fstat(6, {st_mode=S_IFDIR|0755, st_size=0, ...}) = 0
close(7)                                = 0
openat(6, "usb2", O_RDONLY|O_NOFOLLOW|O_CLOEXEC|O_PATH) = 7
fstat(7, {st_mode=S_IFDIR|0755, st_size=0, ...}) = 0
close(6)                                = 0
close(7)                                = 0
access("/sys/devices/pci0000:00/0000:00:14.0/usb2/uevent", F_OK) = 0
openat(AT_FDCWD, "/sys/devices/pci0000:00/0000:00:14.0/usb2/uevent", O_RDONLY|O_CLOEXEC) = 6
fstat(6, {st_mode=S_IFREG|0644, st_size=4096, ...}) = 0
fstat(6, {st_mode=S_IFREG|0644, st_size=4096, ...}) = 0
read(6, "MAJOR=189\nMINOR=128\nDEVNAME=bus/"..., 4096) = 126
read(6, "", 4096)                       = 0
close(6)                                = 0
getrandom("\x7f\xcc\xf9\x78\xd2\x2c\x4a\xde\x9e\xc9\xc9\x9d\x9a\x65\x34\x88", 16, GRND_NONBLOCK) = 16
getrandom("\x3e\xdd\xd5\x42\xe5\x7a\xe1\xb2\x40\x3b\x05\x26\x6f\xc9\x43\xa4", 16, GRND_NONBLOCK) = 16
openat(AT_FDCWD, "/sys/bus/usb/devices/usb2/busnum", O_RDONLY) = 6
fstat(6, {st_mode=S_IFREG|0444, st_size=4096, ...}) = 0
read(6, "2\n", 4096)                    = 2
close(6)                                = 0
openat(AT_FDCWD, "/sys/bus/usb/devices/usb2/devnum", O_RDONLY) = 6
fstat(6, {st_mode=S_IFREG|0444, st_size=4096, ...}) = 0
read(6, "1\n", 4096)                    = 2
close(6)                                = 0
openat(AT_FDCWD, "/sys/bus/usb/devices/usb2/speed", O_RDONLY) = 6
fstat(6, {st_mode=S_IFREG|0444, st_size=4096, ...}) = 0
read(6, "5000\n", 4096)                 = 5
close(6)                                = 0
openat(AT_FDCWD, "/sys/bus/usb/devices/usb2/descriptors", O_RDONLY) = 6
read(6, "\22\1\0\3\t\0\3\tk\35\3\0\25\5\3\2\1\1\t\2\37\0\1\1\0\340\0\t\4\0\0\1"..., 1024) = 49
close(6)                                = 0
pipe([6, 7])                            = 0
fcntl(7, F_GETFL)                       = 0x1 (flags O_WRONLY)
fcntl(7, F_SETFL, O_WRONLY|O_NONBLOCK)  = 0
write(7, "\1", 1)                       = 1
timerfd_create(CLOCK_MONOTONIC, TFD_NONBLOCK) = 8
recvmsg(3, {msg_namelen=128}, 0)        = -1 EAGAIN (Resource temporarily unavailable)
write(1, "ERROR: CONCENTRATOR UNCONNECTED\n", 32ERROR: CONCENTRATOR UNCONNECTED
chron0 commented 2 years ago

perhaps https://github.com/libusb/libusb/issues/1012

kersing commented 2 years ago

Perhaps try and debug outside of Docker first?

chron0 commented 2 years ago

I've rebuilt everything on a pi-star Host I have running here:

root@pi-star(rw):libloragw# ./test_loragw_reg 
Beginning of test for loragw_reg.c
ERROR: CONCENTRATOR UNCONNECTED
IMPLICIT_PAYLOAD_LENGHT = 0 (should be 197)
FRAME_SYNCH_PEAK2_POS = 0 (should be 11)
PREAMBLE_SYMB1_NB = 0 (should be 49253)
ADJUST_MODEM_START_OFFSET_SF12_RDX4 = 0 (should be 3173)
IF_FREQ_1 = 0 (should be -1947)
End of test for loragw_reg.c

same strace result:

openat(AT_FDCWD, "/sys/bus/usb/devices/1-1.4/speed", O_RDONLY|O_CLOEXEC) = 6
fcntl64(6, F_GETFL)                     = 0 (flags O_RDONLY)
fstat64(6, {st_mode=S_IFREG|0444, st_size=4096, ...}) = 0
read(6, "480\n", 4096)                  = 4
close(6)                                = 0
openat(AT_FDCWD, "/sys/bus/usb/devices/1-1.4/descriptors", O_RDONLY|O_CLOEXEC) = 6
read(6, "\22\1\0\2\0\0\0@\3\4\20`\0\7\1\2\0\1\t\0027\0\2\1\0\200\372\t\4\0\0\2"..., 1024) = 73
close(6)                                = 0
pipe2([6, 7], O_CLOEXEC)                = 0
fcntl64(7, F_GETFL)                     = 0x1 (flags O_WRONLY)
fcntl64(7, F_SETFL, O_WRONLY|O_NONBLOCK) = 0
write(7, "\1", 1)                       = 1
timerfd_create(CLOCK_MONOTONIC, TFD_CLOEXEC|TFD_NONBLOCK) = 8
recvmsg(3, {msg_namelen=128}, 0)        = -1 EAGAIN (Resource temporarily unavailable)
write(1, "ERROR: CONCENTRATOR UNCONNECTED\n", 32ERROR: CONCENTRATOR UNCONNECTED
chron0 commented 2 years ago

with debug 1 in rebuild lora_gateway:

root@pi-star(rw):libloragw# ./test_loragw_reg 
Beginning of test for loragw_reg.c
ERROR: MPSSE OPEN FUNCTION FAILED
ERROR CONNECTING CONCENTRATOR
chron0 commented 2 years ago
root@pi-star(rw):libloragw# ./test_loragw_spi 
Beginning of test for loragw_spi.c
ERROR: MPSSE OPEN FUNCTION FAILED
lgw_spi_w:123: ERROR: NULL POINTER AS ARGUMENT
lgw_spi_r:174: ERROR: NULL POINTER AS ARGUMENT
lgw_spi_wb:236: ERROR: NULL POINTER AS ARGUMENT
lgw_spi_rb:317: ERROR: NULL POINTER AS ARGUMENT
lgw_spi_wb:236: ERROR: NULL POINTER AS ARGUMENT
lgw_spi_rb:317: ERROR: NULL POINTER AS ARGUMENT
lgw_spi_r:174: ERROR: NULL POINTER AS ARGUMENT
data received (simple read): 0
lgw_spi_close:104: ERROR: NULL POINTER AS ARGUMENT
End of test for loragw_spi.c
chron0 commented 2 years ago

Just to be sure: which platform should be used for RAK2247 USB in library.cfg?

chron0 commented 2 years ago

after hacking around and using rak831_usb with the correct vid/pid combo a little progress:

root@pi-star(rw):libloragw# ./test_loragw_spi
Beginning of test for loragw_spi.c
lgw_spi_open:92: SPI port opened and configured ok
desc: (null)
PID: 0x6010
VID: 0x0403
clock: 6000000
Libmpsse version: 0x13
WARNING: SPI address > 127
ERROR: SPI WRITE FAILURE
root@pi-star(ro):libloragw# ./test_loragw_reg
Beginning of test for loragw_reg.c
lgw_spi_open:92: SPI port opened and configured ok
desc: (null)
PID: 0x6010
VID: 0x0403
clock: 6000000
Libmpsse version: 0x13
Note: SPI read success
lgw_connect:527: INFO: no FPGA detected or version not supported (v103)
Note: SPI read success
ERROR: SPI WRITE FAILURE

which then also results in:

[27788.368509] ftdi_sio ttyUSB0: FTDI USB Serial Device converter now disconnected from ttyUSB0
[27788.368644] ftdi_sio 1-1.4:1.0: device disconnected