I found out the error. For the pulse mode, it was necessary to input a time delay between the SENS:DATA and TRAC:DATA? commands (not too long, 0.05 seconds was enough).<br> Specifically, I inserted the command <code>time.sleep(0.05) </code>between lines 49 and 51.<br> I hope this helps anyone else with the same problem.