def __init__(self, _serial: Serial): self.ser = _serial self.MEP = {0: 11, 1: 21, 2: 51, 3: 101, 4: 251, 5: 501, 6: 1001} self.RBW = { 0: '3Hz', 1: '10Hz', 2: '30Hz', 3: '100Hz', 4: '300Hz', 5: '1kHz', 6: '3kHz', 7: '10kHz', 8: '500Hz', 9: '2kHz', 10: '4kHz', 11: '5kHz', 12: '20kHz', 13: 'AUTO' } self.TRC = { 0: 'LOGMAG', 1: 'PHASE', 2: 'DELAY', 3: 'MAG & PHASE', 4: 'MAG & DELAY', 5: 'POLAR', 6: 'IMPD CHART', 7: 'ADMT CHART', 8: 'VSWR', 9: 'LINMAG', 10: 'LIN & PHASE', 11: 'LIN & DELAY', 12: 'REAL', 13: 'IMAG', 14: 'REAL & IMAG', 15: 'LOG Z', 16: 'LOG Z & θ', 17: 'Q', 18: 'LOG Z & Q' } self.MEASPT = { 0: 'TB/TA', 1: 'TA/R', 2: 'TB/R', 3: 'TA', 4: 'TB', 5: 'R' } _serial.clear_input() if _serial.write_readline('ACCH?') == '': logging.error('Can not connected to anritsy') assert False
def test_filesettings_open(): ser = Serial(setup_file='myfile.txt', com=False, baud=9600, parity='NONE', stopbits=1, bytesize=8, timeout=0.1, answer_time=0.1, terminator='LN', terminator_space=True, logging_message=True) ser.close()
def test_simple_open(): ser = Serial() ser.close()
def test_write_readlines(): ser = Serial(logging_message='all') n = 3 assert ser.write_readlines('aa', lines_number=n) == n * [b''] ser.close()
def test_write_num(): ser = Serial() with pytest.raises(TypeError): ser.write(1)
def test_write_str(): ser = Serial() ser.write('abc') ser.close()
import serial.tools.list_ports import logging from anritsu import Network_Analyser from myserial import Serial # def excepthook(*args): # logging.getLogger().error('Uncaught exception:', exc_info=args) logging.basicConfig(filename="INFO.log", level=logging.INFO, filemode='w') ser = Serial(setup_file=False, com=False, baud=9600, parity='NONE', stopbits=1, bytesize=8, terminator='LN', terminator_space=True, timeout=5, answer_time=0.05, logging_message=True) anr = Network_Analyser(ser) # anr.set_power(output_pow=-6) # anr.set_freq(10,3*10**8,log=True) # anr.set_meas_points(6) # anr.set_RBW(2) # # anr.set_channel(channel='all') # anr.set_data_format(ch1_format = 3, ch2_format = 3) # anr.set_meas(ch1_meas = 3, ch2_meas = 5)