Learn more about our scanners at: https://joescan.com
Page History
...
The available discovery functions are located in the class ScannerConfig:
- public static List<DiscoveryResponse> ScannerConfig.FindAllScanners() (Example 1a)
- public static DiscoveryResponse ScannerConfig.FindScanner(int id) (Example 1b)
- public static void ScannerConfig.FindAllScanners(ScannerResponseDelegate srh) (Example 1c)
Discovering All Scanners – Example 1a
To discover all scanners on a network, use the first following function listed above:
Code Block | ||
---|---|---|
| ||
using System.Collections.Generic; using JoeScan.JCamNet; namespace Examples { class Program { static void Main(string[] args) { List<DiscoveryResponse> responses = ScannerConfig.FindAllScanners(); foreach (var discoveryResponse in responses) { System.Console.WriteLine("Base IP Address: {0}, CableId: {1}, Serial Number: {2}", discoveryResponse.BaseIPAddress, discoveryResponse.CableId, discoveryResponse.SerialNumber ); } } } } |
...
Code Block | ||||
---|---|---|---|---|
| ||||
Base IP Address: 192.168.1.105, CableId: 0, Serial Number: 374 Base IP Address: 192.168.1.150, CableId: 0, Serial Number: 1465 Base IP Address: 192.168.1.105, CableId: 22, Serial Number: 1941 Base IP Address: 192.168.1.105, CableId: 28, Serial Number: 1940 Base IP Address: 192.168.1.105, CableId: 30, Serial Number: 1747 |
Querying for a specific scanner by CableId or Serial Number – Example 1b
If you want to query for a specific scanner, either by its CableId or serial number, use the second following function listed above:
The parameter id is either a CableId or a serial number. Because no hardware with serial numbers below 128 exists, the API assumes any argument < 128 is a CableId, and a serial number otherwise. However, there may be multiple scanners on your network that have the same CableId (and a different IP Base Address). In this case, it is not safe to use this function, as it only returns one DiscoveryResponse and may throw an exception.
...
In the following example, we only want to work with scanners that have a "1" in their network address at the 3rd quad. Use the third following function above:
Code Block | ||
---|---|---|
| ||
using JoeScan.JCamNet; using System; namespace Examples { class Program { static void Main(string[] args) { ScannerConfig.FindAllScanners(MyDelegate); } public static void MyDelegate(DiscoveryResponse response) { // filter here by your criteria, for instance the subnet: if (response.BaseIPAddress.GetAddressBytes().GetValue(2).ToString() == "1") { System.Console.WriteLine("Base IP Address: {0}, CableId: {1}, Serial Number: {2}", response.BaseIPAddress, response.CableId, response.SerialNumber); } } } } |
...