Пример #1
0
def sat_transmit(data):  # data : string of data to be sent via satellite
    ser = serial.Serial("/dev/ttyUSB0", 19200)
    rb = RockBlock(ser)
    #bindata = struct.pack("i", len(data)) # converts the data to binary
    rb.text_out = data  # put data in outbound buffer
    print("Talking to satellite...")
    status = rb.satellite_transfer()
    # loop as needed
    retry = 0
    while status[
            0] > 8 and retry < 8:  # Keeps trying until data is sent. Max retries = 5
        time.sleep(10)
        status = rb.satellite_transfer()
        print(retry, status)
        retry += 1
    if status[0] > 8:
        print("Transmission failed")
    print("\nDONE.")
Пример #2
0
import board

uart = board.UART()
uart.baudrate = 19200

# via USB cable
# import serial
# uart = serial.Serial("/dev/ttyUSB0", 19200)

from adafruit_rockblock import RockBlock

rb = RockBlock(uart)

# try a satellite Short Burst Data transfer
print("Talking to satellite...")
status = rb.satellite_transfer()
# loop as needed
retry = 0
while status[0] > 8:
    time.sleep(10)
    status = rb.satellite_transfer()
    print(retry, status)
    retry += 1
print("\nDONE.")

# get the raw data
data = rb.data_in
print("Raw data = ", data)

# unpack data (see send example)
some_int = struct.unpack("i", data[0:4])[0]