From 58f393ef63d236db6a7aeafb23beaf75b198263f Mon Sep 17 00:00:00 2001 From: SP1RYTUSzz <157947055+SP1RYTUSzz@users.noreply.github.com> Date: Thu, 8 May 2025 12:52:53 -0700 Subject: [PATCH 1/2] Add UART Pinout node, change node to 7 & 8, change uart to return upon '\n' --- CubeSatLink 2.0/Summit.py | 41 +++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/CubeSatLink 2.0/Summit.py b/CubeSatLink 2.0/Summit.py index 6b9a19d..07fd0e7 100644 --- a/CubeSatLink 2.0/Summit.py +++ b/CubeSatLink 2.0/Summit.py @@ -1,5 +1,6 @@ # CubeSatLink Flight Transceiver Node (Summit) # Connect to antenna before plug any power in +# NOTE: UART Pinout. It is flipped by adafruit design, we can't change it to be logical. # Author: Tri Do import time @@ -13,25 +14,18 @@ uart1 = busio.UART(board.D24, board.D25, baudrate=9600, bits = 8, parity = None, timeout=1) message_started = False -# set the time interval (seconds) for sending packets +uartTxInterval = 1 transmit_interval = 5 RFMTimeOut = 10 -# Define radio parameters. -RADIO_FREQ_MHZ = 902.0 - -# Define pins connected to the chip. -# set GPIO pins as necessary -- this example is for Raspberry Pi -CS = digitalio.DigitalInOut(board.D10) -RESET = digitalio.DigitalInOut(board.D11) led = digitalio.DigitalInOut(board.LED) led.direction = digitalio.Direction.OUTPUT -# Initialize SPI bus. +RADIO_FREQ_MHZ = 902.0 +CS = digitalio.DigitalInOut(board.D10) +RESET = digitalio.DigitalInOut(board.D11) spi = busio.SPI(board.SCK, MOSI=board.MOSI, MISO=board.MISO) -# Initialze RFM radio rfm9x = adafruit_rfm9x.RFM9x(spi, CS, RESET, RADIO_FREQ_MHZ, agc = True) - # rfm9x post-config rfm9x.enable_crc = True rfm9x.tx_power = 23 @@ -39,8 +33,8 @@ rfm9x.coding_rate = 8 #rfm9x.signal_bandwidth = 7800 rfm9x.ack_delay = 0.1 # set delay before sending ACK -rfm9x.node = 1 -rfm9x.destination = 2 +rfm9x.node = 8 +rfm9x.destination = 7 # initialize flag and timer time_now = 0 @@ -70,7 +64,10 @@ def UART_Rx(uart): rx_string = bytearray() while uart.in_waiting > 0: char_buffer = uart.read(1) - rx_string = rx_string + char_buffer + if (char_buffer == '\n'): + break + else: + rx_string = rx_string + char_buffer string = ''.join([chr(b) for b in rx_string]) return string #.decode('utf-8','replace') != '': #not empty @@ -80,13 +77,16 @@ def UART_Rx(uart): def incCnt(): global cnt cnt += 1 -def dspCnt(): +def readCnt(): global cnt return cnt NoAck_cnt = 0 def incNAK(): global NoAck_cnt NoAck_cnt += 1 +def readNAK(): + global NoAck_cnt + return NoAck_cnt def petRFMWatchdog(): global rfmWatchdog @@ -100,7 +100,7 @@ def RFM_Tx(cust,msg): bytes(full_msg, "UTF-8") ): incNAK() - print("Tx No Ack: ") + print(f"Tx No Ack: {readCnt()} {readNAK()}") def RFM_Rx(): # Look for packet. Print header, payload, RSSI, SNR @@ -111,11 +111,10 @@ def RFM_Rx(): print("RSSI: {0}, SNR: {1}".format(rfm9x.last_rssi, rfm9x.last_snr)) return packet[4:] -uartTxInterval = 3 uart0_receiving = '' uart1_receiving = '' while True: -# try: + try: Blink_Status_LED() # RFM Tx @@ -150,7 +149,7 @@ def RFM_Rx(): # #RFM Rx # uplink_message = RFM_Rx() - uplink_message = "Summit checking in. Behind Great Ideas. Phytecsssss.\n" + uplink_message = "Summit checking in. Behind Great Ideas. Phytecssssssadhfkjdshasdh whatever lorem ipsum.\n" # print("RFM Recieved:",uplink_message) # UART Tx @@ -164,5 +163,5 @@ def RFM_Rx(): # print("-----END LOOP-----") time.sleep(0.1) -# except Exception as e: -# print(e) + except Exception as e: + print(e) From 0918bef417f268c8a426eaaa59a1c20ddeb5f4ed Mon Sep 17 00:00:00 2001 From: SP1RYTUSzz <157947055+SP1RYTUSzz@users.noreply.github.com> Date: Thu, 8 May 2025 12:57:51 -0700 Subject: [PATCH 2/2] change coding rate, node & destination --- CubeSatLink 2.0/GroundStation.py | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/CubeSatLink 2.0/GroundStation.py b/CubeSatLink 2.0/GroundStation.py index 7a61d77..cbfd534 100644 --- a/CubeSatLink 2.0/GroundStation.py +++ b/CubeSatLink 2.0/GroundStation.py @@ -10,35 +10,26 @@ import sdcardio import storage +led = digitalio.DigitalInOut(board.LED) +led.direction = digitalio.Direction.OUTPUT + # FIELD CONFIG PARAMETERS RADIO_FREQ_MHZ = 902.0 - -# Declare SPI pins RESET = digitalio.DigitalInOut(board.D11) CS_RFM = digitalio.DigitalInOut(board.D10) CS_SD = board.D4 -# Declare on-board LED status blink -led = digitalio.DigitalInOut(board.LED) -led.direction = digitalio.Direction.OUTPUT - - -# Initialize SPI bus spi = busio.SPI(board.SCK, MOSI=board.MOSI, MISO=board.MISO) -# Initialize SD Card Module - -# Initialize RFM95 rfm9x = adafruit_rfm9x.RFM9x(spi, CS_RFM, RESET, RADIO_FREQ_MHZ, agc = True) - # Radio config rfm9x.tx_power = 23 -rfm9x.coding_rate = 8 +rfm9x.coding_rate = 6 #rfm9x.signal_bandwidth = 7800 rfm9x.spreading_factor = 8 #higher = lower bitrate rfm9x.enable_crc = True # enable CRC checking rfm9x.ack_delay = 0.1 # set delay before transmitting ACK (seconds) -rfm9x.node = 2 # set node addresses -rfm9x.destination = 1 # set destination addresses +rfm9x.node = 7 # set node addresses +rfm9x.destination = 8 # set destination addresses tnow = 0 TxInterval = 5