Пример #1
0
        static void Main(string[] args)
        {
            string reply;

            try
            {
                // Pass in a reader hostname or IP address as a
                // command line argument when running the example
                if (args.Length != 1)
                {
                    Console.WriteLine("Error: No hostname specified.  Pass in the reader hostname as a command line argument when running the Sdk Example.");
                    return;
                }
                string hostname = args[0];

                // Open up an RShell connection on the reader.
                // Specify the reader address, user name, password and connection timeout.
                reader.RShell.OpenSecureSession(hostname, "root", "impinj", 5000);

                // Send an RShell command
                RShellCmdStatus status = reader.RShell.Send("show network summary", out reply);

                // Check the status
                if (status == RShellCmdStatus.Success)
                {
                    Console.WriteLine("RShell command executed successfully.\n");
                }
                else
                {
                    Console.WriteLine("RShell command failed to execute.\n");
                }

                // Print out the entire reply.
                Console.WriteLine("RShell command reply : \n\n" + reply + "\n");

                // Close the RShell connection.
                reader.RShell.Close();

                // Wait for the user to press enter.
                Console.WriteLine("Press enter to exit.");
                Console.ReadLine();
            }
            catch (OctaneSdkException e)
            {
                // Handle Octane SDK errors.
                Console.WriteLine("Octane SDK exception: {0}", e.Message);
            }
            catch (Exception e)
            {
                // Handle other .NET errors.
                Console.WriteLine("Exception : {0}", e.Message);
            }
        }
Пример #2
0
        public static void SyncReaderTime()
        {
            try
            {
                lock (instance)
                {
                    string reply;

                    // Open up an RShell connection on the reader.
                    // Specify the reader address, user name, password and connection timeout.
                    instance.reader.RShell.OpenSecureSession(Hostname, "root", "impinj", 5000);

                    DateTime currentTime = DateTime.UtcNow;
                    while (currentTime.Millisecond > 5)
                    {
                        System.Threading.Thread.Sleep(1000 - currentTime.Millisecond);
                        currentTime = DateTime.UtcNow;
                    }

                    string time = currentTime.ToString("MM.dd-HH:mm:ss");

                    // Send an RShell command
                    RShellCmdStatus statusNTP = instance.reader.RShell.Send("config network ntp disable", out reply);

                    RShellCmdStatus status = instance.reader.RShell.Send("config system time " + time, out reply);

                    // Check the status
                    if (status == RShellCmdStatus.Success)
                    {
                        Logging.Logger.Log("RFID", "RShell command executed successfully.\n");
                    }
                    else
                    {
                        Logging.Logger.Log("RFID", "RShell command failed to execute.\n");
                    }

                    // Print out the entire reply.
                    Logging.Logger.Log("RFID", "RShell command reply : \n\n" + reply + "\n");

                    // Close the RShell connection.
                    instance.reader.RShell.Close();
                }
            }
            catch (OctaneSdkException e)
            {
                // Handle Octane SDK errors.
                Logging.Logger.Log(e);
            }
        }
Пример #3
0
        static void Main(string[] args)
        {
            string reply;

            try
            {
                // Open up an RShell connection on the reader.
                // Specify the reader address, user name, password and connection timeout.
                reader.RShell.Open(SolutionConstants.ReaderHostname, "root", "impinj", 5000);

                // Send an RShell command
                RShellCmdStatus status = reader.RShell.Send("show network summary", out reply);

                // Check the status
                if (status == RShellCmdStatus.Success)
                {
                    Console.WriteLine("RShell command executed successfully.\n");
                }
                else
                {
                    Console.WriteLine("RShell command failed to execute.\n");
                }

                // Print out the entire reply.
                Console.WriteLine("RShell command reply : \n\n" + reply + "\n");

                // Close the RShell connection.
                reader.RShell.Close();

                // Wait for the user to press enter.
                Console.WriteLine("Press enter to exit.");
                Console.ReadLine();
            }
            catch (OctaneSdkException e)
            {
                // Handle Octane SDK errors.
                Console.WriteLine("Octane SDK exception: {0}", e.Message);
            }
            catch (Exception e)
            {
                // Handle other .NET errors.
                Console.WriteLine("Exception : {0}", e.Message);
            }
        }
Пример #4
0
        static void Main(string[] args)
        {
            try
            {
                // Connect to the reader.
                // Change the ReaderHostname constant in SolutionConstants.cs
                // to the IP address or hostname of your reader.
                Console.WriteLine("Connecting to the reader.");
                reader.Connect(SolutionConstants.ReaderHostname);

                // Assign the TagsReported event handler.
                // This specifies which method to call
                // when tags reports are available.
                reader.TagsReported += OnTagsReported;

                // Get the default settings
                // We'll use these as a starting point
                // and then modify the settings we're
                // interested in.
                Settings settings = reader.QueryDefaultSettings();

                // Set the start trigger to Immediate.
                // This will allow the reader to start as soon as it boots up.
                settings.AutoStart.Mode = AutoStartMode.Immediate;

                // Tell the reader to hold all tag reports and events
                // when we disconnect from the reader.
                settings.HoldReportsOnDisconnect = true;

                // Tell the reader to include the antenna number
                // and timestamp in all tag reports. Other fields
                // can be added to the reports in the same way by
                // setting the appropriate Report.IncludeXXXXXXX property.
                settings.Report.IncludeAntennaPortNumber = true;
                settings.Report.IncludeFirstSeenTime     = true;

                // Apply the newly modified settings.
                Console.WriteLine("Configuring the reader.");
                reader.ApplySettings(settings);

                // The current configuration will be saved to to persistent storage.
                // The saved parameters then become the reader's power-on defaults.
                // If AutoStart mode is set to Immediate, the reader will
                // automatically start after booting up.
                Console.WriteLine("Press enter to save settings and reboot");
                Console.ReadLine();
                reader.SaveSettings();

                // Disconnect from the reader
                Console.WriteLine("Disconnecting from reader.");
                reader.Disconnect();

                // Issue an RShell command to reboot.
                // Open up an RShell connection on the reader.
                // Specify the reader address, user name, password and connection timeout.
                string reply;
                reader.RShell.Open(SolutionConstants.ReaderHostname, "root", "impinj", 5000);
                RShellCmdStatus status = reader.RShell.Send("reboot", out reply);
                // Close the RShell connection.
                reader.RShell.Close();

                // Check the status of the RShell command.
                if (status == RShellCmdStatus.Success)
                {
                    Console.WriteLine("Reader rebooting...\n");
                    Thread.Sleep(15000);

                    Console.Write("Waiting for reader to come back online.");
                    // Ping the reader until it's back online.
                    while (!ReaderIsAvailable(SolutionConstants.ReaderHostname))
                    {
                        Console.Write(".");
                        Thread.Sleep(1000);
                    }

                    Console.WriteLine("\nThe reader is back online. Press enter to reconnect and get tag data.\n");
                    Console.ReadLine();
                    Console.WriteLine("Reconnecting to reader.");

                    // Reconnect to the reader.
                    reader.Connect(SolutionConstants.ReaderHostname);

                    // Enable tag reports and events.
                    reader.ResumeEventsAndReports();
                }
                else
                {
                    // Error executing RShell command. Print out reply.
                    Console.WriteLine("RShell command failed to execute.\n");
                    Console.WriteLine("RShell command reply : \n\n" + reply + "\n");
                }

                // Wait for the user to press enter.
                Console.WriteLine("Press enter to exit.");
                Console.ReadLine();

                // Apply the default settings.
                // This removes the saved settings.
                reader.ApplyDefaultSettings();

                // Stop reading.
                reader.Stop();

                // Disconnect from the reader.
                reader.Disconnect();
            }
            catch (OctaneSdkException e)
            {
                // Handle Octane SDK errors.
                Console.WriteLine("Octane SDK exception: {0}", e.Message);
            }
            catch (Exception e)
            {
                // Handle other .NET errors.
                Console.WriteLine("Exception : {0}", e.Message);
            }
        }