Cypress Lab for Mac OS 9 and OS X (PowerPC and Intel)
About CyLab
News
Supported Devices
Download
Documentation
Contact
Links
Development for CyLab can be done in many development environments. Here, a quick introduction to development in REALbasic and in C(++) is given.

REALbasic development

For development in REALbasic, you'll need to install the CyLabPlugin.rbx file into the REALbasic plugins folder. This version of the plugin is Universal, i.e. it supports both PPC and i386 (Carbon).

A simple example:

Sub Action ()

	dim cy as CyLab
	dim i as Integer
	cy = CyLab.FindFirstDevice() // Notice the change from the previous plugin version (CyFindFirstDevice).
	i=-2
	cy.OpenDevice
	for i=0 to 255
		cy.WriteDigitalIO 0,i
	next
	i=-1
	cy.CloseDevice
  
exception e as CyLabException
  
	MsgBox ("CyLab exception, error #"+str(e.errorNumber)
			+", ["+e.Message+"]")
 
End Sub
The functions and classes defined by the plugin:
CyLab Class Shared Methods

FindFirstDevice() as CyLab

CyLab Class Methods

FindNextDevice() as CyLab
OpenDevice
CloseDevice
WriteDigitalIO (address as Integer, value as Integer)
ReadDigitalIO (address as Integer) as Integer
SetLEDBrightness (value as Integer)
ReadButton () as Integer
ReadThermometer () as Double
SelectAnalogIn (base as Integer)
CompuLAB (write0 as Integer, ByRef read0 as Integer, 
		ByRef analog0 as Integer, ByRef analog1 as Integer, 
		ByRef analog2 as Integer, ByRef analog3 as Integer)
USBPort (write0 as Integer, write1 as Integer, 
		ByRef read0 as Integer, ByRef read1 as Integer)
SetISink (pin as Integer, value as Integer)
SetPullUp (port as Integer, value as Integer)


CyLab Class Shared Properties

libraryVersionGlobal (Integer)

CyLab Class Properties

selector (Integer)
deviceName (String)
vendor (Integer)
product (Integer)
version (Integer)
id (Integer)
driverVersion (Integer)
libraryVersion (Integer)
location (Integer)


CyLabException Class Properties (RuntimeException subclass)

ErrorNumber (Integer)
Message (string)

C(++) development

For development on OS9 or OSX/Carbon, you'll need the CyLab.h header file and the CyLabLib library stub file.
For development on OSX in Cocoa, you'll need the CyLab.framework framework.

Initialize the library (OS X/Cocoa only):

  long err;
  err = CyLibraryInitialize ();

Find all devices attached using FindFirst/FindNext:

  long err;
  CyDeviceRef ref;

 	for (status = CyFindFirstDevice (&ref); status == cyNoError; 
         status = CyFindNextDevice (&ref)) 
  {
      /* do something with the device */
  }

To use the device you first have to open it:

    err = CyOpenDevice (ref);

Set ports using:

    err = CyWriteDigitalIO (ref, 1, 0x08); /* set port 1 to 0x08 */

Read ports:

    err = CyReadDigitalIO (ref, 0, &value);

Close the device when you're done:

    CyCloseDevice (ref);

Finally, close the library (OS X/Cocoa only):

  long err;
  err = CyLibraryFinalize ();

Look at CyLab.h for more calls.

Copyright 2001-2007 Martijn Plak.
$Id: documentation.html $