Пример #1
0
    def test_j1850_pwm_decode(self):
        self.test_name = 'J1850 PWM frame'
        self.trial_count = 100
        for i in xrange(self.trial_count):
            self.update_progress(i+1)

            frame_count = random.randint(1, 6)
            frames = []
            for i in xrange(frame_count):
                frames.append(gen_j1850_frame())

            pwm_p, pwm_m = j1850.j1850_pwm_synth(frames)

            records = list(j1850.j1850_pwm_decode(pwm_p, stream_type=stream.StreamType.Edges))

            self.assertEqual(len(records), len(frames), 'Decoded frame count mismatch: {} -> {}'.format(len(frames), len(records)))

            for r, o in zip(records, frames):
                if r.data != o:
                    print('Mismatch:\n  {}\n  {}'.format(o, r.data))

                    print('### original frames:')
                    for o in frames:
                        print('  ', repr(o))

                    print('### decoded frames:')
                    for r in records:
                        print('  ', repr(r.data))
                self.assertEqual(r.data, o, 'Frames are different')
    def test_j1850_pwm_decode(self):
        self.test_name = 'J1850 PWM frame'
        self.trial_count = 100
        for i in xrange(self.trial_count):
            self.update_progress(i + 1)

            frame_count = random.randint(1, 6)
            frames = []
            for i in xrange(frame_count):
                frames.append(gen_j1850_frame())

            pwm_p, pwm_m = j1850.j1850_pwm_synth(frames)

            records = list(
                j1850.j1850_pwm_decode(pwm_p,
                                       stream_type=stream.StreamType.Edges))

            self.assertEqual(
                len(records), len(frames),
                'Decoded frame count mismatch: {} -> {}'.format(
                    len(frames), len(records)))

            for r, o in zip(records, frames):
                if r.data != o:
                    print('Mismatch:\n  {}\n  {}'.format(o, r.data))

                    print('### original frames:')
                    for o in frames:
                        print('  ', repr(o))

                    print('### decoded frames:')
                    for r in records:
                        print('  ', repr(r.data))
                self.assertEqual(r.data, o, 'Frames are different')
Пример #3
0
    def test_j1850_sample_data(self):
    
        # Read files containing frames
        dp_samples, sample_period, start_time = tsup.read_bin_file('test/data/j1850_pwm_1p.bin')
        dp_it = stream.samples_to_sample_stream(dp_samples, sample_period, start_time)

        records = list(j1850.j1850_pwm_decode(dp_it))
        
        #print('### decoded records:', len(records))
        #for r in records:
        #    print(r.data)
        self.assertEqual(len(records), 9, 'Missing records, expected to decode 9')
    def test_j1850_sample_data(self):

        # Read files containing frames
        dp_samples, sample_period, start_time = tsup.read_bin_file(
            'test/data/j1850_pwm_1p.bin')
        dp_it = stream.samples_to_sample_stream(dp_samples, sample_period,
                                                start_time)

        records = list(j1850.j1850_pwm_decode(dp_it))

        #print('### decoded records:', len(records))
        #for r in records:
        #    print(r.data)
        self.assertEqual(len(records), 9,
                         'Missing records, expected to decode 9')