Beispiel #1
0
    def test_process_raw_data(self):
        # TODO: Suspect something is wrong with channel 0
        # Test data
        data = b'\xc7\xad-\x81\xbb\xd5\x8bA\xd8\x03\x0e\xabW\x00\x00\x94\xd1@\x00\x00\x00\x00p\x99dA\x00\x01\x15\x04*\x89\xf5\xec=m\xea\xff@\x00\x90+,\xc8\x8fP@\x00\x00\x88\x13\x8f\xfc\x94\xc0{\x00\x01\r\xfe \xc5x\x03\xf2\x04\xb9\xf1\xc0\x00\x10\x10\x02\xa2\xf4\x98R@\x00\x00`\x12w\xee\x88@{\x00\x01\x05\x01*\x19\xbbc\xd5(\\\x11A\x00`\nL\x0fWR@\x00\x00\xa8\x10\x10\x02\xac\xa6\xc0{\x00\x01\x16\xfd+\x93d_8?-\r\xc1\x00\xa0\xe8\xd5\xd9\xc1P@\x00\x00\xc4!M\xbf\xa2@;\x00\x02\x01\x01\x1c\x00\x01\xc0\xb7\xa3P\x13\xc1\x00H\xfd\xad\x1b\xa2R@\x00\x00<\xb7\x8f\xf0\xa8@3\x00\x02\x12\x120\x00nX|\x93z\n\xc1\x00H\x85\xa4\x93\x1bQ@\x00\x00X\t\xb0\x0f\xa1@{\x00\x02\x1b\x1b.\x00\xae\xed"\xfe\xd5\x0bA\x00H\xa5\x00\x1b\xf7Q@\x00\x00\xf8\xda\xd8s\xa2\xc0{\x00\x02\x14\x14.\x00\xf9d \x05\xeb\x11A\x00H5$\xcd\x9eS@\x00\x004`\xe1h\xa7\xc0{\x00\x02\x08\x082\x00\x00\xd5\x83\x90\xb1\x97@\x00H\xbdl&\xf9P@\x00\x00\x00\xb7\x9c\x9dC\xc0;\x00\x02  $\x00\x96\xe8\xda\xcdo\x0e\xc1\x00H\x1d\x16E\xc9S@\x00\x00H)\xce,\xa6@{\x00\x02\n\n1\x00\x0eJJ\xb5B\x03A\x00H-\x83\xac\tR@\x00\x00\xe8\xed\xb6T\x99\xc0;\x00\x02\x0b\x0b/\x00E\xf4\xa7\xba;\x12\xc1\x00H\x05g\xbf\xf9Q@\x00\x00\xb8zl\x8f\xa7@{\x00\x02\x1c\x1c"\x00p\xfc\x1d\xe1\'\x0c\xc1\x00H\x05n\xb3\xd0S@\x00\x00\\F4\x1f\xa4@;\x00'

        # Process data
        raw = binr.process_raw_data(data)

        # Check raw data response
        self.assertEquals(raw["Time"], 58374000.14730411)
        self.assertEquals(raw["Week Number"], 984)
        self.assertEquals(raw["GPS time shift"], 18000.000020901723)
        self.assertEquals(raw["GLO time shift"], 10800000.0)
        self.assertEquals(raw["Rec Time Scale Correction"], 0)
        self.assertEquals(len(raw["Signal Type"]), 13)
        self.assertEquals(raw["Signal Type"][2], 1)
        self.assertEquals(raw["Sat Number"][2], 5)
        self.assertEquals(raw["Carrier Number"][2], 1)
        self.assertEquals(raw["Carrier Phase"][2], 284426.2083882555)
        self.assertEquals(raw["Pseudo Range"][2], 73.36030865681823)
        self.assertEquals(raw["Doppler Freq"][2], -2902.0040288167074)
        self.assertEquals(raw["Flags"][2], 123)
Beispiel #2
0
#print("Requesting satellite ephemeris")
#ser.write(binr.cancel_requests())
#time.sleep(0.5)
#ser.write(binr.request_sv_ephemeris(binr.GPS, 3,-3))
#buffer = ser.read(1000)
#data, buffer = binr.process_msg(buffer)

print("Requesting raw data stream")
ser.write(binr.request_raw_data(10))
buffer = []
try:
    while True:
        try:

            buffer = list(ser.read_until(terminator='\x10\x03'))
            if len(buffer) > 0:
                data, buffer = binr.process_msg(list(buffer))
                print(len(buffer))
                print("Msg: " + str(hex(data["ID"])) + ": " +
                      str(len(data["data"])) + " bytes : " +
                      str(bytearray(data["data"][0:50])))
                if data["ID"] == 0xF5:
                    raw_data = binr.process_raw_data(data["data"])
                    binr.print_raw_data(raw_data)
            time.sleep(0.1)
        except ValueError:
            s = 1
        time.sleep(0.1)
except KeyboardInterrupt:
    ser.close()
Beispiel #3
0
    rover_obs = np.zeros((Nc, 4))
    base_obs = np.zeros((Nc, 4))

    # Get messages from base and rover
    print("Checking for messages")
    if rover_stream.in_waiting > 0:
        # Read and process the messages
        try:
            rover_buffer = list(rover_stream.read_until(terminator='\x10\x03'))
            rover_msg, rover_buffer = binr.process_msg(rover_buffer)
            print("Rover message received. Unread buffer size: " +
                  str(len(rover_buffer)))

            # We are only interrested in observation and navigation messages
            if rover_msg['ID'] == 0xF5:  # observation message
                rover_data = binr.process_raw_data(rover_msg["data"])

                # Calculate obervable receiver time
                t_rx = (rover_data["Time"] +
                        rover_data["GPS time shift"]) / 1000

                # Loop through all channels
                for i in range(len(rover_data["Carrier Phase"])):
                    # Check if raw data is valid
                    if (rover_data["Signal Type"][i] == binr.GPS
                            and rover_data["Flags"][i] & 0b00011011
                            == 0b00011011):  # Only handle GPS for now

                        # Start adding information
                        sat_no = rover_data["Sat Number"][i]
                        phase = rover_data["Carrier Phase"][i]
Beispiel #4
0
import ephemeris
import numpy as np
import binr

if False:
    # Test the positioning of a single satellite
    # Define data
    # GPS sat 1 data
    eph_bin = b'\x01\x03\x00\xc0c\xc2\xfe\x8e\xa2,\x91\xa1-\xec)]\xf3?\x00`B\xb6\x00\x00\x00\xa0\x87\x92X?\x00\x98\x047\x00\x00\xc0*\xba!\xb4@\x00\x00\x00\x00\x12\xe4\xb8A\x00\x00\xc0\xb1\xb8\xe8\xc7\x04\xe6\xaa\x02\xc0\x00\x00 2\x00\xc7\xaesB\xc2\xee?\x00pbC\xacb^T\x8em\xde?\x19\x9bhA\xe6\xd2\xa1\xbdk\xc8\xa6\xf2\x80\xf0P\xbd\x00@\x1c6\x00\x00\x00\x00\x12\xe4\xb8A\x00\x00\x00\x00\x00\x00\xdc,\x9e\x90\xce=\x00\x00\x16\x00'
    # Raw data message
    raw_data_bin = b'\x90Q\xffg\xd4\xa5\xb8A\xd8\x03\xb4\xd01\x00\x00\x94\xd1@\x00\x00\x00\x00p\x99dA\x00\x01\x0b\x00\x1b\x00\x00\x00\x00\x00\x00\x00\x00\x00\xf026\x91\xc2S@\x00\x00\xc0\xdaJL\x94\xc0\x13\x00\x01\x03\x05\x1fh#\xff2F\xb2VA\x00\xd0\xd3\xa4\xf5FQ@\x00\x00|0\xf8\t\xa5\xc0;\x00\x01\x05\x01\x1fn\x92YN\xc7\xdb]\xc1\x00`\x8a\xc4\x0c\xa6R@\x00\x00l\xe6B\x96\xb0@3\x00\x01\x13\x03\x1e\xeeS\x14s(E8\xc1\x00\xd0\xf5\xe2\x96\x11P@\x00\x00\x10\x10\x0b\x01X\x83\xc0;\x00\x02\x17\x17*\xa8n\x04wT\ng\xc1\x00H\xa5\x9c\xdatS@\x00\x00\xe4Z\x812\xac@\x7f\x00\x02\x13\x13$\x00\x18\x8b\x8a\x97\xd9f\xc1\x00H%E\xa4<S@\x00\x00\x9c\x157\xe0\xa8@\x7f\x00\x01\x12\xfd%\x06U\xcd\x86\xdd6hA\x00\xa0\x98\xdbevR@\x00\x00\xc4\x83J\xe2\xac\xc0?\x00\x02\x1f\x1f!\xa0\x90qf\x0e\xb0I\xc1\x00H\xa5\xb2=1T@\x00\x00\xcc^\xcfa\xa2@;\x00\x01\x04\x06(\xa3\x15\xd0\xa0\xae\xefm\xc1\x00P\xd6\x96\xc1\x03P@\x00\x00H\t7Y\x94@\x7f\x00\x02\x1c\x1c$0b\xdaj3\xbb^A\x00H%_\xc4\xa6T@\x00\x00\xa8>\xfe\xf3\xa2\xc0?\x00\x02\x0e\x0e$\x00\xf8\xc1\x8b\xe0\xd5\xe2@\x00H%\x99\xfb\xfeR@\x00\x00\xa0D}\xef\x97\xc0?\x00\x02\x03\x03.h\x9e\x825\xb7&g\xc1\x00H\xe5\x9e\x81\xe6P@\x00\x00\x80c_\xd3\x91@\x7f\x00\x02\x11\x11# \xda\xe4cprk\xc1\x00HeG\xda`R@\x00\x00\xa0u%\xc6\x9c@;\x00\x02  \x17\x00\x00\x00\x00\x00\x00\x00\x00\x00H\xa5\xef\xc2\x83T@\x00\x00\xf0x\xc8l\xa6\xc0\x13\x00\x02\x01\x01*\x00#f@\xebF\x12\xc1\x00H\xa5\xde\xb0*Q@\x00\x00\x08\xed\x83\xa1\x92\xc0?\x00\x02\x16\x16\x1f`\xb6\xde\x12kmM\xc1\x00H%\x9fX:Q@\x00\x00@\xf1\x07K|\xc0{\x00\x02\x0b\x0b(\x00JM\xac\xe5\xadVA\x00He\x84k\xe8Q@\x00\x00\xc8\x8d\x17\x10\x10\xa4\xc0?\x00\x04x\x00&\x00\xd1s1*\xfc5\xc1\x00\xa4\xd2\x85\x18\x08`@\x00\x00\xa0I\x95Bq@?\x00\x02\x12\x12%\x00\x04\x97\xac|\xbe`A\x00H\xa5\nnPR@\x00\x00\x08\xb7\x93y\xa5\xc0?\x00'

    # Process messages
    eph = binr.process_sv_ephemeris(eph_bin)
    raw = binr.process_raw_data(raw_data_bin)

    # Print raw data message
    #binr.print_raw_data(raw)
    ch = 11  # GPS(3) channel

    # Print some information of our GPS
    print("Signal strength:       " + str(raw["SNR"][ch]))
    prng = raw["Pseudo Range"][ch]
    print("Pseudo Range:          " + str(prng) + " ms")
    t_rx = raw["Time"] / 1000
    print("Time received:         " + str(t_rx) + " s")
    t_tx_orig = ephemeris.calc_tx_time(t_rx, prng)
    print("Time transmitted:      " + str(t_tx_orig) + " s")
    pos, clock_correction, dt_r = ephemeris.calc_sat_xyz(t_tx_orig, eph)
    print("Sat position:          " + str(pos) + " m")