|
|
(25 intermediate revisions by 3 users not shown) |
Line 1: |
Line 1: |
| [[Category:Programming]] | | [[Category:Programming]]{{Recommended_Flow_Links|{{Flow Page Number|{{PAGENAME}} }} }} |
| {| | | __NOTOC__ |
| |style="vertical-align:middle; width: 60%;"|
| | ==What Is the Phidget Network Server?== |
| The Phidget Network Server is a feature of Phidgets that makes it possible to control or interact with Phidgets connected to other computers on your local network. | | The Phidget Network Server is a tool that makes it easy to access Phidgets that are connected to '''other computers''' on your network. |
|
| |
|
| If you haven't read them yet, we recommend first reading the pages on [[What is a Phidget?]] and [[Phidget Programming Basics]] to better understand the contents of this page.
| | It also enables in-browser JavaScript applications with Phidgets, and provides a dictionary manager which can be used to share information between applications. |
| |{{TOC limit|2}}
| |
| |}
| |
|
| |
|
| ==General Overview== | | ===Without the Phidget Network Server=== |
| | Your application runs on the same computer that your Phidgets are connected to. |
| | [[Image:Networkserver_ex1v2.png|500px|center|link=]] |
|
| |
|
| Once the Phidget Network Server is enabled, your computer hosts a '''Phidget Server''' which broadcasts all connected Phidgets to other computers on your network. When another computer tries to open a channel, these Phidgets will be included in the list of channels that can be attached.
| | ===With the Phidget Network Server=== |
| | Your Phidgets are connected to a computer running the Phidget Network Server. The Phidget Network Server hosts a Phidget Server, which makes your Phidgets available to other computers on your network. |
| | * Your application(s) can run on any computer that has access to the network the host is on. |
| | * Multiple applications can access the Phidgets simultaneously, with some exceptions (e.g. motor controllers). |
|
| |
|
| Phidgets attached over a Phidget Network server can be addressed, opened, and attached in much the same way as local Phidgets, so long as the program has access to the Network Server hosting the Phidgets.
| | [[Image:Networkserver_ex2v3.png|600px|center|link=]] |
|
| |
|
| Channels that are attached remotely may be opened by multiple programs simultaneously using the Phidget Network Server. There are some exceptions, such as motor controllers, that will never match more than one channel at a time for safety reasons.
| | ==Phidget Network Server Hosts== |
| | As mentioned above, a computer is required to host the Phidget Network Server. Any Windows, macOS, or Linux machine can act as a host. '''The Wireless VINT Hub or the PhidgetSBC4 are also excellent, compact choices.''' |
| | [[Image:HUB5000_0.jpg|200px|thumb|link=]] |
| | ===Wireless VINT Hub=== |
| | The Wireless VINT Hub (HUB5000) has the Phidget Network Server built-in. Simply connect your Phidgets, power the device, and the Network Server starts automatically. |
|
| |
|
| [[Image:NetworkServer_PhidgetServer.jpg|link=|800px]] | | This device supports both Ethernet and WiFi connections and provides a simple web interface to configure your Phidget Network Server. Check out the [{{SERVER}}/?prodid=1143 product page] for more information. |
|
| |
|
| When you open a Phidget, you have the option of opening it '''locally''' or '''remotely'''.
| | [[Image:SBC3003_0.jpg|link=|thumb|300px]] |
|
| |
|
| Opening a Phidget '''locally''' means communicating with it directly. You can only locally open Phidgets that are physically connected to the computer running your program.
| | ===PhidgetSBC4=== |
| | The PhidgetSBC4 (SBC3003) has the Phidget Network Server built-in. Simply connect your Phidgets, power the device, and the Network Server starts automatically. |
|
| |
|
| Opening a Phidget '''remotely''' means communicating with it using the Network Server. You can remotely open any Phidget on your network, even ones that are physically connected to the computer running your program.
| | This device supports both Ethernet and WiFi connections and provides a simple web interface to configure your Phidget Network Server. Additionally, you can connect USB Phidgets directly to this device and run application code on board. Check out the [{{SERVER}}/?prodid=969 product page] for more information. |
|
| |
|
| '''''IsLocal''''' and '''''IsRemote''''' serve as additional Addressing Properties when a Phidget Network Server is used in your application, and are used to specify if a Phidget should be attached locally or remotely. If you are opening a Phidget your computer is physically connected to and your program uses the Phidget Network Server, it is strongly recommended to specify if you intend to connect to it locally or remotely.
| | ==Phidget Network Server Clients== |
| | Client applications can run on any [[Operating_System_Support|supported operating system]] and can be written in any [[Programming_Resources|supported programming language]]. The client machine does '''not''' need to run a Phidget Network Server. |
|
| |
|
| ==Using The Network Server== | | ==Learn More== |
| | View our [[Network Server Guide|Phidget Network Server Guide]] for more in-depth information. |
|
| |
|
| Each Operating System page has a section on how to use the Network Server on that operating system:
| |
|
| |
|
| Notably, on Windows and OS X this can be handled from the '''Phidgets Control Panel''', under the ''Network Server'' tab.
| | {{Flow_Navigation_Buttons|{{Flow Page Number|{{PAGENAME}} }} }} |
| | |
| * [[OS - Windows#Phidget Network Server|Windows]]
| |
| * [[OS - OS X#Phidget Network Server|Mac OS]]
| |
| * [[OS - Linux#Phidget Network Server|Linux]]
| |
| * [[OS - Phidget SBC#Phidget Network Server|Linux on the Phidget SBC]]
| |
| * [[OS - iOS#Phidget Network Server|iPhone/iPad iOS]]
| |
| | |
| The operating systems pages will tell you how to start and stop the Network Server on your computer, and how to run it with or without mDNS (Bonjour, avahi, etc).
| |
| | |
| == Connecting to a Network Server ==
| |
| | |
| There are two ways to gain access to a Phidget server that's being hosted on your network. If the server is discoverable, you can simply enable automatic server discovery in your program. Select your programming language below to see a sample of how this is done.
| |
| | |
| <tabber>
| |
| Java=<syntaxhighlight lang=java>
| |
| Net.enableServerDiscovery(ServerType.DEVICE_REMOTE);
| |
| </syntaxhighlight>
| |
| |-|
| |
| Python=<syntaxhighlight lang=python>
| |
| Net.enableServerDiscovery(PhidgetServerType.PHIDGETSERVER_DEVICEREMOTE)
| |
| </syntaxhighlight>
| |
| |-|
| |
| C#=<syntaxhighlight lang=cSharp>
| |
| Net.EnableServerDiscovery(ServerType.DeviceRemote);
| |
| </syntaxhighlight>
| |
| |-|
| |
| C=<syntaxhighlight lang=c>
| |
| PhidgetNet_enableServerDiscovery(PHIDGETSERVER_DEVICEREMOTE);
| |
| </syntaxhighlight>
| |
| </tabber>
| |
| | |
| '''Net''' is the object that is used for Phidget Networking. You can find a full list of methods and properties available use with the network in the {{Phidget22API}} by selecting '''"Networking API"''' in the drop-down menu.
| |
| | |
| If the Phidget server is not discoverable, you can connect to it by adding it specifically. This is done using {{code|AddServer}}, which takes a number of parameters that help specify the server to connect to (e.g. IP address, port, password). See below for an an example of adding a specific server, and take a look at the "Networking API" in the {{Phidget22API}} for details.
| |
| | |
| <tabber>
| |
| Java=<syntaxhighlight lang=java>
| |
| Net.addServer("ServerName", "192.168.2.20", 5661, "passwd", 0);
| |
| </syntaxhighlight>
| |
| |-|
| |
| Python=<syntaxhighlight lang=python>
| |
| Net.addServer("ServerName", "192.168.2.20", 5661, "passwd", 0)
| |
| </syntaxhighlight>
| |
| |-|
| |
| C#=<syntaxhighlight lang=cSharp>
| |
| Net.AddServer("ServerName", "192.168.2.20", 5661, "passwd", 0);
| |
| </syntaxhighlight>
| |
| |-|
| |
| C=<syntaxhighlight lang=c>
| |
| PhidgetNet_addServer("ServerName", "192.168.2.20", 5661, "passwd", 0);
| |
| </syntaxhighlight>
| |
| </tabber>
| |
| | |
| ==Network Server on a Phidget Single Board Computer==
| |
| The [{{SERVER}}/products.php?product_id=SBC3003 Phidget Single Board Computer (SBC)] can provide a compact, inexpensive way to easily run the Network Server. It runs the Network Server in the background automatically from the moment you turn it on, and allows you to remotely read from and control all Phidgets attached to it:
| |
| | |
| [[Image:network_server_sbc.jpg|link=|900px]]
| |
| | |
| In this example, a Phidget SBC is connected to a VINT Hub, which in turn is connected to a VINT device. By using the Network Server, it makes all of these channels available to any device connected to the same network. The Network Server on the SBC is discoverable by default.
| |
| | |
| This is convenient because it allows the Phidgets and sensors to be in a remote location, like mounted on a wall or inside some kind of assembly, rather than sitting on your computer desk. The channels of this system could be conveniently accessed by a home computer on the network, a phone running some Phidgets code, or even another Phidget SBC in a different location.
| |
| | |
| For more information on controlling Phidgets with your phone, have a look at the mobile section of our [[Software_Overview#Operating System Support|operating system support]] page, or read {{ARTICLE|MurvRobotIOS|this article}} where we use [[OS_-_iOS|iOS]] to control a robot full of Phidgets.
| |
| | |
| == Examples ==
| |
| Below are some quick examples showing how simple it is to open a Phidget remotely over the Network Server. In each example, a light sensor Phidget is being remotely opened on port 0 of a VINT Hub with serial number 37299.
| |
| | |
| <tabber>
| |
| Java=<syntaxhighlight lang='Java'>
| |
| LightSensor ch = new LightSensor();
| |
| | |
| ch.setDeviceSerialNumber(37299);
| |
| ch.setHubPort(0);
| |
| ch.setIsRemote(true);
| |
| | |
| Net.enableServerDiscovery(ServerType.DEVICE_REMOTE);
| |
| | |
| ch.open(5000);
| |
| </syntaxhighlight>
| |
| |-|
| |
| Python=<syntaxhighlight lang='python'>
| |
| ch = LightSensor()
| |
| | |
| ch.setDeviceSerialNumber(37299)
| |
| ch.setHubPort(0)
| |
| ch.setIsRemote(1)
| |
| | |
| Net.enableServerDiscovery(PhidgetServerType.PHIDGETSERVER_DEVICEREMOTE)
| |
| | |
| ch.openWaitForAttachment(5000);
| |
| </syntaxhighlight>
| |
| |-|
| |
| C#=<syntaxhighlight lang='CSharp'>
| |
| LightSensor ch = new LightSensor();
| |
| | |
| ch.DeviceSerialNumber = 37299;
| |
| ch.HubPort = 0;
| |
| ch.IsRemote = true;
| |
| | |
| Net.EnableServerDiscovery(ServerType.DeviceRemote);
| |
| | |
| ch.Open(5000);
| |
| </syntaxhighlight>
| |
| |-|
| |
| C/C++=<syntaxhighlight lang=cpp>
| |
| PhidgetLightSensorHandle ch;
| |
| PhidgetLightSensor_create(&ch);
| |
| | |
| Phidget_setDeviceSerialNumber((PhidgetHandle) ch, 37299);
| |
| Phidget_setHubPort((PhidgetHandle) ch, 0);
| |
| Phidget_setIsRemote((PhidgetHandle) ch, 1);
| |
| | |
| PhidgetNet_enableServerDiscovery(PHIDGETSERVER_DEVICEREMOTE);
| |
| | |
| Phidget_open((PhidgetHandle) ch);
| |
| | |
| </syntaxhighlight>
| |
| </tabber>
| |
| | |
| For more information, have a look at the {{Phidget22API}} and select your language from the drop-down menu. You can learn more about opening Phidgets on the [[Phidget_Programming_Basics#Opening_the_Phidget|Programming Basics]] page.
| |
| | |
| == Troubleshooting ==
| |
| | |
| When using the Network Server, both the '''client and server should have the ''same version''''' of the Network Server installed. The easiest way to ensure this is to update your libraries on both ends.
| |
| | |
| For other troubleshooting tips, try our General Troubleshooting page, in its [[General_Troubleshooting#Network_Server_Troubleshooting|Network Server section]].
| |
| | |
| === Further Reading ===
| |
| | |
| [[Phidget Programming Basics]] - Here you can find the basic concepts to help you get started with making your own programs that use Phidgets.
| |
| | |
| [[Data Interval/Change Trigger]] - Learn about these two properties that control how much data comes in from your sensors.
| |
| | |
| [[Using Multiple Phidgets]] - It can be difficult to figure out how to use more than one Phidget in your program. This page will guide you through the steps.
| |
| | |
| [[Polling vs. Events]] - Your program can gather data in either a polling-driven or event-driven manner. Learn the difference to determine which is best for your application.
| |
| | |
| [[Logging, Exceptions, and Errors]] - Learn about all the tools you can use to debug your program.
| |
| | |
| [[Best Phidgets Practices]] - Good programming habits that will save you from common problems when writing code for your Phidgets.
| |
15 . Phidget Network Server
What Is the Phidget Network Server?
The Phidget Network Server is a tool that makes it easy to access Phidgets that are connected to other computers on your network.
It also enables in-browser JavaScript applications with Phidgets, and provides a dictionary manager which can be used to share information between applications.
Without the Phidget Network Server
Your application runs on the same computer that your Phidgets are connected to.
With the Phidget Network Server
Your Phidgets are connected to a computer running the Phidget Network Server. The Phidget Network Server hosts a Phidget Server, which makes your Phidgets available to other computers on your network.
- Your application(s) can run on any computer that has access to the network the host is on.
- Multiple applications can access the Phidgets simultaneously, with some exceptions (e.g. motor controllers).
Phidget Network Server Hosts
As mentioned above, a computer is required to host the Phidget Network Server. Any Windows, macOS, or Linux machine can act as a host. The Wireless VINT Hub or the PhidgetSBC4 are also excellent, compact choices.
Wireless VINT Hub
The Wireless VINT Hub (HUB5000) has the Phidget Network Server built-in. Simply connect your Phidgets, power the device, and the Network Server starts automatically.
This device supports both Ethernet and WiFi connections and provides a simple web interface to configure your Phidget Network Server. Check out the product page for more information.
PhidgetSBC4
The PhidgetSBC4 (SBC3003) has the Phidget Network Server built-in. Simply connect your Phidgets, power the device, and the Network Server starts automatically.
This device supports both Ethernet and WiFi connections and provides a simple web interface to configure your Phidget Network Server. Additionally, you can connect USB Phidgets directly to this device and run application code on board. Check out the product page for more information.
Phidget Network Server Clients
Client applications can run on any supported operating system and can be written in any supported programming language. The client machine does not need to run a Phidget Network Server.
Learn More
View our Phidget Network Server Guide for more in-depth information.