AdvanReader-m10 C# examples
DISCLAIMER OF LIABILITY
THE PROCEDURES AND SAMPLES IN THIS PAGE ARE PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND (EITHER EXPRESS OR IMPLIED), INCLUDING BUT NOT LIMITED TO ANY IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A SPECIFIC OR GENERAL PURPOSE AND THOSE ARISING BY STATUTE OR BY LAW, OR FROM A CAUSE OF DEALING OR USAGE OF TRADE.
THIS ALSO APPLIES TO THE CONSEQUENCES OF ANY ACTIONS TAKEN ON THE BASIS OF THE INFORMATION PROVIDED.
Introduction
We provide some basic examples in C# you can download to test AdvanReader-m1-10 or AdvanReader-m2-10. To check their features, please see the corresponding pages:
Below are the instructions depending on your Operating system (Windows or Linux)
Available examples
For now, the following examples are available:
Synch: the example expects the reader port as an argument. It connects to the reader and sets the region to EU3. Then, it tells the reader to use antenna #1 and the protocol Gen2 and starts reading during a specified time (it can be changed by changing the variable readTime). By default, it reads for 10 seconds. Finally, it stops reading and prints the tags read information.
Asynch: it also expects the reader port as an argument. It connects to the reader and sets the region to EU3. Then, it tells the reader to use antenna #1 and the protocol Gen2. After that, it reads asynchronously and prints the tag information while it's being read. It stops reading after the specified sleepTime (10 seconds by default)
Windows
Requirements
These examples have been tested using an AdvanReader-m1-10 and the following software:
Windows 10 64 bits
Visual Studio 2017 (including C# tools)
.NET Framework 4.5
How to run the examples
In order to run the examples, please follow the steps below:
1. Open Visual Studio 2017
2. Open the solution by clicking on File --> Open --> Project/Solution (or Open Project/Solution):
3. Browse to the solution directory and click on Advanreader10.sln
4. Since the solution contains more than one example, you need to specify which one you want to run, and specify the port used by the reader:
4.1. On the Solution Explorer, double click on Properties:
4.2. Click on Application and select the example you want to run. In our case, we are going to select "Asynch.Asynch" as we want to run the Asynch example:
4.3. Click on Debug and specify the Command line arguments. In our case, it's eapi:///COM3, but you should check your port on the Windows Device Manager:
4.4. Press Ctrl + S to save the preferences.
5. Execute the example: click on the Start button or F5 (or Ctrl + F5 if you do not want the console to be closed at the end of the execution):
6. The information of the tags read will be displayed on the console:
Troubleshooting
Error: The port 'COMX' does not exist
If you get an output on the console like the following:
It means the port you specified is not correct. Please, check on Windows Device Manager (section Ports (COM & LPT)) the port you need to use:
If your Windows does not recognize the port, try to use another USB port on your computer.
Linux
Requirements
These examples have been tested using an AdvanReader-m1-10 and the following software:
Linux Mint
Mono JIT compiler version 4.2.1 (Debian 4.2.1.102+dfsg2-7ubuntu4)
XBuild Engine Version 12.0
How to run the examples
1. Download the examples zip
2. Extract the compressed file
3. Go to the command line and go to the AdvanReader10 directory where Advanreader10.csproj is located (/Advanreader10/Advanreader10/).
4. Compile the program by using the following command:
xbuild Advanreader10.csproj
5. If the compilation was successful, go to bin/Debug directory. An Advanreader10.exe* should have been created in the folder.
6. Run the project by using the command:
sudo mono Advanreader10.exe eapi:///dev/ttyUSB0
Note: in our case, dev/ttyUSB0 port has been used, but you should make sure which one you are using (tip: use ls /dev)
7. The progam should print the output on the terminal:
Troubleshooting
The build failed
If you tried to compile the project, but the build failed, try to run the following command:
xbuild Advanreader10.csproj /verbosity:diagnostic
Adding the verbosity option allows you to figure out which problem made the build to fail
Error: Permission denied
If the output on the terminal is the following:
Error: Permission denied
Run the command with sudo.
Error: No such file or directory
If the output is:
Error: No such file or directory
Most certainly, the ttyUSB port you specified is not correct. Use the command ls /dev to check the one you need to use.
Downloads
You can find our examples in our GitHub page: https://github.com/Keonn-Technologies/AdvanReader-10-C-Sharp-Examples