Phidget Network Server: Difference between revisions

From Phidgets Support
 
(47 intermediate revisions by 5 users not shown)
Line 1: Line 1:
[[Category:Overview]]
[[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 on your local network. 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.


[[Image:SBC3003_0.jpg|link=|thumb|300px]]


At the top you have your computer, which has the Phidgets drivers installed. Connected via USB are a number of USB Phidgets and/or [[What_is_VINT?|VINT Hubs]]. Connected to the VINT Hubs could be VINT devices.
===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 [{{SERVER}}/?prodid=969 product page] for more information.


All of these connected Phidgets have various channels that can be opened, which allow the program running on your computer to read data from them or control their various parts.  
==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.


==Learn More==
View our [[Network Server Guide|Phidget Network Server Guide]] for more in-depth information.


Since the Network Server is disabled in this diagram, this computer is the only one that will be able to access these Phidgets.


<br clear="all">
{{Flow_Navigation_Buttons|{{Flow Page Number|{{PAGENAME}} }} }}
 
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, your Phidgets will be included in the list it selects the channel from.
 
[[Image:NetworkServer_PhidgetServer.jpg|link=|800px]]
 
When you open a Phidget, you have the option of opening it '''locally''' or '''remotely'''.
 
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.
 
Opening a Phidget '''remotely''' means communicating with it using the Network Service. You can remotely open any Phidget on your network, even ones that are physically connected to the computer running your program.
 
Why would you want to remotely open a Phidget that's physically attached to the computer? Well, a Phidget channel that is opened locally cannot be accessed by any other computer for as long as it's opened. A Phidget channel that is remotely opened, on the other hand, can be simultaneously opened by any number of programs.
 
[[Image:NetworkServer_Local_Remote.jpg|link=|800px]]
 
As you can see in this example, there is a Phidget with four channels connected to one computer via USB. When it locally opens DigitalOutput channel 1, the other computer on the network is unable to open that channel remotely. Furthermore, that same computer cannot open a second instance of that channel using the network server because it's already opened it locally. On the other hand, both computers are able to open DigitalOutput channel 2 remotely, because it hasn't been opened locally by the host computer. Either computer in the diagram could remotely open several instances of DigitalOutput channel 2 in this way.
 
== Setting up the Network Server ==
 
== 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 broadcasting itself on mDNS, you can simply enable automatic server discovery in your program. In C#, for example, you would call the {{Code|Net.EnableServerDiscovery(ServerType.Device)}} method in your program. '''Net''' is the object that is used for Phidget Networking. You can find a full list of methods and properties in the {{Phidget22API}} by selecting "Networking API" in the drop-down menu.
 
If the Phidget server is not broadcasting itself on mDNS, you can connect to it by adding it specifically. In C#, for example, you would do this by calling the {{Code|Net.AddServer()}} method. AddServer takes a number of parameters that help specify the server to connect to (e.g. IP address, port, password). For more details on how to use AddServer, take a look at the "Networking API" in 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:
 
<<picture of SBC setup>>
 
This can allow for a compact, mobile-based system like this:
 
<<picture of SBC with mobile>>?
 
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}}.
 
== 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>
 
== Web Server ==
 
== Phidget Dictionaries ==
 
== 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]].

Latest revision as of 19:47, 20 January 2025

 Phidget Programming Basics: Phidget Network ServerTOC Icon.png Table of Contents

Nav Back Arrow.png Nav Back Hover.png WhiteTab1.png HoverTab1.jpg WhiteTab2.png HoverTab2.jpg WhiteTab3.png HoverTab3.jpg WhiteTab4.png HoverTab4.jpg WhiteTab5.png HoverTab5.jpg WhiteTab6.png HoverTab6.jpg WhiteTab7.png HoverTab7.jpg WhiteTab8.png HoverTab8.jpg WhiteTab9.png HoverTab9.jpg WhiteTab10.png HoverTab10.jpg WhiteTab11.png HoverTab11.jpg WhiteTab12.png HoverTab12.jpg WhiteTab13.png HoverTab13.jpg WhiteTab14.png HoverTab14.jpg GreenTab15.png WhiteTab16.png HoverTab16.jpg Nav Next Arrow.png Nav Next Hover.png


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.

Networkserver ex1v2.png

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).
Networkserver ex2v3.png

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.

HUB5000 0.jpg

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.

SBC3003 0.jpg

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.