1

I'm using Telnetlib to control a VIAVI 5800.Here is my code. And I log results of telnet.read_very_eager. Sometimes the first read returns b'', maybe say it occurs a lot. I really don't understand why only the first read has this problem while the others just work fine. I also tried adding more time after I finishing changing the time slot, this still happens.

import telnetlib
import time
from robot.libraries.BuiltIn import BuiltIn

for vc4 in range(vc4, vc4_end):
    for tug3 in range(stm_start, tug3_end):
        for tug2 in range(1, 8):
            for tu12 in range(1, 4):
                tu12_com = ":SENSE:SDH:DS1:E1:LP:C12:CHANNEL" + " " + str(tu12) + "\n"
                tug2_com = ":SENSE:SDH:DS1:E1:LP:C2:CHANNEL" + " " + str(tug2) + "\n"
                tug3_com = ":SENSE:SDH:DS1:E1:LP:C3:CHANNEL" + " " + str(tug3) + "\n"
                vc4_com = ":SENSE:SDH:CHANNEL:STMN" + " " + str(vc4)
                tn.write(tu12_com.encode('ascii'))  # change tu12 
                time.sleep(0.1)
                tn.write(tug2_com.encode('ascii'))  # change tug2 
                time.sleep(0.1)
                tn.write(tug3_com.encode('ascii'))  # change tug3 
                time.sleep(0.1)
                tn.write(vc4_com.encode('ascii'))  # change vc4
                time.sleep(1.5)
                tn.write(b":ABOR\n")
                time.sleep(1)
                tn.write(b":INIT\n")
                time.sleep(5)
                tn.write(b":SENSE:DATA? TEST:SUMMARY\n")
                time.sleep(2)
                result = tn.read_very_eager()
                result_num = str(vc4) + "-" + str(tug3) + "-" + str(tug2) + "-" + str(tu12)
                BuiltIn().log_to_console(result_num)
                BuiltIn().log_to_console(result)

The results are like under:

results saved in excel workbook

results in RF Ride console

I'm so confused and wondering can anyone explain this. Thanks a lot. BTW, my python version is:

C:\Users\Quinn>python -V
Python 3.7.9

0 Answers0