Home AMX User Forum NetLinx Modules & Duet Modules

Issues with ClearOne XAP Module

There appears to be a small bug with the ClearOne XAP module (v1.0.3) found on the AMX site. It doesn't properly interpret the PROPERTY-NetworkConfig command. However, if you specify device types as integers (rather than converting them to their ascii equivalents it will properly read string returned from a network of XAP's.

Additionally it does not properly form the headers of command it sends to the physical device. However, it is possible to create a virtual device to act as a proxy and re-write outgoing strings.
PROGRAM_NAME='XAP Example'


DEFINE_DEVICE

dvDSP =		 5001:1:0		// Clearone XAP network

vdvDSP =		41001:1:0		// Duet device for XAP module comms

vdvXAPProxy =	41002:1:0		// Proxy device for command translation. A Duet
				// has been used as they don't echo back
				// string, thus preventing an infinite loop.


DEFINE_CONSTANT

INTEGER DSP_TYPE_XAP800 = 5		// Device types
INTEGER DSP_TYPE_XAPTH2 = 6
INTEGER DSP_TYPE_XAP400 = 7


DEFINE_COMBINE

(vdvXAPProxy, dvDSP)		// These devices must be combined to
				// allow returned strings to be processed by
				// the control module.

(**
 * Initializes DSP communication parameters.
 *
 * The integer to ascii conversion has been intentionally ommitted to combat
 * the bug in the module.
 *
 *)
DEFINE_FUNCTION fnDSPInit ()
{
    SEND_COMMAND vdvDSP[1], "'PROPERTY-NetworkConfig,',
				DSP_TYPE_XAP400,':0:',
				DSP_TYPE_XAP800,':0'"
    SEND_COMMAND vdvDSP[1], "'REINIT'"
}

(**
 * Translates an outgoing string from the control module into the correct
 * format (see header comment block).
 *
 * @param		sString	the incorrectly formed string to convert
 * @return		a correctly formed string that the device will understand
 *
 *)
DEFINE_FUNCTION CHAR[128] fnDSPTranslateOutgoingString (CHAR sString[])
{
    STACK_VAR INTEGER nDeviceType
    nDeviceType = TYPE_CAST(MID_STRING(sString, 2, 1))

    IF (nDeviceType == DSP_TYPE_XAP400 ||
	nDeviceType == DSP_TYPE_XAP800 ||
	nDeviceType == DSP_TYPE_XAPTH2)
    {
	RETURN "'#',
		ITOA(nDeviceType),
		RIGHT_STRING(sString, LENGTH_STRING(sString) - 2)"
    } ELSE {
	RETURN sString
    }
}


DEFINE_START

DEFINE_MODULE 'ClearOneXAP_Comm_dr1_0_0' mdlDSP(vdvDSP, vdvXAPProxy)


DEFINE_EVENT
DATA_EVENT[vdvDSP]
{
    ONLINE:
    {
	fnDSPInit()
    }
}

DATA_EVENT[vdvXAPProxy]
{
    STRING:
    {
	SEND_STRING dvDSP, fnDSPTranslateOutgoingString(DATA.TEXT)
    }
}
Sign In or Register to comment.