Esempio n. 1
0
    def test_receive_multipart_file(self):
        self._start()

        data = ''.join(map(lambda x: x * 300, ['A', 'B', 'C']))

        p = "/test"

        self.system.obc.write_file(p, data)

        self.system.comm.put_frame(
            telecommand.DownloadFile(correlation_id=0x11,
                                     path=p,
                                     seqs=[0, 3, 1, 2]))

        frames = [
            self.system.comm.get_frame(20),
            self.system.comm.get_frame(1),
            self.system.comm.get_frame(1),
            self.system.comm.get_frame(1)
        ]

        frames = sorted(frames, key=lambda x: x.seq())

        received = ''
        for f in frames:
            received += ''.join([chr(b) for b in f.payload()[2:]])

        self.assertAlmostEqual(received, data)
Esempio n. 2
0
    def down_sads(*chunks):
        chunks = list(chunks)
        if not chunks:
            print 'Nothing to download'
            return

        ns['run']([[
            tc.DownloadFile(correlation_id=31, path='/sads.exp', seqs=chunks),
            ns['Send'], WaitMode.Wait
        ]])
Esempio n. 3
0
    def down_photo(photo_id, *chunks):
        chunks = list(chunks)
        if not chunks:
            chunks = range(0, 25, 1)

        photo_file = '/sail.photo_{}'.format(photo_id)

        ns['run']([[
            tc.DownloadFile(correlation_id=13, path=photo_file, seqs=chunks),
            ns['Send'], WaitMode.Wait
        ]])
Esempio n. 4
0
    def test_should_respond_with_error_frame_for_non_existent_file_when_downloading(
            self):
        self._start()

        p = "/non_exist"

        self.system.comm.put_frame(
            telecommand.DownloadFile(correlation_id=0x11,
                                     path=p,
                                     seqs=[0, 3, 1, 2]))

        frame = self.system.comm.get_frame(20, filter_type=FileSendErrorFrame)

        self.assertIsInstance(frame, FileSendErrorFrame)
        self.assertEqual(frame.seq(), 0)
        self.assertEqual(frame.correlation_id, 0x11)
        self.assertEqual(frame.error_code, 1)
Esempio n. 5
0
def download_chunks(uplink_station, all_stations, file_name, correlation_id,
                    chunks):
    cmd = tc.DownloadFile(correlation_id=correlation_id,
                          path=file_name,
                          seqs=chunks)

    downloaded = []
    attempt = 0

    while not downloaded:
        if attempt >= 10:
            break

        attempt += 1

        print 'Download chunks {}. Attempt: {}. TC: {}'.format(
            chunks, attempt, cmd)
        uplink_station.sender.send(cmd.frame())
        downloaded = receive_file_parts(all_stations, correlation_id, chunks)

    return downloaded