Template:UGsbc1
Basic Use
Basic use of the PhidgetSBC allows the opening of connected Phidgets over the network. Using another Phidget with the PhidgetSBC in this way is almost exactly like using Phidgets over USB, in respect to the API calls and behavior. However, some extra considerations need to be made when working with the Phidget Network Service.
Phidget Network Service
Support for opening Phidgets over the network is made possible via the Phidget Network Service. This allows a user to write an application in a system and language of their choosing and then operate Phidgets connected to the PhidgetSBC. It is a socket based server that runs on the PhidgetSBC, and allows any attached Phidgets to be seen and opened directly over the network. To use this server go to the "Phidgets->Network Service" tab in the web configuration page and enable it.
Opening and controlling a Phidget over the network is nearly the same as opening one locally. The main differences are:
- Different open calls that include server information. New calls OpenRemote and openRemoteIP (naming depends on language).
- Access to Network Service based properties: Server hostname, port and ID.
- Access to server connect and disconnect events, and network error events.
- Phidgets can be opened by more then one separate application at the same time.
- Reliability is more of a issue because network connections are easily broken
Opening a Phidget over the network is asynchronous and pervasive, just like opening locally. This means that if a connection to the remote server cannot be established right away, it will keep trying indefinitely, and even survive the server being stopped and started, etc. Instances of the Phidget Network Service can be referred to either using hostname (IP Address) and port number, or by Server ID. The advantage of using a Server ID is that it stays consistent compared to IP addresses, and you don’t need to know the Port number. A Network Service Server ID is assigned when the Network Service is run - which on the PhidgetSBC defaults to ‘phidgetsbc’. In order to use a Server ID, the Bonjour utility also needs to be installed. Refer to the Programming Manual and the API manual for your language for more information about using the Phidget Network Service.
Reliability
Determining reliability needs can become important while opening Phidgets over the network, because the network connection can potentially be interrupted at any time. This can leave the network attached Phidget in an undesirable state. For example - if a motor controller is driving a motor and the connection is lost, there is no way to stop the motor until the connection is re-established. These issues are less important if you are just receiving sensor data from an Interface Kit.
It’s generally a good idea to catch server connect and disconnect and Phidget attach and detach events in order to know the state of the connections. It’s also a good idea to catch error events - this is where network errors will be reported. If reliability is important, you should consider writing a program to run locally on the PhidgetSBC, and communicate with it through the Dictionary interface. This way, if the connection is broken, the local application will notice and be able to take any appropriate actions. See the advanced chapter for more information.
Finding Phidgets on the Network
Any Phidgets attached to the PhidgetSBC can be identified using the Status >> Phidgets page in the configuration interface, and should be seen on the network through the network service. The Phidget Control Panel lists all detected network attached Phidgets (just make sure "List Remote Phidgets" is enabled in File->Options) . The Phidgets connected to the PhidgetSBC should be seen here and can be opened by double clicking its name in the menu. Network attached Phidgets can also be located programmatically with the Phidget Manager. The Phidget Manager is used with either hostname and port, or server ID, just like with ‘Open’. The manager can also be used to find all Phidgets on any Network service through Bonjour, by specifying a NULL Server ID. See your specific language’s guide for more information about coding with the Phidget Manager.
Testing Using Mac OS X
The steps are very similar to the Windows process described above:
- Ensure you have OS X 10.3.9 or later running.
- Download and run the Installer (OS software license)
- Click on System Preferences → Phidgets (under Other) to activate the Preference Pane
- Make sure that the Phidget SBC is properly attached to the network as described in the Getting Started section
- Double Click on the Phidget SBC in the Phidget Preference Pane to bring up the Web Interface in your default browser
- Or, click on the Bonjour tab to see attached Phidgets being run over the network and to bring up their examples
The address in the browser that connects to the SBC is either an IP address (such as 192.168.2.181) or a link local address, (such as phidgetsbc.local
, which is the default). Note down the address in the browser, as you will need this information for later if you will be working directly with the SBC to perform tasks such as writing or running code. But for now, with the web interface open, we have a section to walk you through it.
Using Linux
With Linux, you have many setup options, but all involve knowing the IP address or link local address of the SBC after you have plugged it in as described in Getting Started section. The IP address can be somewhat difficult to obtain, but the default link local address for all new Phidget SBCs is phidgetsbc.local
- which is an mDNS address. Wait at least three minutes after booting the SBC to make sure link local addressing is started. You'll also need some form of mDNS (either avahi
or mDNSResponder
) installed on your main computer. The avahi
service is usually installed by default on most Linux machines, try which avahi-resolve
to make sure. Then, try typing phidgetsbc.local
into a web browser. The web interface should come up, starting with the Set the Password screen.
Note that some browsers (i.e. Google Chrome) combine search and addressing in the same address bar, so you may need to turn off web service and prediction service in Preferences → Under The Bonnet
for Chrome to treat phidgetsbc.local
like a web address rather than a search term. If these steps do not bring you to the initial setup password screen as shown in the SBC Web Interface section, you will probably need to read the internet setup section on the SBC OS Page. That section contains more than just troubleshooting information - it includes in-depth information on how the SBC starts its network, your initial network configuration options, and how to connect to the SBC without mDNS using both DHCP and static IP.
If you want to use the SBC to broadcast data from Phidgets over a network, the SBC is already automatically performing this function with its attached Interface Kit, and will also do so for any Phidgets plugged into its USB ports. If this is your sole intended use of the SBC, you can skip ahead to our example on using the attached Interface Kit.
However, the SBC is much, much more than simply a way to get data from Phidgets over a network. You can use the SBC as an external Linux computer. You'll need to set a password using the SBC web interface, and write down a network address of the SBC (phidgetsbc.local
, or an IP address if you worked through the internet setup section on the SBC OS Page). But after that, if no other sections in the basic SBC web interface section apply to you (using the webcam, setting up wireless networking, or checking system parameters like memory), you can skip ahead to the OS - Phidget SBC page.
Linux - Attached Interface Kit
As soon as the SBC boots and can connect to the network (either by DHCP or by mDNS/avahi), it begins broadcasting the state of its attached InterfaceKit over the network using the Phidget Network Service. To test the InterfaceKit on your Linux computer over the network, you will need to install the Phidget libraries and the Phidget network service if you haven't already. (If you have used any Phidget via USB and over a network on your Linux computer, you have already done this.) This process is described on the general Linux OS page, so follow those installation instructions, with the following modifications to the Linux network service introduction:
- Instead of using a localhost (127.0.0.1) address, use the the SBC's IP or link local (
phidgetsbc
) address, - Instead of using the function call
openRemoteIP
in your code, use the function callopenRemote
, and the Interface Kit serial number which is on the back of the SBC.
Note that any attached analog sensors in the black ports will not show up over the network service as individual Phidgets. Rather, they will show up as part of the Interface Kit, through the port number that they are attached to on the SBC board.