Example #1
0
def send_handler(channel, data):
    msg = jtag_t.decode(data)
    #print("Message on channel \"%s\"" % channel)
    print (bcolors.OKBLUE + "\x1b[0G\x1b[2K>> %u.%u\033[93m" \
        " Address[%u, 0x%02X]\033[92m Data[%u, 0x%08X]\033[0m" \
        % (msg.seconds, msg.microseconds, msg.address, msg.address, \
            msg.data , msg.data))
Example #2
0
def rec_handler(channel, data):
    global data_count
    msg = jtag_t.decode(data)
    #print("Message on channel \"%s\"" % channel)
    print (bcolors.OKBLUE + "\x1b[0G\x1b[2K<< %u.%u\033[93m" \
    	" Address[%u, 0x%02X]\033[92m Data[%u, 0x%08X]\033[0m" \
    	% (msg.seconds, msg.microseconds, msg.address, msg.address, \
    		msg.data , msg.data))

    if(msg.address == 9):
        # Closed Loop Debugging

        motor_position = msg.data%21845
        motor_position_cmd = 1024-(motor_position/21845.0)*1024.0
        print ("Loop Debugging: %u, %u, %u" % (msg.data, motor_position, motor_position_cmd))

        data_count = data_count + 1
        with open('resolver_log.csv', 'a') as csvfile:
            logwriter = csv.writer(csvfile, delimiter=' ',
                            quotechar='|', quoting=csv.QUOTE_MINIMAL)
            time = msg.seconds + (msg.microseconds*pow(10,-6))
            logwriter.writerow([data_count, msg.data])

    elif(msg.address == 16):
        # Closed Loop Debugging
        
        data_count = data_count + 1
        with open('delta_log.csv', 'a') as csvfile:
            logwriter = csv.writer(csvfile, delimiter=' ',
                            quotechar='|', quoting=csv.QUOTE_MINIMAL)
            time = msg.seconds + (msg.microseconds*pow(10,-6))
            logwriter.writerow([data_count, msg.data])

    elif(msg.address == 17):
        # Closed Loop Debugging
        
        data_count = data_count + 1
        with open('torque_log.csv', 'a') as csvfile:
            logwriter = csv.writer(csvfile, delimiter=' ',
                            quotechar='|', quoting=csv.QUOTE_MINIMAL)
            time = msg.seconds + (msg.microseconds*pow(10,-6))
            logwriter.writerow([data_count, msg.data])

    elif(msg.address == 18):
        # Closed Loop Debugging
        
        data_count = data_count + 1
        with open('u_log.csv', 'a') as csvfile:
            logwriter = csv.writer(csvfile, delimiter=' ',
                            quotechar='|', quoting=csv.QUOTE_MINIMAL)
            time = msg.seconds + (msg.microseconds*pow(10,-6))
            logwriter.writerow([data_count, msg.data])
    elif(msg.address == 20):
        # Closed Loop Debugging
        
        data_count = data_count + 1
        with open('v_log.csv', 'a') as csvfile:
            logwriter = csv.writer(csvfile, delimiter=' ',
                            quotechar='|', quoting=csv.QUOTE_MINIMAL)
            time = msg.seconds + (msg.microseconds*pow(10,-6))
            logwriter.writerow([data_count, msg.data])
    elif(msg.address == 22):
        # Closed Loop Debugging
        
        data_count = data_count + 1
        with open('w_log.csv', 'a') as csvfile:
            logwriter = csv.writer(csvfile, delimiter=' ',
                            quotechar='|', quoting=csv.QUOTE_MINIMAL)
            time = msg.seconds + (msg.microseconds*pow(10,-6))
            logwriter.writerow([data_count, msg.data])

    elif(msg.address == 26):
        # Position Loop Debugging
        data_count = data_count + 1
        with open('error_log.csv', 'a') as csvfile:
            logwriter = csv.writer(csvfile, delimiter=' ',
                            quotechar='|', quoting=csv.QUOTE_MINIMAL)
            time = msg.seconds + (msg.microseconds*pow(10,-6))
            logwriter.writerow([data_count, msg.data])

    elif(msg.address == 31):
        # PID Debugging
        data_count = data_count + 1
        with open('pid_log.csv', 'a') as csvfile:
            logwriter = csv.writer(csvfile, delimiter=' ',
                            quotechar='|', quoting=csv.QUOTE_MINIMAL)
            time = msg.seconds + (msg.microseconds*pow(10,-6))
            logwriter.writerow([data_count, msg.data])

    elif(msg.address == 37):
        # Absolute Position Debugging
        data_count = data_count + 1
        with open('absolute_log.csv', 'a') as csvfile:
            logwriter = csv.writer(csvfile, delimiter=' ',
                            quotechar='|', quoting=csv.QUOTE_MINIMAL)
            time = msg.seconds + (msg.microseconds*pow(10,-6))
            logwriter.writerow([data_count, msg.data])

    else:
        with open('command_log.csv', 'a') as csvfile:
            logwriter = csv.writer(csvfile, delimiter=' ',
                            quotechar='|', quoting=csv.QUOTE_MINIMAL)
            time = msg.seconds + (msg.microseconds*pow(10,-6))
            logwriter.writerow([data_count, msg.address, msg.data])

    with open('full_log.csv', 'a') as csvfile:
            logwriter = csv.writer(csvfile, delimiter=' ',
                            quotechar='|', quoting=csv.QUOTE_MINIMAL)
            time = msg.seconds + (msg.microseconds*pow(10,-6))
            logwriter.writerow([data_count, msg.address, msg.data])