jgoerzen / lorapipe

Pipe applications and networks over long-range LoRa radios
GNU General Public License v3.0
67 stars 7 forks source link

"Failed to Configure radio" "bad response" #2

Open Bovril1a opened 4 years ago

Bovril1a commented 4 years ago

Hi,

Looking to set up some remote connectivity, working with LORA (2 x LoStik's) via TCP/IP, connecting to two Raspberry Pi's so thought your code would be perfect.

I have complied the Rust code, no errors, the firmware for the LoStik from "sys get ver" is RN2483 1.0.5 Oct 31 2018 15:06:52

When I try to run the code, I have to run it first using sudo

sudo socat EXEC:'pppd nodetach file /etc/ppp/peers/lora,pty,rawer' \ goes to > OK , I then run

EXEC:'./lorapipe --txslot 2000 --initfile=init-fast.txt --maxpacketsize 100 --txwait 120 /dev/ttyUSB0 pipe,pty,rawer'

error message throws as below.

thread 'main' panicked at 'Failed to configure radio: Custom { kind: Other, error: "Bad response from radio during initialization" }', src/main.rs:112:5 note: run with RUST_BACKTRACE=1 environment variable to display a backtrace

Looking at the init-fast.txt the "radio set pwr" statement appears incorrect as the max pwr setting is 15 not 20. as per the init.txt and init-fast.txt both edited and set to 15, same error on run.

Any idea where the problerm may lie..?

jgoerzen commented 4 years ago

Try running with --debug and you should see the exact communication, which should shed some light on it.

Bovril1a commented 4 years ago

Ran with --debug

pi@Pi3_misc:~/lorapipe/target/release $ sudo socat EXEC:'pppd nodetach file /etc/ppp/peers/lora,pty,rawer' \

EXEC:'./lorapipe --debug --txslot 2000 --initfile=init-fast.txt --maxpacketsize 100 --txwait 120 /dev/ttyUSB0 pipe,pty,rawer' 14:04:54 [ INFO] lora starting 14:04:54 [TRACE] (1) lorapipe::ser: [src/ser.rs:72] "/dev/ttyUSB0" SEROUT: INVALIDCOMMAND 14:04:54 [TRACE] (2) lorapipe::ser: [src/ser.rs:65] "/dev/ttyUSB0" SERIN: invalid_param 14:04:55 [DEBUG] (1) lorapipe::lorastik: Configuring radio 14:04:55 [TRACE] (1) lorapipe::ser: [src/ser.rs:72] "/dev/ttyUSB0" SEROUT: sys get ver 14:04:55 [TRACE] (2) lorapipe::ser: [src/ser.rs:65] "/dev/ttyUSB0" SERIN: RN2483 1.0.5 Oct 31 2018 15:06:52 14:04:55 [TRACE] (1) lorapipe::ser: [src/ser.rs:72] "/dev/ttyUSB0" SEROUT: mac reset 14:04:55 [TRACE] (2) lorapipe::ser: [src/ser.rs:65] "/dev/ttyUSB0" SERIN: invalid_param thread 'main' panicked at 'Failed to configure radio: Custom { kind: Other, error: "Bad response from radio during initialization" }', src/main.rs:112:5 note: run with RUST_BACKTRACE=1 environment variable to display a backtrace

I then ran lsusb then ls /dev/ttyU*

pi@Pi3_misc:~/lorapipe/target/release $ lsusb Bus 001 Device 004: ID 1a86:7523 QinHeng Electronics HL-340 USB-Serial adapter Bus 001 Device 005: ID 0424:7800 Standard Microsystems Corp. Bus 001 Device 003: ID 0424:2514 Standard Microsystems Corp. USB 2.0 Hub Bus 001 Device 002: ID 0424:2514 Standard Microsystems Corp. USB 2.0 Hub Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

pi@Pi3_misc:~/lorapipe/target/release $ ls /dev/ttyU* /dev/ttyUSB0

pi@Pi3_misc:~/lorapipe/target/release $

I connected to the Lostik via terminal and ran sys ver RN2483 1.0.5 Oct 31 2018 15:06:52

mac reset invalid_param

mac pause 4294967245

I went into /src/lorastik.rs and commented out the mac reset statement and reran cargo then removed the mac reset statement in init-fast.txt and re-ran.

Same error

pi@Pi3_misc:~/lorapipe/target/release $ sudo socat EXEC:'pppd nodetach file /etc/ppp/peers/lora,pty,rawer' \

EXEC:'./lorapipe --debug --txslot 2000 --initfile=init-fast.txt --maxpacketsize 100 --txwait 120 /dev/ttyUSB0 pipe,pty,rawer' 14:24:08 [ INFO] lora starting 14:24:08 [TRACE] (1) lorapipe::ser: [src/ser.rs:72] "/dev/ttyUSB0" SEROUT: INVALIDCOMMAND 14:24:09 [TRACE] (2) lorapipe::ser: [src/ser.rs:65] "/dev/ttyUSB0" SERIN: invalid_param 14:24:09 [DEBUG] (1) lorapipe::lorastik: Configuring radio 14:24:09 [TRACE] (1) lorapipe::ser: [src/ser.rs:72] "/dev/ttyUSB0" SEROUT: sys get ver 14:24:10 [TRACE] (2) lorapipe::ser: [src/ser.rs:65] "/dev/ttyUSB0" SERIN: RN2483 1.0.5 Oct 31 2018 15:06:52 14:24:10 [TRACE] (1) lorapipe::ser: [src/ser.rs:72] "/dev/ttyUSB0" SEROUT: mac reset 14:24:10 [TRACE] (2) lorapipe::ser: [src/ser.rs:65] "/dev/ttyUSB0" SERIN: invalid_param thread 'main' panicked at 'Failed to configure radio: Custom { kind: Other, error: "Bad response from radio during initialization" }', src/main.rs:112:5 note: run with RUST_BACKTRACE=1 environment variable to display a backtrace

jgoerzen commented 4 years ago

Interesting. I found the reference for your device over at http://ww1.microchip.com/downloads/en/DeviceDoc/RN2483-LoRa-Technology-Module-Command-Reference-User-Guide-DS40001784G.pdf and apparently it requires either mac reset 868 or mac reset 433 depending on which band you want to use. My RN2903 doesn't accept a band.

I don't know which band you're using, but can you try adapting the mac reset to one of those? If that works, then we'll have to think about what an appropriate way to build this in to the program might be.

Bovril1a commented 4 years ago

Just did that very thing..... 8-) Also changed the radio pwr state to 15 which is the max for this chip set...... Seems to fire up OK although when it's running if I open another shell and do an ifconfig no sign of a ppp network interface.

Ther is one error showing at the beginning

pi@Pi3_misc:~/lorapipe/target/release $ sudo socat EXEC:'pppd nodetach file /etc/ppp/peers/lora,pty,rawer' \

EXEC:'./lorapipe --debug --txslot 2000 --initfile=init-fast.txt --maxpacketsize 100 --txwait 120 /dev/ttyUSB0 pipe,pty,rawer' 14:36:02 [ INFO] lora starting 14:36:02 [TRACE] (1) lorapipe::ser: [src/ser.rs:72] "/dev/ttyUSB0" SEROUT: INVALIDCOMMAND 14:36:02 [TRACE] (2) lorapipe::ser: [src/ser.rs:65] "/dev/ttyUSB0" SERIN: valid_param 14:36:03 [DEBUG] (1) lorapipe::lorastik: Configuring radio 14:36:03 [TRACE] (1) lorapipe::ser: [src/ser.rs:72] "/dev/ttyUSB0" SEROUT: sys get ver 14:36:03 [TRACE] (2) lorapipe::ser: [src/ser.rs:65] "/dev/ttyUSB0" SERIN: RN2483 1.0.5 Oct 31 2018 15:06:52 14:36:03 [TRACE] (1) lorapipe::ser: [src/ser.rs:72] "/dev/ttyUSB0" SEROUT: mac reset 868 14:36:03 [TRACE] (2) lorapipe::ser: [src/ser.rs:65] "/dev/ttyUSB0" SERIN: ok 14:36:03 [TRACE] (1) lorapipe::ser: [src/ser.rs:72] "/dev/ttyUSB0" SEROUT: mac pause 14:36:03 [TRACE] (2) lorapipe::ser: [src/ser.rs:65] "/dev/ttyUSB0" SERIN: 4294967245 14:36:03 [TRACE] (1) lorapipe::ser: [src/ser.rs:72] "/dev/ttyUSB0" SEROUT: radio get mod 14:36:03 [TRACE] (2) lorapipe::ser: [src/ser.rs:65] "/dev/ttyUSB0" SERIN: lora 14:36:03 [TRACE] (1) lorapipe::ser: [src/ser.rs:72] "/dev/ttyUSB0" SEROUT: radio get freq 14:36:03 [TRACE] (2) lorapipe::ser: [src/ser.rs:65] "/dev/ttyUSB0" SERIN: 868100000 14:36:03 [TRACE] (1) lorapipe::ser: [src/ser.rs:72] "/dev/ttyUSB0" SEROUT: radio get pwr 14:36:03 [TRACE] (2) lorapipe::ser: [src/ser.rs:65] "/dev/ttyUSB0" SERIN: 1 14:36:03 [TRACE] (1) lorapipe::ser: [src/ser.rs:72] "/dev/ttyUSB0" SEROUT: radio get sf 14:36:03 [TRACE] (2) lorapipe::ser: [src/ser.rs:65] "/dev/ttyUSB0" SERIN: sf12 14:36:03 [TRACE] (1) lorapipe::ser: [src/ser.rs:72] "/dev/ttyUSB0" SEROUT: radio get bw 14:36:03 [TRACE] (2) lorapipe::ser: [src/ser.rs:65] "/dev/ttyUSB0" SERIN: 125 14:36:03 [TRACE] (1) lorapipe::ser: [src/ser.rs:72] "/dev/ttyUSB0" SEROUT: radio get cr 14:36:03 [TRACE] (2) lorapipe::ser: [src/ser.rs:65] "/dev/ttyUSB0" SERIN: 4/5 14:36:03 [TRACE] (1) lorapipe::ser: [src/ser.rs:72] "/dev/ttyUSB0" SEROUT: radio get wdt 14:36:03 [TRACE] (2) lorapipe::ser: [src/ser.rs:65] "/dev/ttyUSB0" SERIN: 15000 14:36:03 [TRACE] (1) lorapipe::ser: [src/ser.rs:72] "/dev/ttyUSB0" SEROUT: radio set pwr 15 14:36:03 [TRACE] (2) lorapipe::ser: [src/ser.rs:65] "/dev/ttyUSB0" SERIN: ok 14:36:03 [TRACE] (1) lorapipe::ser: [src/ser.rs:72] "/dev/ttyUSB0" SEROUT: radio set sf sf7 14:36:03 [TRACE] (2) lorapipe::ser: [src/ser.rs:65] "/dev/ttyUSB0" SERIN: ok 14:36:03 [TRACE] (1) lorapipe::ser: [src/ser.rs:72] "/dev/ttyUSB0" SEROUT: radio set bw 500 14:36:03 [TRACE] (2) lorapipe::ser: [src/ser.rs:65] "/dev/ttyUSB0" SERIN: ok 14:36:03 [TRACE] (1) lorapipe::ser: [src/ser.rs:72] "/dev/ttyUSB0" SEROUT: radio set cr 4/5 14:36:03 [TRACE] (2) lorapipe::ser: [src/ser.rs:65] "/dev/ttyUSB0" SERIN: ok 14:36:03 [TRACE] (1) lorapipe::ser: [src/ser.rs:72] "/dev/ttyUSB0" SEROUT: radio set wdt 60000 14:36:03 [TRACE] (2) lorapipe::ser: [src/ser.rs:65] "/dev/ttyUSB0" SERIN: ok 14:36:03 [DEBUG] (3) lorapipe::lorastik: txdelayrequired: self.txdelay = None 14:36:03 [TRACE] (3) lorapipe::ser: [src/ser.rs:72] "/dev/ttyUSB0" SEROUT: radio rx 0 14:36:03 [TRACE] (2) lorapipe::ser: [src/ser.rs:65] "/dev/ttyUSB0" SERIN: ok 14:36:03 [TRACE] (3) lorapipe::ser: [src/ser.rs:72] "/dev/ttyUSB0" SEROUT: radio rxstop 14:36:03 [TRACE] (2) lorapipe::ser: [src/ser.rs:65] "/dev/ttyUSB0" SERIN: ok 14:36:03 [DEBUG] (3) lorapipe::lorastik: txdelayrequired: self.txdelay = None 14:36:03 [TRACE] (3) lorapipe::ser: [src/ser.rs:72] "/dev/ttyUSB0" SEROUT: radio tx 007eff7d23c0217d217d217d207d387d217d247d247d207d227d267d207d207d207d207d257d262bc492e57d277d227d287d22d7267e 14:36:03 [TRACE] (2) lorapipe::ser: [src/ser.rs:65] "/dev/ttyUSB0" SERIN: ok 14:36:03 [TRACE] (2) lorapipe::ser: [src/ser.rs:65] "/dev/ttyUSB0" SERIN: radio_tx_ok 14:36:03 [DEBUG] (3) lorapipe::lorastik: txdelayrequired: self.txdelay = None 14:36:03 [TRACE] (3) lorapipe::ser: [src/ser.rs:72] "/dev/ttyUSB0" SEROUT: radio rx 0 14:36:03 [TRACE] (2) lorapipe::ser: [src/ser.rs:65] "/dev/ttyUSB0" SERIN: ok 14:36:05 [TRACE] (3) lorapipe::ser: [src/ser.rs:72] "/dev/ttyUSB0" SEROUT: radio rxstop 14:36:05 [TRACE] (2) lorapipe::ser: [src/ser.rs:65] "/dev/ttyUSB0" SERIN: ok 14:36:05 [DEBUG] (3) lorapipe::lorastik: txdelayrequired: self.txdelay = None

Bovril1a commented 4 years ago

Well, adding the band set works but still not sign of TCP/IP traffic.

Strangely enough if I run a network command such as ping or traceroute, whilst the commands bomb out there IS back and forth activity in the debug screens.

I am running this off two Raspberry Pi's "Pi"_4 and "P3_misc"

Two screenshots First showing the two devices running lorapipe in debug mode, minimal activity

Second screenshot is when I run traceroute, activity showing on both but the traceroute bombs out

They have IP addresses 10.10.10.3 and 10.10.10.4. I run traceroute from .4 to .3

capture_no_activity capture_traceroute

jgoerzen commented 4 years ago

So there's a lot that could be at play with TCP/IP. Let's start simple, and first verify that the two lorapipes can talk to each other: run one with the ping command, and the other with pong.

If that works, then how are you configuring TCP/IP?

jgoerzen commented 4 years ago

FWIW, I documented the mac reset issue at 3c992bd, so this can be closed. I can keep it open for TCP/IP conversation for a bit though.

Bovril1a commented 4 years ago

It's ALIVE...... 8-)

Just fired up ping and pong, screenshot of the activity and the outputs including RF quality below.

Command line used

./lorapipe --debug --readqual /dev/ttyUSB0 pong > pi3_lora.txt

./lorapipe --debug --readqual /dev/ttyUSB0 ping > pi4_lora.txt

ping_pong

TCP/IP was fired up using the PPP settings in the lorapipe documentation, then SSH'd. (There was an extraneous # in my original script that buggered it up)

Memories of classic dial up and Compuserve days..... with the speed.....

Thanks so much for this..... now I get to play.

Have you thought about porting this to Arduino..?

The TTGO Lora32 or T-Beam devices would lend themselves particularly well to this as self contained, all in one devices as well as plugins for PC Wintel and *nix devices including repeater and re-broadcast as well as IoT functionality

jgoerzen commented 4 years ago

Hah, another old CompuServer! Yes indeed, the speed brings back memories of modems...

I've done very little in the Arduino space, mainly thanks to the Raspberry Pi being roughly the same cost and far quicker to get going. I run lorapipe on a pi and it works great. I haven't had the time to tinker.