Beispiel #1
0
 public void Should_set_antenna_check(ConnectionType connectionType)
 {
     using var r = new SerialReader(TestSettings.Instance.GetConnection(connectionType));
     r.SetAntennaCheck(true).Wait();
     r.GetReaderInfo().Result.AntennaCheck.Should().BeTrue();
     r.SetAntennaCheck(false).Wait();
     r.GetReaderInfo().Result.AntennaCheck.Should().BeFalse();
 }
Beispiel #2
0
 public void Should_set_inventory_scan_interval()
 {
     using var r = new SerialReader(TestSettings.Instance.GetConnection());
     r.SetInventoryScanInterval(TimeSpan.FromMilliseconds(1000)).Wait();
     r.GetReaderInfo().Result.InventoryScanInterval.Should().Be(TimeSpan.FromMilliseconds(1000));
     r.SetInventoryScanInterval(TimeSpan.FromMilliseconds(300)).Wait();
     r.GetReaderInfo().Result.InventoryScanInterval.Should().Be(TimeSpan.FromMilliseconds(300));
 }
Beispiel #3
0
 public void Should_set_antenna_configuration(ConnectionType connectionType)
 {
     using var r = new SerialReader(TestSettings.Instance.GetConnection(connectionType));
     r.SetAntennaConfiguration(GenAntennaConfiguration.Antenna1 | GenAntennaConfiguration.Antenna2).Wait();
     r.GetReaderInfo().Result.AntennaConfiguration.Should().Be(GenAntennaConfiguration.Antenna1 | GenAntennaConfiguration.Antenna2);
     r.SetAntennaConfiguration(GenAntennaConfiguration.Antenna1).Wait();
     r.GetReaderInfo().Result.AntennaConfiguration.Should().Be(GenAntennaConfiguration.Antenna1);
 }
Beispiel #4
0
 public void Should_set_rf_power()
 {
     using var r = new SerialReader(TestSettings.Instance.GetConnection());
     r.SetRFPower(20).Wait();
     r.GetReaderInfo().Result.RFPower.Should().Be((byte)20);
     r.SetRFPower(0).Wait();
     r.GetReaderInfo().Result.RFPower.Should().Be((byte)0);
     r.SetRFPower(26).Wait();
     r.GetReaderInfo().Result.RFPower.Should().Be((byte)26);
 }
Beispiel #5
0
 public void Should_set_antenna_configuration()
 {
     using (var r = new SerialReader(TestSettings.Instance.GetConnection()))
     {
         r.SetAntennaConfiguration(AntennaConfiguration.Antenna1).Wait();
         r.GetReaderInfo().Result.AntennaConfiguration.ShouldBe(AntennaConfiguration.Antenna1);
         r.SetAntennaConfiguration(AntennaConfiguration.Antenna1 | AntennaConfiguration.Antenna2).Wait();
         r.GetReaderInfo().Result.AntennaConfiguration.ShouldBe(AntennaConfiguration.Antenna1 | AntennaConfiguration.Antenna2);
     }
 }
Beispiel #6
0
        public void Should_change_serial_baud_and_update_connection(ConnectionType connectionType)
        {
            var connection = (SerialPortFactory)TestSettings.Instance.GetConnection(connectionType,
                                                                                    BaudRates.Baud57600);

            using var r = new SerialReader(connection);
            var info = r.GetReaderInfo().Result;

            r.SetSerialBaudRate(BaudRates.Baud115200).Wait();
            connection.BaudRate.Should().Be(115200);
            info = r.GetReaderInfo().Result;
            r.SetSerialBaudRate(BaudRates.Baud57600).Wait();
            connection.BaudRate.Should().Be(57600);
            info = r.GetReaderInfo().Result;
        }
Beispiel #7
0
        static void Main(string[] args)
        {
            Console.WriteLine("Generic serial reader test app. Supply serial port name as argument.");
            if (args.Length == 0)
            {
                Console.WriteLine("Available serial ports:");
                var names = SerialPortStream.GetPortNames();
                foreach (var name in names)
                {
                    Console.WriteLine(name);
                }
                return;
            }

            var portName = args[0];

            using (var r = new SerialReader(portName))
            {
                Console.WriteLine("Serial number: {0}", r.GetSerialNumber().Result);
                var info = r.GetReaderInfo().Result;
                Console.WriteLine("Model: {0}", info.Model);
                Console.WriteLine("FirmwareVersion: {0}", info.FirmwareVersion);
                Console.WriteLine("AntennaConfiguration: {0}", info.AntennaConfiguration);
                Console.WriteLine("SupportedProtocols: {0}", info.SupportedProtocols);
                Console.WriteLine("RFPower: {0}", info.RFPower);
                Console.WriteLine("InventoryScanInterval: {0}", info.InventoryScanInterval);

                Console.WriteLine("Performing inventory. Ctrl+C to stop");
                var tags = new Dictionary <string, int>();
                while (true)
                {
                    try
                    {
                        var result = r.TagInventory().Result;
                        foreach (var tag in result.Tags)
                        {
                            tags.AddOrUpdate(tag.TagId, 1, (k, v) => v + 1);
                        }

                        Console.WriteLine($"#################################################");
                        foreach (var pair in tags.OrderBy(x => x.Key))
                        {
                            Console.WriteLine($"{pair.Key} {pair.Value}");
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex);
                    }
                }
            }
        }
Beispiel #8
0
 public void Should_get_reader_info()
 {
     using (var r = new SerialReader(TestSettings.Instance.GetConnection()))
     {
         //r.SetAntennaCheck(false).Wait();
         r.SetRFPower(20).Wait();
         var info = r.GetReaderInfo().Result;
         info.FirmwareVersion.Major.ShouldBe(3);
         info.FirmwareVersion.Minor.ShouldBeInRange(1, 18);
         info.Model.ShouldBeOneOf(ReaderModel.CF_RU5202, ReaderModel.UHFReader288MP);
         info.SupportedProtocols.ShouldBeOneOf(ProtocolType.Gen18000_6C,
                                               ProtocolType.Gen18000_6B, ProtocolType.Gen18000_6C | ProtocolType.Gen18000_6B);
         info.RFPower.ShouldBe((byte)20);
         info.InventoryScanInterval.ShouldBeInRange(TimeSpan.FromMilliseconds(0), TimeSpan.FromMilliseconds(25500));
         info.AntennaConfiguration.ShouldBe(AntennaConfiguration.Antenna1);
         info.AntennaCheck.ShouldBe(false);
     }
 }
Beispiel #9
0
        static void ShowBasicReaderInfo(SerialReader reader, DemoArgs args)
        {
            reader.SetRFPower((byte)ConnectionString.Parse(args.ConnectionString).RFPower).Wait();
            Console.WriteLine("Serial number: {0}", reader.GetSerialNumber().Result);
            var info = reader.GetReaderInfo().Result;

            Console.WriteLine("Model: {0}", info.Model);
            Console.WriteLine("FirmwareVersion: {0}", info.FirmwareVersion);
            Console.WriteLine("AntennaConfiguration: {0}", info.AntennaConfiguration);
            Console.WriteLine("SupportedProtocols: {0}", info.SupportedProtocols);
            Console.WriteLine("RFPower: {0}", info.RFPower);
            Console.WriteLine("InventoryScanInterval: {0}", info.InventoryScanInterval);


            if (args.Confirm)
            {
                Console.WriteLine("Press enter to start inventory cycle");
                Console.ReadLine();
            }

            Console.WriteLine("Performing inventory. Ctrl+C to stop");
        }