Exemple #1
0
        public void Finish()
        {
            inShutdown = true;
            Thread.Sleep(1000);

            if (isEnabled)
            {
                BeagleApi.bg_disable(hBeagle);
            }

            if (isOpened)
            {
                BeagleApi.bg_close(hBeagle);
            }
        }
    /*=====================================================================
     | MAIN PROGRAM
     | ====================================================================*/
    public static void Main(String[] args)
    {
        int  port    = 0;      // open port 0 by default
        uint timeout = 100;    // in milliseconds
        uint latency = 200;    // in milliseconds
        int  num     = 0;

        if (args.Length < 1)
        {
            printUsage();
            Environment.Exit(1);
        }

        num = Convert.ToInt32(args[0]);

        // Open the device
        beagle = BeagleApi.bg_open(port);
        if (beagle <= 0)
        {
            Console.Write("Unable to open Beagle device on port {0:d}\n", port);
            Console.Write("Error code = {0:d}\n", beagle);
            Environment.Exit(1);
        }
        Console.Write("Opened Beagle device on port {0:d}\n", port);

        // Query the samplerate since Beagle USB has a fixed sampling rate
        samplerateKHz = BeagleApi.bg_samplerate(beagle, samplerateKHz);
        if (samplerateKHz < 0)
        {
            Console.Write("error: {0:s}\n",
                          BeagleApi.bg_status_string(samplerateKHz));
            Environment.Exit(1);
        }
        Console.Write("Sampling rate set to {0:d} KHz.\n", samplerateKHz);

        // Set the idle timeout.
        // The Beagle read functions will return in the specified time
        // if there is no data available on the bus.
        BeagleApi.bg_timeout(beagle, timeout);
        Console.Write("Idle timeout set to {0:d} ms.\n", timeout);

        // Set the latency.
        // The latency parameter allows the programmer to balance the
        // tradeoff between host side buffering and the latency to
        // receive a packet when calling one of the Beagle read
        // functions.
        BeagleApi.bg_latency(beagle, latency);
        Console.Write("Latency set to {0:d} ms.\n", latency);

        Console.Write("Host interface is {0:s}.\n",
                      ((BeagleApi.bg_host_ifce_speed(beagle)) != 0) ?
                      "high speed" : "full speed");

        Console.Write("\n");
        Console.Out.Flush();

        // Configure the capture buffer
        usbConfigBuffer();

        // Configure the complex match
        usbConfigComplexMatch();

        usbDump(num);

        // Close the device
        BeagleApi.bg_close(beagle);

        return;
    }
Exemple #3
0
    /*=====================================================================
     | MAIN PROGRAM
     | ====================================================================*/
    public static void Main(String[] args)
    {
        int  port       = 0;     // open port 0 by default
        int  samplerate = 10000; // in kHz
        uint timeout    = 500;   // in milliseconds
        uint latency    = 200;   // in milliseconds
        int  len        = 0;
        int  num        = 0;

        if (args.Length < 2)
        {
            print_usage();
            Environment.Exit(1);
        }
        len = Convert.ToInt32(args[0]);
        num = Convert.ToInt32(args[1]);

        // Open the device
        beagle = BeagleApi.bg_open(port);
        if (beagle <= 0)
        {
            Console.Write("Unable to open Beagle device on port {0:d}\n",
                          port);
            Console.Write("Error code = {0:d}\n", beagle);
            Environment.Exit(1);
        }
        Console.Write("Opened Beagle device on port {0:d}\n", port);

        // Set the samplerate
        samplerate = BeagleApi.bg_samplerate(beagle, samplerate);
        if (samplerate < 0)
        {
            Console.Write("error: {0:s}\n",
                          BeagleApi.bg_status_string(samplerate));
            Environment.Exit(1);
        }
        Console.Write("Sampling rate set to {0:d} KHz.\n", samplerate);

        // Set the idle timeout.
        // The Beagle read functions will return in the specified time
        // if there is no data available on the bus.
        BeagleApi.bg_timeout(beagle, timeout);
        Console.Write("Idle timeout set to {0:d} ms.\n", timeout);

        // Set the latency.
        // The latency parameter allows the programmer to balance the
        // tradeoff between host side buffering and the latency to
        // receive a packet when calling one of the Beagle read
        // functions.
        BeagleApi.bg_latency(beagle, latency);
        Console.Write("Latency set to {0:d} ms.\n", latency);

        Console.Write("Host interface is {0:s}.\n",
                      ((BeagleApi.bg_host_ifce_speed(beagle)) != 0) ? "high speed" :
                      "full speed");
        // Configure the device for SPI
        BeagleApi.bg_spi_configure(
            beagle,
            BeagleSpiSSPolarity.BG_SPI_SS_ACTIVE_LOW,
            BeagleSpiSckSamplingEdge.BG_SPI_SCK_SAMPLING_EDGE_RISING,
            BeagleSpiBitorder.BG_SPI_BITORDER_MSB);

        // There is usually no need for target power when using the
        // Beagle as a passive monitor.
        BeagleApi.bg_target_power(beagle, BeagleApi.BG_TARGET_POWER_OFF);

        Console.Write("\n");
        Console.Out.Flush();

        spidump(len, num);

        // Close the device
        BeagleApi.bg_close(beagle);

        return;
    }