def login_seq_passwd(ser_conn, user, passwd): '''Provides the ability to logon using a specific user and specific passwd''' global SEQ # Create and reset packet packet = c12packet.C1218_packet() #Send logon packet.reset_packet(ctrl=SEQ) if not packet.logon_num(num=user): print "login_seq_passwd: Failed to build logon" data = packet.full_packet() print "Sending: %s: %s" % ('logon:', packet.print_packet(data)) send_data(ser_conn, data) # Blind ACK send_ack(ser_conn, cmd_pause) # Cycle Control Byte SEQ ^= 1 #Send security packet.reset_packet(ctrl=SEQ) if not packet.passwd(passwd=passwd): print "login_seq_passwd: Failed to build security" data = packet.full_packet() print "Sending: %s: %s" % ('security:', packet.print_packet(data)) send_data(ser_conn, data) # Blind ACK send_ack(ser_conn, cmd_pause) # Cycle Control Byte SEQ ^= 1 # Return the sequence where we left off return SUCCESS
def term_session(ser_conn): global SEQ # Create and reset packet packet = c12packet.C1218_packet() packet.reset_packet(ctrl=SEQ) # Build read packet and send packet.term() data = packet.full_packet() print "Sending: %s: %s" % ('term_session:', packet.print_packet(data)) send_data(ser_conn, data) # Blind ACK send_ack(ser_conn, cmd_pause) # Cycle Control Byte SEQ ^= 1 # Return the sequence where we left off return SUCCESS
def run_proc(ser_conn, proc, indata=''): global SEQ # Create and reset packet packet = c12packet.C1218_packet() packet.reset_packet(ctrl=SEQ) # Build procedure packet and send packet.proc(proc=proc, data=indata) data = packet.full_packet() print "Sending: %s: %s" % ('run_proc:', packet.print_packet(data)) send_data(ser_conn, data) # Blind ACK send_ack(ser_conn, cmd_pause) # Cycle Control Byte SEQ ^= 1 # Return the sequence where we left off return SUCCESS
def full_table_read(ser_conn, table): global SEQ # Create and reset packet packet = c12packet.C1218_packet() packet.reset_packet(ctrl=SEQ) # Build read packet and send packet.full_read(table=table) data = packet.full_packet() print "Sending: %s: %s" % ('full_read:', packet.print_packet(data)) send_data(ser_conn, data) # Blind ACK send_ack(ser_conn, cmd_pause * 3) # Cycle Control Byte SEQ ^= 1 # Return the sequence where we left off return SUCCESS
def login_setup(ser_conn): '''Provides the ability to logon using a specific user and specific passwd''' global SEQ # Create and reset packet packet = c12packet.C1218_packet() #Send ident packet.reset_packet(ctrl=SEQ) if not packet.ident(): print "login_seq_passwd: Failed to build ident" return FAIL data = packet.full_packet() print "Sending: %s: %s" % ('ident:', packet.print_packet(data)) send_data(ser_conn, data) # Blind ACK send_ack(ser_conn, cmd_pause) # Cycle Control Byte SEQ ^= 1 if NEGO_ON: #Send nego packet.reset_packet(ctrl=SEQ) if not packet.nego(): print "login_seq_passwd: Failed to build nego" return FAIL data = packet.full_packet() print "Sending: %s: %s" % ('nego:', packet.print_packet(data)) send_data(ser_conn, data) # Blind ACK send_ack(ser_conn, cmd_pause) # Cycle Control Byte SEQ ^= 1 # Return the sequence where we left off return SUCCESS
#start_delay = 100 #start_delay = 1 cmd_pause = .15 no_pause = 0 logon_pause = 5 # Outcomes SUCCESS = True FAIL = False # Initialize Comm Port SER_CONN0 = c12serial.SERCONN(debug=DEBUG) SER_CONN0.serInit(port=COMM_PORT, baud=COMM_BAUD, invert=INVERT) # Setup and configure packet packet = c12packet.C1218_packet() packet.set_debug(DEBUG) packet.set_nego(NEGO_ON) if action == "test_login": '''Test login to determine if password works''' print "Running test_login function" if DEBUG: print "Start Delay:", start_delay c12packet.delay(start_delay) if not packet.login_setup(ser_conn0): print action, ': login_setup failed.' sys.exit() if not packet.login_seq_passwd(ser_conn0, USER_NUM, PASSWD): print action, ': login_seq_passwd failed.'
def config_packet(self): '''Setup C12.18 packet.''' packet = c12packet.C1218_packet() return packet