UsbAccessXtra(Beta)
Windows:1.0.8 Released:2006-11-09
Mac OSX:1.0.0 Released:2004-12-07
Mac OS9:1.0.0 Released:2004-12-28
Copyright Geoff Smith 1999-2006
This page last updated Tuesday 02nd of December 2008



Introduction

Information

Messages

Download/Buy

Error handling


Description

The UsbAccess Xtra allows HID access to a USB device attached to the computer using Macromedia Director(TM). You are able to read and write between the device and the computer. Note that system devices, like the keyboard and mouse, are not accessable.
For updates on this and my other XObjects/Xtras check out my web page: www.physicalbits.com

Release and Version history

 

Compatibility Chart

UsbAccessXtra is available for the Microsoft Windows and Apple Macintosh platforms.Comptiability with various versions of the plaforms is out lined below:

OS
Version
Yes
No
Not available
Untested
Microsoft© Windows 95      
98      
2000      
XP
     
NT 4      
Apple Macintosh Classic (OS9)
     
OSX
     
 

Installation

There are two methods to install and use this Xtra for Macromedia Director.

Copy the UsbAccessXtra.x32 (PC) or UsbAccessXtra.xtr/UsbAccessXtra.OS9 (Mac) into the Xtras folder inside the folder with the Director main program. When you start Director it looks inside, and makes available, any xtras inside the Xtras folder.

The other method is to place the xtra in some folder, and use Director's openxlib command before trying to use it. I use this method in my demo movies. If you put the xtra in the Xtras folder you do not need to use the openxlib command. Refer to the Director documentation for further information.

If you want to check that the xtra is loaded, enter the lingo "showxlib" command into Directors message window. This lists all the available xtras, UsbAccessXtra should be in the list, if not then some error has occurred. Check the location of the file or use the openxlib command (see above). The figure below shows the presence of the xtra, "-- Xtra: UsbAccessXtra", and because openxlib was used the name of the file that it was read from is shown.
Is the xtra is on the list use "put interface(xtra "UsbAccessXtra")" to list all the messages available in the xtra. It also shows the version of the xtra and if it can be used in a projector.

 


Example of message window after openxlib and interface lingo commands have been executed
(Varies with different versions)

 

Simple Example Director Lingo for UsbAccessXtra


What are these callbacks and how do they work?

Firstly, do not use callbacks unless you have a good reason to, you should normally use the standrad polling technique.

Normally you use handlers in Lingo that call messages in an xtra,

Lingo -> handler ->xtra message->internal xtra code-> reply from xtra->handler

If you are wating for some data from the xtra you gave to call it often to see when it arrives, this is callled polling. The xtra buffers data until you request it. You can have your code take responsibility for checking by constantly polling the the xtra to see when data arrives.
This is equivalent to continually calling a friend on the phone to see when they return home, it would be a lot easier for you to leave a message on their voicemail asking them to call you back

Some of the xtra commands use a different technique, callbacks.

 

Receiving messages can be difficult with serial communication because it is asynchronous, meaning you never know exactly when a message will come in. Luckily your computer has a serial buffer that will hold the incoming messages until your software gets around to checking but eventually you have to check. You can have your code take responsibility for checking by constantly polling the serial port using the "charsAvailable" method and then the various "read" methods probably in the exitframe script. This is equivalent to continually calling a friend on the phone to see when they return home, it would be a lot easier for you to leave a message on their voicemail asking them to call you back.


Traditional polling with Director and the SerialXtra

You can make the same request of the SerialXtra, and offload the responsibility for checking the serial port status to the Xtra, creating a "callback." You tell the Xtra to call you back, that is call one of your handlers when the right amount of stuff has come in the from the serial port. In the background, the xtra will then do all the work you would do in the exitframe, and call the handler you specified with the incoming data delivered as a parameter variable. If you have done internet programming you are probably already familiar with these two ways of dealing with the asynchronous nature of the communication, netlingo uses polling but the multiuser Xtra uses a callback, actionscript uses callbacks for everything.


Callback into Director from the SerialXtra

Using callbacks frees you to concentrate on other things, but has a problem. If there is an error with the SerialXtra it would normally return an error when you poll, now a separate callback, "SerialXtra_XtraError" message is sent. See section below on "Extended error reporting"


Another view of the callback process - ReadUsingCallback

Detail - Callback during normal Director operation (asynchronous)

NOTES on Callbacks

 

Part B - Extended error reporting

 


Conditions of use

In this document Xtra refers to this Xtra, and me refers to Geoff Smith. All rights to the XObject/Xtra are retained by me. The XObject may be used in any MacroMedia Director document for personal use and given to your friends. All documentation must be included when passing on the XObject/Xtra. Unless licensed you may NOT do the following ·distribute for profit without prior permission. ·distribute for profit within a Director presentation without prior permission ·distribute by CD-ROM without prior permission. ·distribute as part of a collection without prior permission ·be used in a public presentation without prior permission.
Financial liabilty for this product is limited to the purchase price or $1, whichever is greater.
All legal proceeding must be carried out under the auspices of the court of Santa Clara, California, USA. These conditions may be modified at any time. Please refer to the physicalbits website for the latest conditions.