|
|
(34 intermediate revisions by 5 users not shown) |
Line 1: |
Line 1: |
| [[Category:Programming]] | | [[Category:Programming]]{{Recommended_Flow_Links|{{Flow Page Number|{{PAGENAME}} }} }} |
| __TOC__
| | __NOTOC__ |
| | ==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. |
|
| |
|
| ==General Overview==
| | It also enables in-browser JavaScript applications with Phidgets, and provides a dictionary manager which can be used to share information between applications. |
| The Phidget Network Server is a feature of Phidgets that makes it possible to control or interact with Phidgets connected to other computers. To understand how it works, let's first take a look at what a system looks like without the Network Server enabled:
| |
|
| |
|
| | ===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=]] |
|
| |
|
| | ===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). |
|
| |
|
| | [[Image:Networkserver_ex2v3.png|600px|center|link=]] |
|
| |
|
| [[Image:Phidgets_without_NetworkServer.jpg|link=|500px|right]] | | ==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. |
|
| |
|
| | 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. |
|
| |
|
| Begin with a local computer with the Phidget software installed and a number of Phidgets and/or [[What_is_VINT?|VINT Hubs]] connected. Connected to the VINT Hubs could be VINT devices.
| | [[Image:SBC3003_0.jpg|link=|thumb|300px]] |
|
| |
|
| | ===PhidgetSBC4=== |
| | The PhidgetSBC4 (SBC3003) has the Phidget Network Server built-in. Simply connect your Phidgets, power the device, and the Network Server starts automatically. |
|
| |
|
| All of these connected Phidgets have various channels that can be attached, which would allow a program running on the local computer to control or read data from them.
| | 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. |
|
| |
|
| | ==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. |
|
| |
|
| Since the Network Server is disabled in this diagram, the local computer is the only one that will be able to access the connected Phidgets.
| | ==Learn More== |
| | View our [[Network Server Guide|Phidget Network Server Guide]] for more in-depth information. |
|
| |
|
| <br clear="all">
| |
|
| |
|
| Enabling the Phidget Network Server will allow software on a remote computer to connect to the local computer and receive the list of available Phidget devices attached. The channels from the remote computer will appear to be local to the local computer.
| | {{Flow_Navigation_Buttons|{{Flow Page Number|{{PAGENAME}} }} }} |
| | |
| [[Image:NetworkServer_PhidgetServer.jpg|link=|800px]]
| |
| | |
| Software can set the {{Code|IsLocal}} and {{Code|IsRemote}} properties of a channel to control if remote or local channels should be considered during matching.
| |
| | |
| Specifying '''IsLocal''' would instruct the Phidget software to only match Phidgets physically connected to the local computer.
| |
| | |
| Specifying '''IsRemote''' would instruct the Phidget software to only match Phidgets exported by a remote computer.
| |
| | |
| Phidget device channels normally can only be attached to a single user channel; however, device channels that are exported by the Phidget Network Server may attach to more than one remote user channel. There are some exceptions (for example motor controllers) where safety could be an issue.
| |
| | |
| [[Image:NetworkServer_Local_Remote.jpg|link=|800px]]
| |
| | |
| As can be see in this example, there is a Phidget with four channels connected to a local computer. The local computer has enabled the Phidget Network Server. When the local computer attaches to channel 1, a remote computer is unable to attach to channel 1; furthermore, the local computer cannot attach a second user channel to channel 1 using the network server because channel 1 is already attached locally. On the other hand, both computers are able to attach to channel 2 remotely, because channel 2 hasn't been attached locally by the local computer. Both the local computer and the remote computer could attach several user channels to channel 2.
| |
| | |
| ==Using The Network Server==
| |
| | |
| Each Operating System page has a section on how to use the Phidget Network Server:
| |
| | |
| * [[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 OS pages have examples of how to set up the Phidget Network Server and how to use it to remotely control and gather data from Phidgets. The OS pages also describe how to start and stop the Phidget Network Server, and how to run it with or without mDNS (Bonjour, avahi, etc).
| |
| | |
| == Connecting to a Network Server ==
| |
| | |
| There are two ways to access to a Phidget Network Server. First, if '''publish''' is enabled in a server, the server will broadcast its existence, and software can enable server discovery to dynamically discover and connect to the server. Second, software can connect directly to a server. To enable server discovery the {{Code|enableServerDiscovery()}} method is used. To connect to a specific server the {{Code|addServer()}} method is used. A list of networking methods can be found in the "Network API" section of the {{Phidget22API}}.
| |
| | |
| ==Network Server on a Phidget Single Board Computer==
| |
| | |
| The 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 read from and control all Phidgets attached to it:
| |
| | |
| [[Image:network_server_sbc.jpg|link=|900px]]
| |
| | |
| In this example, a Phidget SBC physically connected to a VINT Hub which is connected to a VINT device. The SBC itself has its own channels corresponding to the on-board ports it has. By using the network server, it makes all of these channels available to any device connected to the same wireless network.
| |
| | |
| 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.
| |
| | |
| The SBC runs Linux, which provides a [[OS - Phidget SBC|full operating system]] on which to develop code, {{ARTICLE|WebPageOnSBC|serve web pages}}, and {{ARTICLE|PhidgetsWirelesslyWithSBC|control Phidgets}}.
| |
| | |
| For more information on controlling Phidgets with your phone, have a look at the mobile section of our [[Software_Overview#Language_Support|languages]] 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.
| |
| | |
| {{hiddenh3|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);
| |
| | |
| Phidget_open((PhidgetHandle) ch);
| |
| | |
| </syntaxhighlight>
| |
| | |
| {{hiddenh3|C#}} | |
| | |
| <syntaxhighlight lang='CSharp'>
| |
| LightSensor ch = new LightSensor();
| |
| | |
| ch.DeviceSerialNumber = 37299;
| |
| ch.HubPort = 0;
| |
| ch.IsRemote = true;
| |
| | |
| ch.Open();
| |
| | |
| </syntaxhighlight>
| |
| | |
| {{hiddenh3|Java}} | |
| | |
| <syntaxhighlight lang='Java'>
| |
| LightSensor ch = new LightSensor();
| |
| | |
| ch.setDeviceSerialNumber(37299);
| |
| ch.setHubPort(0);
| |
| ch.setIsRemote(true);
| |
| | |
| ch.open();
| |
| | |
| </syntaxhighlight>
| |
| | |
| {{hiddenh3|Python}}
| |
| | |
| <syntaxhighlight lang='python'>
| |
| ch = LightSensor()
| |
| | |
| ch.setDeviceSerialNumber(37299)
| |
| ch.setHubPort(0)
| |
| ch.setIsRemote(1)
| |
| | |
| ch.open();
| |
| | |
| </syntaxhighlight>
| |
| | |
| 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.