// Print common packet header information
 static void printPacket(BeagleUsb5000Source source,
                         byte[]              packet,
                         byte[]              k_packet_data,
                         int length)
 {
     if (source == BeagleUsb5000Source.BG_USB5000_SOURCE_USB2)
     {
         Console.Write("{0:s}", usbPrintUsb2DataPacket(packet, length));
     }
     else
     {
         Console.Write("{0:s}", usbPrintUsb3DataPacket(packet,
                                                       k_packet_data,
                                                       length));
     }
     Console.Out.Flush();
 }
    static void printSource(BeagleUsb5000Source source)
    {
        switch (source)
        {
        case BeagleUsb5000Source.BG_USB5000_SOURCE_ASYNC:
            Console.Write("Async");
            break;

        case BeagleUsb5000Source.BG_USB5000_SOURCE_RX:
            Console.Write("SSRX");
            break;

        case BeagleUsb5000Source.BG_USB5000_SOURCE_TX:
            Console.Write("SSTX");
            break;

        case BeagleUsb5000Source.BG_USB5000_SOURCE_USB2:
            Console.Write("USB2");
            break;
        }
    }
    static void usbDump(int numPackets)
    {
        // Setup variables
        byte[] packet      = new byte[1036];
        byte[] packetKBits = new byte[130];

        int packetnum = 0;
        int tries     = 10;

        BeagleUsb5000CaptureStatus captureStatus =
            BeagleUsb5000CaptureStatus.BG_USB5000_CAPTURE_STATUS_INACTIVE;
        uint pretrigAmt   = 0;
        uint pretrigTotal = 0;
        uint capAmt       = 0;
        uint capTotal     = 0;

        // Disable VBUS to device
        BeagleApi.bg_usb5000_target_power(
            beagle, BeagleUsbTargetPower.BG_USB5000_TARGET_POWER_OFF);

        // Start the capture
        if (BeagleApi.bg_enable(beagle, BeagleProtocol.BG_PROTOCOL_USB) !=
            (int)BeagleStatus.BG_OK)
        {
            Console.Write("error: could not enable USB capture; exiting...\n");
            Environment.Exit(1);
        }

        // Disable VBUS to device
        BeagleApi.bg_usb5000_target_power(
            beagle, BeagleUsbTargetPower.BG_USB5000_TARGET_POWER_HOST_SUPPLIED);

        // Wait for the analyzer to trigger for up to 10 seconds...
        while (tries != 0)
        {
            if (BeagleApi.bg_usb5000_usb3_capture_status(
                    beagle, 1000, ref captureStatus,
                    ref pretrigAmt, ref pretrigTotal,
                    ref capAmt, ref capTotal) !=
                (int)BeagleStatus.BG_OK)
            {
                Console.Write(
                    "error: could not query capture status; exiting...\n");
                Environment.Exit(1);
            }

            if (captureStatus <= BeagleUsb5000CaptureStatus.
                BG_USB5000_CAPTURE_STATUS_PRE_TRIGGER)
            {
                Console.Write("waiting for trigger...\n");
            }
            else
            {
                break;
            }

            tries--;
        }

        if (tries == 0)
        {
            Console.Write("did not trigger, make sure a host and a device " +
                          "is connected to the analyzer.\n");
            Environment.Exit(1);
        }

        Console.Write(
            "index,time(ns),source,event,status,data0 ... dataN(*)\n");
        Console.Out.Flush();

        // ...then start decoding packets
        while (packetnum < numPackets || (numPackets == 0))
        {
            uint  status               = 0;
            uint  events               = 0;
            ulong timeSop              = 0;
            ulong timeDuration         = 0;
            uint  timeDataOffset       = 0;
            BeagleUsb5000Source source =
                BeagleUsb5000Source.BG_USB5000_SOURCE_ASYNC;

            int length = BeagleApi.bg_usb5000_read(
                beagle,
                ref status, ref events, ref timeSop, ref timeDuration,
                ref timeDataOffset, ref source,
                1036, packet, 130, packetKBits);

            // Make sure capture is triggered.
            if (length == (int)BeagleStatus.BG_CAPTURE_NOT_TRIGGERED)
            {
                continue;
            }

            // Check for invalid packet or Beagle error
            if (length < 0)
            {
                Console.Write("error={0:d}\n", length);
                break;
            }

            // Exit if observed end of capture
            if (status == BeagleApi.BG_READ_USB_END_OF_CAPTURE)
            {
                Console.Write("\n");
                Console.Write("End of capture\n");
                break;
            }

            // Grab the next packet on a timeout.
            if (length == 0 &&
                status == BeagleApi.BG_READ_TIMEOUT &&
                events == 0)
            {
                continue;
            }

            // Print the packet details
            Console.Write("{0},", packetnum);
            Console.Write("{0},", timestampToNS(timeSop, samplerateKHz));
            printSource(source);
            Console.Write(",");
            printEvents(source, events);
            Console.Write(",");
            printStatus(source, status);
            Console.Write(",");
            printPacket(source, packet, packetKBits, length);
            Console.Write("\n");

            packetnum++;
        }

        // Stop the capture
        BeagleApi.bg_disable(beagle);
    }
    static void printEvents(BeagleUsb5000Source source, uint events)
    {
        // Print USB 2 events
        if (source == BeagleUsb5000Source.BG_USB5000_SOURCE_USB2)
        {
            printUsb2Events(events);
            return;
        }

        // Print USB 3 and Asynch events
        if ((events & BeagleApi.BG_EVENT_USB_LTSSM) != 0)
        {
            uint evt_idx = events & BeagleApi.BG_EVENT_USB_LTSSM_MASK;
            if (evt_idx < LTSSM_TABLE.Length)
            {
                Console.Write("LTSSM Transition: {0:s}; ",
                              LTSSM_TABLE[evt_idx]);
            }
            else
            {
                Console.Write("Unknown LTSSM Transition: {0:d}; ", evt_idx);
            }
        }

        if ((events & BeagleApi.BG_EVENT_USB_COMPLEX_TRIGGER) != 0)
        {
            Console.Write("{0:s} trigger from state: {1:d}; ",
                          (events & BeagleApi.BG_EVENT_USB_TRIGGER_TIMER) != 0 ?
                          "Timer" : "Complex",
                          events & BeagleApi.BG_EVENT_USB_TRIGGER_STATE_MASK);
        }

        if ((events & BeagleApi.BG_EVENT_USB_VBUS_PRESENT) != 0)
        {
            Console.Write("VBUS Present; ");
        }

        if ((events & BeagleApi.BG_EVENT_USB_VBUS_ABSENT) != 0)
        {
            Console.Write("VBUS Absent; ");
        }

        if ((events & BeagleApi.BG_EVENT_USB_SCRAMBLING_ENABLED) != 0)
        {
            Console.Write("Scrambling On; ");
        }

        if ((events & BeagleApi.BG_EVENT_USB_SCRAMBLING_DISABLED) != 0)
        {
            Console.Write("Scrambling Off; ");
        }

        if ((events & BeagleApi.BG_EVENT_USB_POLARITY_NORMAL) != 0)
        {
            Console.Write("Polarity Normal; ");
        }

        if ((events & BeagleApi.BG_EVENT_USB_POLARITY_REVERSED) != 0)
        {
            Console.Write("Polarity Reversed; ");
        }

        if ((events & BeagleApi.BG_EVENT_USB_PHY_ERROR) != 0)
        {
            Console.Write("PHY Error; ");
        }

        if ((events & BeagleApi.BG_EVENT_USB_HOST_DISCONNECT) != 0)
        {
            Console.Write("SS Host Discon; ");
        }

        if ((events & BeagleApi.BG_EVENT_USB_HOST_CONNECT) != 0)
        {
            Console.Write("SS Host Conn; ");
        }

        if ((events & BeagleApi.BG_EVENT_USB_TARGET_DISCONNECT) != 0)
        {
            Console.Write("SS Trgt Discon; ");
        }

        if ((events & BeagleApi.BG_EVENT_USB_TARGET_CONNECT) != 0)
        {
            Console.Write("SS Trgt Conn; ");
        }

        if ((events & BeagleApi.BG_EVENT_USB_LFPS) != 0)
        {
            Console.Write("LFPS; ");
        }

        if ((events & BeagleApi.BG_EVENT_USB_TRIGGER) != 0)
        {
            Console.Write("Trigger; ");
        }

        if ((events & BeagleApi.BG_EVENT_USB_EXT_TRIG_ASSERTED) != 0)
        {
            Console.Write("Ext In Asserted; ");
        }

        if ((events & BeagleApi.BG_EVENT_USB_EXT_TRIG_DEASSERTED) != 0)
        {
            Console.Write("Ext In Deasserted; ");
        }
    }
 static void printStatus(BeagleUsb5000Source source, uint status)
 {
     printGeneralStatus(status);
     printUsbStatus(source, status);
 }
    static void printUsbStatus(BeagleUsb5000Source source, uint status)
    {
        if (source == BeagleUsb5000Source.BG_USB5000_SOURCE_USB2)
        {
            // USB 2 status codes
            if ((status & BeagleApi.BG_READ_USB_ERR_BAD_SIGNALS) != 0)
            {
                Console.Write("BAD_SIGNAL; ");
            }

            if ((status & BeagleApi.BG_READ_USB_ERR_BAD_SYNC) != 0)
            {
                Console.Write("BAD_SYNC; ");
            }

            if ((status & BeagleApi.BG_READ_USB_ERR_BIT_STUFF) != 0)
            {
                Console.Write("BAD_STUFF; ");
            }

            if ((status & BeagleApi.BG_READ_USB_ERR_FALSE_EOP) != 0)
            {
                Console.Write("BAD_EOP; ");
            }

            if ((status & BeagleApi.BG_READ_USB_ERR_LONG_EOP) != 0)
            {
                Console.Write("LONG_EOP; ");
            }

            if ((status & BeagleApi.BG_READ_USB_ERR_BAD_PID) != 0)
            {
                Console.Write("BAD_PID; ");
            }

            if ((status & BeagleApi.BG_READ_USB_ERR_BAD_CRC) != 0)
            {
                Console.Write("BAD_CRC; ");
            }

            if ((status & BeagleApi.BG_READ_USB_TRUNCATION_MODE) != 0)
            {
                Console.Write("TRUNCATION_MODE; ");
            }
        }
        else
        {
            // USB 3 status codes
            if ((status & BeagleApi.BG_READ_USB_PKT_TYPE_LINK) != 0)
            {
                Console.Write("LINK; ");
                if ((status & BeagleApi.BG_READ_USB_ERR_BAD_SLC_CRC_1) != 0)
                {
                    Console.Write("BAD_SLC_CRC_1; ");
                }
                if ((status & BeagleApi.BG_READ_USB_ERR_BAD_SLC_CRC_2) != 0)
                {
                    Console.Write("BAD_SLC_CRC_2; ");
                }
            }

            if ((status & BeagleApi.BG_READ_USB_PKT_TYPE_DP) != 0)
            {
                Console.Write("DATA; ");
                if ((status & BeagleApi.BG_READ_USB_ERR_BAD_SDP_CRC) != 0)
                {
                    Console.Write("BAD_SDP_CRC; ");
                }
                if ((status & BeagleApi.BG_READ_USB_EDB_FRAMING) != 0)
                {
                    Console.Write("SDP_EDB_FRAME; ");
                }
            }

            if ((status & BeagleApi.BG_READ_USB_PKT_TYPE_HDR) != 0)
            {
                Console.Write("HDR; ");
                if ((status & BeagleApi.BG_READ_USB_ERR_BAD_SHP_CRC_16) != 0)
                {
                    Console.Write("BAD_SHP_CRC_16; ");
                }
                if ((status & BeagleApi.BG_READ_USB_ERR_BAD_SHP_CRC_5) != 0)
                {
                    Console.Write("BAD_SHP_CRC_5; ");
                }
            }

            if ((status & BeagleApi.BG_READ_USB_PKT_TYPE_TSEQ) != 0)
            {
                Console.Write("TSEQ; ");
            }
            if ((status & BeagleApi.BG_READ_USB_PKT_TYPE_TS1) != 0)
            {
                Console.Write("TS1; ");
            }
            if ((status & BeagleApi.BG_READ_USB_PKT_TYPE_TS2) != 0)
            {
                Console.Write("TS2; ");
            }

            if ((status & BeagleApi.BG_READ_USB_ERR_UNK_END_OF_FRAME) != 0)
            {
                Console.Write("BAD_UNK_EOF; ");
            }
            if ((status & BeagleApi.BG_READ_USB_ERR_DATA_LEN_INVALID) != 0)
            {
                Console.Write("BAD_DATA_LEN; ");
            }
            if ((status & BeagleApi.BG_READ_USB_ERR_BAD_TS) != 0)
            {
                Console.Write("BAD_TS; ");
            }
            if ((status & BeagleApi.BG_READ_USB_ERR_FRAMING) != 0)
            {
                Console.Write("FRAME_ERROR; ");
            }
        }
    }
Example #7
0
    static void usbDump(int numPackets, byte capMask)
    {
        // Setup variables
        byte[] packet      = new byte[1036];
        byte[] packetKBits = new byte[130];

        int packetnum = 0;

        BeagleUsb5000CaptureStatus captureStatus =
            BeagleUsb5000CaptureStatus.BG_USB5000_CAPTURE_STATUS_INACTIVE;
        uint pretrigAmt   = 0;
        uint pretrigTotal = 0;
        uint capAmt       = 0;
        uint capTotal     = 0;
        int  ret          = 0;

        #if STATS_MODE
        // Statistic mode variables
        ulong dispTimeSop     = 0;
        ulong sstxByteCount   = 0;
        ulong ssrxByteCount   = 0;
        ulong sstxPacketCount = 0;
        ulong ssrxPacketCount = 0;
        ulong usb2ByteCount   = 0;
        ulong usb2PacketCount = 0;
        #endif

        // Configure Beagle 480 for realtime capture
        if (BeagleApi.bg_usb5000_configure(
                beagle, capMask,
                BeagleUsb5000TriggerMode.BG_USB5000_TRIGGER_MODE_IMMEDIATE) !=
            (int)BeagleStatus.BG_OK)
        {
            Console.Write(
                "error: could not configure Beagle 5000 with desired mode\n");
            Environment.Exit(1);
        }

        // Start the capture
        if (BeagleApi.bg_enable(beagle, BeagleProtocol.BG_PROTOCOL_USB) !=
            (int)BeagleStatus.BG_OK)
        {
            Console.Write("error: could not enable USB capture; exiting...\n");
            Environment.Exit(1);
        }

        // Wait for the analyzer to trigger for up to 2 seconds...
        if ((capMask & BeagleApi.BG_USB5000_CAPTURE_USB2) != 0)
        {
            ret = BeagleApi.bg_usb5000_usb2_capture_status(
                beagle, 2000, ref captureStatus,
                ref pretrigAmt, ref pretrigTotal,
                ref capAmt, ref capTotal);
        }
        else
        {
            ret = BeagleApi.bg_usb5000_usb3_capture_status(
                beagle, 2000, ref captureStatus,
                ref pretrigAmt, ref pretrigTotal,
                ref capAmt, ref capTotal);
        }

        if (ret != (int)BeagleStatus.BG_OK)
        {
            Console.Write(
                "error: could not query capture status; exiting...\n");
            Environment.Exit(1);
        }

        if (captureStatus <= BeagleUsb5000CaptureStatus.
            BG_USB5000_CAPTURE_STATUS_PRE_TRIGGER)
        {
            Console.Write("did not trigger.\n");
            Environment.Exit(1);
        }

        // Output the header...
        #if STATS_MODE
        Console.Write(
            "   SSTX PACKETS ( MB/s )    SSRX PACKETS ( MB/s )    USB2 PACKETS ( MB/s )\n");
        #else
        Console.Write(
            "index,time(ns),source,event,status,data0 ... dataN(*)\n");
        #endif
        Console.Out.Flush();

        // ...then start decoding packets
        while (packetnum < numPackets || (numPackets == 0))
        {
            uint  status               = 0;
            uint  events               = 0;
            ulong timeSop              = 0;
            ulong timeDuration         = 0;
            uint  timeDataOffset       = 0;
            BeagleUsb5000Source source =
                BeagleUsb5000Source.BG_USB5000_SOURCE_ASYNC;

            int length = BeagleApi.bg_usb5000_read(
                beagle,
                ref status, ref events, ref timeSop, ref timeDuration,
                ref timeDataOffset, ref source,
                1036, packet, 130, packetKBits);

            // Make sure capture is triggered.
            if (length == (int)BeagleStatus.BG_CAPTURE_NOT_TRIGGERED)
            {
                continue;
            }

            // Check for invalid packet or Beagle error
            if (length < 0)
            {
                Console.Write("error={0:d}\n", length);
                break;
            }

            // Exit if observed end of capture
            if (status == BeagleApi.BG_READ_USB_END_OF_CAPTURE)
            {
                Console.Write("\n");
                Console.Write("End of capture\n");
                break;
            }

            #if STATS_MODE
            // Count the number of packets and bytes
            if (length > 0)
            {
                switch (source)
                {
                case BeagleUsb5000Source.BG_USB5000_SOURCE_USB2:
                    usb2PacketCount++;
                    usb2ByteCount += (ulong)length;
                    break;

                case BeagleUsb5000Source.BG_USB5000_SOURCE_TX:
                    sstxPacketCount++;
                    sstxByteCount += (ulong)length;
                    break;

                case BeagleUsb5000Source.BG_USB5000_SOURCE_RX:
                    ssrxPacketCount++;
                    ssrxByteCount += (ulong)length;
                    break;

                default:
                    break;
                }
            }

            // Periodically print out the stats
            if ((timeSop - dispTimeSop) > DISPLAY_TIME_TICKS)
            {
                double timeS = (double)timestampToNS(timeSop - dispTimeSop,
                                                     samplerateKHz) / 1E9;
                double sstxMBps =
                    ((double)sstxByteCount) / (1024 * 1024L) / timeS;
                double ssrxMBps =
                    ((double)ssrxByteCount) / (1024 * 1024L) / timeS;
                double usb2MBps =
                    ((double)usb2ByteCount) / (1024 * 1024L) / timeS;

                Console.Write("\r{0,15:d} ({1,6:##0.00})" +
                              " {2,15:d} ({3,6:##0.00})" +
                              " {4,15:d} ({5,6:##0.00})",
                              sstxPacketCount, sstxMBps,
                              ssrxPacketCount, ssrxMBps,
                              usb2PacketCount, usb2MBps);

                sstxByteCount = 0;
                ssrxByteCount = 0;
                usb2ByteCount = 0;
                dispTimeSop   = timeSop;
            }
            #else
            // Grab the next packet on a timeout.
            if (length == 0 &&
                status == BeagleApi.BG_READ_TIMEOUT &&
                events == 0)
            {
                continue;
            }

            // Print the packet details
            Console.Write("{0},", packetnum);
            Console.Write("{0},", timestampToNS(timeSop, samplerateKHz));
            printSource(source);
            Console.Write(",");
            printEvents(source, events);
            Console.Write(",");
            printStatus(source, status);
            Console.Write(",");
            printPacket(source, packet, packetKBits, length);
            Console.Write("\n");
            #endif

            packetnum++;
        }

        // Stop the capture
        BeagleApi.bg_disable(beagle);
    }
    static void printUsbStatus(BeagleUsb5000Source source, uint status)
    {
        if (source == BeagleUsb5000Source.BG_USB5000_SOURCE_USB2) {
            // USB 2 status codes
            if ((status & BeagleApi.BG_READ_USB_ERR_BAD_SIGNALS) != 0)
                Console.Write("BAD_SIGNAL; ");

            if ((status & BeagleApi.BG_READ_USB_ERR_BAD_SYNC) != 0)
                Console.Write("BAD_SYNC; ");

            if ((status & BeagleApi.BG_READ_USB_ERR_BIT_STUFF) != 0)
                Console.Write("BAD_STUFF; ");

            if ((status & BeagleApi.BG_READ_USB_ERR_FALSE_EOP) != 0)
                Console.Write("BAD_EOP; ");

            if ((status & BeagleApi.BG_READ_USB_ERR_LONG_EOP) != 0)
                Console.Write("LONG_EOP; ");

            if ((status & BeagleApi.BG_READ_USB_ERR_BAD_PID) != 0)
                Console.Write("BAD_PID; ");

            if ((status & BeagleApi.BG_READ_USB_ERR_BAD_CRC) != 0)
                Console.Write("BAD_CRC; ");

            if ((status & BeagleApi.BG_READ_USB_TRUNCATION_MODE) != 0)
                Console.Write("TRUNCATION_MODE; ");
        }
        else {
            // USB 3 status codes
            if ((status & BeagleApi.BG_READ_USB_PKT_TYPE_LINK) != 0) {
                Console.Write("LINK; ");
                if ((status & BeagleApi.BG_READ_USB_ERR_BAD_SLC_CRC_1) != 0)
                    Console.Write("BAD_SLC_CRC_1; ");
                if ((status & BeagleApi.BG_READ_USB_ERR_BAD_SLC_CRC_2) != 0)
                    Console.Write("BAD_SLC_CRC_2; ");
            }

            if ((status & BeagleApi.BG_READ_USB_PKT_TYPE_DP) != 0) {
                Console.Write("DATA; ");
                if ((status & BeagleApi.BG_READ_USB_ERR_BAD_SDP_CRC) != 0)
                    Console.Write("BAD_SDP_CRC; ");
                if ((status & BeagleApi.BG_READ_USB_EDB_FRAMING) != 0)
                    Console.Write("SDP_EDB_FRAME; ");
            }

            if ((status & BeagleApi.BG_READ_USB_PKT_TYPE_HDR) != 0) {
                Console.Write("HDR; ");
                if ((status & BeagleApi.BG_READ_USB_ERR_BAD_SHP_CRC_16) != 0)
                    Console.Write("BAD_SHP_CRC_16; ");
                if ((status & BeagleApi.BG_READ_USB_ERR_BAD_SHP_CRC_5) != 0)
                    Console.Write("BAD_SHP_CRC_5; ");
            }

            if ((status & BeagleApi.BG_READ_USB_PKT_TYPE_TSEQ) != 0)
                Console.Write("TSEQ; ");
            if ((status & BeagleApi.BG_READ_USB_PKT_TYPE_TS1) != 0)
                Console.Write("TS1; ");
            if ((status & BeagleApi.BG_READ_USB_PKT_TYPE_TS2) != 0)
                Console.Write("TS2; ");

            if ((status & BeagleApi.BG_READ_USB_ERR_UNK_END_OF_FRAME) != 0)
                Console.Write("BAD_UNK_EOF; ");
            if ((status & BeagleApi.BG_READ_USB_ERR_DATA_LEN_INVALID) != 0)
                Console.Write("BAD_DATA_LEN; ");
            if ((status & BeagleApi.BG_READ_USB_ERR_BAD_TS) != 0)
                Console.Write("BAD_TS; ");
            if ((status & BeagleApi.BG_READ_USB_ERR_FRAMING) != 0)
                Console.Write("FRAME_ERROR; ");
        }
    }
 static void printStatus(BeagleUsb5000Source source, uint status)
 {
     printGeneralStatus(status);
     printUsbStatus(source, status);
 }
    static void printSource(BeagleUsb5000Source source)
    {
        switch (source) {
          case BeagleUsb5000Source.BG_USB5000_SOURCE_ASYNC:
            Console.Write("Async");
            break;

          case BeagleUsb5000Source.BG_USB5000_SOURCE_RX:
            Console.Write("SSRX");
            break;
          case BeagleUsb5000Source.BG_USB5000_SOURCE_TX:
            Console.Write("SSTX");
            break;
          case BeagleUsb5000Source.BG_USB5000_SOURCE_USB2:
            Console.Write("USB2");
            break;
        }
    }
 // Print common packet header information
 static void printPacket(BeagleUsb5000Source source,
     byte[]              packet,
     byte[]              k_packet_data,
     int                 length)
 {
     if (source == BeagleUsb5000Source.BG_USB5000_SOURCE_USB2)
         Console.Write("{0:s}", usbPrintUsb2DataPacket(packet, length));
     else {
         Console.Write("{0:s}", usbPrintUsb3DataPacket(packet,
                                                       k_packet_data,
                                                       length));
     }
     Console.Out.Flush();
 }
    static void printEvents(BeagleUsb5000Source source, uint events)
    {
        // Print USB 2 events
        if (source == BeagleUsb5000Source.BG_USB5000_SOURCE_USB2) {
            printUsb2Events(events);
            return;
        }

        // Print USB 3 and Asynch events
        if ((events & BeagleApi.BG_EVENT_USB_LTSSM) != 0) {
            uint evt_idx = events & BeagleApi.BG_EVENT_USB_LTSSM_MASK;
            if (evt_idx < LTSSM_TABLE.Length) {
                Console.Write("LTSSM Transition: {0:s}; ",
                              LTSSM_TABLE[evt_idx]);
            }
            else
                Console.Write("Unknown LTSSM Transition: {0:d}; ", evt_idx);
        }

        if ((events & BeagleApi.BG_EVENT_USB_COMPLEX_TRIGGER) != 0) {
            Console.Write("{0:s} trigger from state: {1:d}; ",
                          (events & BeagleApi.BG_EVENT_USB_TRIGGER_TIMER) != 0 ?
                          "Timer" : "Complex",
                   events & BeagleApi.BG_EVENT_USB_TRIGGER_STATE_MASK);
        }

        if ((events & BeagleApi.BG_EVENT_USB_VBUS_PRESENT) != 0)
            Console.Write("VBUS Present; ");

        if ((events & BeagleApi.BG_EVENT_USB_VBUS_ABSENT) != 0)
            Console.Write("VBUS Absent; ");

        if ((events & BeagleApi.BG_EVENT_USB_SCRAMBLING_ENABLED) != 0)
            Console.Write("Scrambling On; ");

        if ((events & BeagleApi.BG_EVENT_USB_SCRAMBLING_DISABLED) != 0)
            Console.Write("Scrambling Off; ");

        if ((events & BeagleApi.BG_EVENT_USB_POLARITY_NORMAL) != 0)
            Console.Write("Polarity Normal; ");

        if ((events & BeagleApi.BG_EVENT_USB_POLARITY_REVERSED) != 0)
            Console.Write("Polarity Reversed; ");

        if ((events & BeagleApi.BG_EVENT_USB_PHY_ERROR) != 0)
            Console.Write("PHY Error; ");

        if ((events & BeagleApi.BG_EVENT_USB_HOST_DISCONNECT) != 0)
            Console.Write("SS Host Discon; ");

        if ((events & BeagleApi.BG_EVENT_USB_HOST_CONNECT) != 0)
            Console.Write("SS Host Conn; ");

        if ((events & BeagleApi.BG_EVENT_USB_TARGET_DISCONNECT) != 0)
            Console.Write("SS Trgt Discon; ");

        if ((events & BeagleApi.BG_EVENT_USB_TARGET_CONNECT) != 0)
            Console.Write("SS Trgt Conn; ");

        if ((events & BeagleApi.BG_EVENT_USB_LFPS) != 0)
            Console.Write("LFPS; ");

        if ((events & BeagleApi.BG_EVENT_USB_TRIGGER) != 0)
            Console.Write("Trigger; ");

        if ((events & BeagleApi.BG_EVENT_USB_EXT_TRIG_ASSERTED) != 0)
            Console.Write("Ext In Asserted; ");

        if ((events & BeagleApi.BG_EVENT_USB_EXT_TRIG_DEASSERTED) != 0)
            Console.Write("Ext In Deasserted; ");
    }