DoctorMX Library (MacOSX version)
These are library files to use DoctorMX USB/DMX512 interface hardware from application program.
include
DDrMXLibX.h
C/C++ include file.
lib
libdrmxlibx.a
Static link library file.
Need to be added to your application project.
sample
DrMXLibXTest.cpp
A source file of test application program (console tool).
It should be able to be build with the command line below.
g++ -framework Carbon -framework IOKit DrMXLibTestX.cpp libdrmxlibx.a
It compares output and input data, then shows whether same or not.
(DMX input and output of DoctorMX USB/DMX512 interface hardware should be connected with a cable to loop back)
C/C++ API
Enumerating Devices
RDrMXEnum DrMXEnum_New();
Creates an enumerator for available interface hardware.
void DrMXEnum_Delete(RDrMXEnum aE);
Deletes an enumerator.
aE
An enumerator which is returned by DrMXEnum_New()
.
CFStringRef DrMXEnum_Next(RDrMXEnum aE);
Returns a device identifier (string) one by one.
This identifier is a unique (permanent) serial number for each interface hardware.
(earlier product do not have a serial number, thus USB connection ID which is assigned by system is used instead)
A serial number is 4 digit decimal number.
(alternative identifier for earlier product consists of more characters)
Returns NULL
if no more device is available.
aE
An enumerator which is returned by DrMXEnum_New()
.
Using a Device
RDrMX DrMX_OpenID(CFRunLoopRef aRL, CFStringRef aID);
Opens a specific interface hardware.
Returns an opaque reference to the interface hardware if available.
Returns NULL
if specified hardware is not available for any reason (not connected, etc.).
aRL
A Run Loop (thread) on which input/output completion callback function is executed.
aID
An identifier (serial number) returned by DrMXEnum_Next()
.
If NULL
, any available interface hardware is opened.
RDrMX DrMX_Open(CFRunLoopRef aRL);
Opens an any available interface hardware.
(equivalent to DrMX_OpenID(aRL, NULL);
)
Returns an opaque reference to the interface hardware if available.
Returns NULL
if no hardware is available for any reason (not connected, etc.).
aRL
A Run Loop (thread) on which input/output completion callback function is executed.
void DrMX_Close(RDrMX aR);
Closes an interface hardware.
aR
A reference returned by DrMX_Open()
.
int DrMX_Write(RDrMX aR, const unsigned char* aP, int aL, void(*aCB)(void*), void* aRef);
Outputs DMX data.
To output DMX signal continuously, repeat DrMX_Write()
periodically.
Returns 1
if output begins.
In this case, aCB
will be called when output is completed (aP
is not needed to be valid until complete).
Returns 0
if previous output by DrMX_Write()
has not completed yet.
Also returns 0
for any errors.
aR
A reference returned by DrMX_Open()
.
aP
An array of byte.
The first element (aP[0]
) is a DMX start code (normally 0).
aL
Length of an array, in elements.
Maximum length is 513.
aCB
Output completion callback function.
aRef
An arbitrary pointer which will be passed to output completion callback function.
int DrMX_Read(RDrMX aR, unsigned char* aP, int aL, void(*aCB)(void*), void* aRef);
Inputs DMX data.
Returns -1
if no input data is available.
In this case, aCB
will be called when input is completed (aP
must be valid until complete).
Returns a number of bytes read if there are input data (1 or greater).
Extra data more than specified by aL
are silently discarded.
Returns 0
if previous input by DrMX_Read()
has not completed yet.
Also returns 0
for any errors.
aR
A reference returned by DrMX_Open()
.
aP
An array of byte.
The first element (aP[0]
) is a DMX start code (normally 0).
aL
Length of an array, in elements.
Maximum length is 513.
aCB
Input completion callback function.
aRef
An arbitrary pointer which will be passed to input completion callback function.
int DrMX_SetTiming(RDrMX aR, unsigned int aBrk, unsigned int aMAB, unsigned int aMBS);
Sets output signal timing.
Returns 0
if failed for any reason (device is removed, etc.).
aBrk
Specify a break time.
The minimum value of 92μS is added to this value.
Default is 84 (actual break time is 176μS).
Valid range is from 0 to 255 [μS] .
aMAB
Specify "Mark After Break" time.
The minimum value of 12μS is added to this value.
Default is 0 (actual MAB is 12μS).
Valid range is from 0 to 255 [μS] .
aMBS
Specify "Mark Between Slot" time.
Default is 0 (actual MBS is also 0μS).
Valid range is from 0 to 255 [μS] .
Example
RDrMXEnum de = DrMXEnum_New();
for (;;)
{
CFString id = DrMXEnum_Next(de);
if (id == NULL) break;
CFRelease(id);
}
DrMXEnum_Delete(de);
/* ----------- */
unsigned char wbuf[513];
unsigned char rbuf[513];
int r;
RDrMX drmx = DrMX_Open(runloop);
if (drmx != NULL)
{
/* setup output data
|
|
*/
r = DrMX_Write(drmx, wbuf, 513, wcb, NULL);
if (r == 0)
{
/* retry later */
}
r = DrMX_Read(drmx, rbuf, 513, rcb, NULL);
if (0 < r)
{
/* process input data */
}
DrMX_Close(drmx);
}
For any questions, ask via email.
email (uty@kuwatec.co.jp)