raspberrypi-tw / lora-sx1276

Sample code for LoRa SX1276
GNU Affero General Public License v3.0
55 stars 17 forks source link

RuntimeError: Bad PA_DAC value 0x0 #3

Open z3rone opened 1 year ago

z3rone commented 1 year ago

I have an error when I run the tx_beacon.py script. It seems an invalid PA_DAC value is returned:

$ ./tx_beacon.py -f 868.0 --wait 1
Traceback (most recent call last):
  File "/home/noroot/lora-sx1276/./tx_beacon.py", line 116, in <module>
    print(lora)
  File "/home/noroot/lora-sx1276/SX127x/LoRa.py", line 943, in __str__
    s += " pa_dac             %s\n" % ['default', 'PA_BOOST'][self.get_pa_dac()]
  File "/home/noroot/lora-sx1276/SX127x/LoRa.py", line 56, in wrapper
    return func(self, self.spi.xfer([register_address, 0])[1])
  File "/home/noroot/lora-sx1276/SX127x/LoRa.py", line 816, in get_pa_dac
    raise RuntimeError("Bad PA_DAC value %s" % hex(pa_dac))
RuntimeError: Bad PA_DAC value 0x0

If I comment the line 943 out the script at least does not fail but I am not able to receive any messages on another device:

SX127x LoRa registers:
 mode               SLEEP
 freq               868.000000 MHz
 coding_rate        CR4_5
 bw                 BW125
 spreading_factor   1 chips/symb
 implicit_hdr_mode  OFF
 rx_payload_crc     OFF
 tx_cont_mode       OFF
 preamble           0
 low_data_rate_opti OFF
 agc_auto_on        ON
 symb_timeout       0
 freq_hop_period    0
 hop_channel        {'pll_timeout': 1, 'crc_on_payload': 0, 'fhss_present_channel': 4}
 payload_length     0
 max_payload_length 0
 irq_flags_mask     {'rx_timeout': 1, 'rx_done': 0, 'crc_error': 0, 'valid_header': 1, 'tx_done': 1, 'cad_done': 1, 'fhss_change_ch': 1, 'cad_detected': 1}
 irq_flags          {'rx_timeout': 0, 'rx_done': 0, 'crc_error': 0, 'valid_header': 0, 'tx_done': 1, 'cad_done': 0, 'fhss_change_ch': 0, 'cad_detected': 1}
 rx_nb_byte         26
 rx_header_cnt      16560
 rx_packet_cnt      31643
 pkt_snr_value      30.500000
 pkt_rssi_value     -26
 rssi_value         -100
 fei                65280
 pa_select          PA_BOOST
 max_power          10.800000 dBm
 output_power       -4.200000 dBm
 ocp                OFF
 ocp_trim           45.000000 mA
 lna_gain           NOT_USED
 lna_boost_lf       0b0
 lna_boost_hf       0b10
 detect_optimize    0x0
 detection_thresh   0x10
 sync_word          0x0
 dio_mapping 0..5   [1, 0, 0, 0, 0, 0]
 tcxo               XTAL
 fifo_addr_ptr      0xf4
 fifo_tx_base_addr  0xf5
 fifo_rx_base_addr  0x20
 fifo_rx_curr_addr  0x24
 fifo_rx_byte_addr  0x0
 status             {'rx_coding_rate': 0, 'modem_clear': 0, 'header_info_valid': 0, 'rx_ongoing': 0, 'signal_sync': 0, 'signal_detected': 0}
 version            0x0