NifTK  16.4.1 - 0798f20
CMIC's Translational Medical Imaging Platform
Macros | Functions
Command Macros

Macros

#define ndi3D(p, ph, mode)   ndiCommand((p),"3D:%02X%d",(ph),(mode))
 
#define ndiBEEP(p, n)   ndiCommand((p),"BEEP:%i",(n))
 
#define ndiCOMM(p, baud, dps, h)   ndiCommand((p),"COMM:%d%03d%d",(baud),(dps),(h))
 
#define ndiDSTART(p)   ndiCommand((p),"DSTART:")
 
#define ndiDSTOP(p)   ndiCommand((p),"DSTOP:")
 
#define ndiGX(p, mode)   ndiCommand((p),"GX:%04X",(mode))
 
#define ndiINIT(p)   ndiCommand((p),"INIT:")
 
#define ndiIRATE(p, rate)   ndiCommand((p),"IRATE:%d",(rate))
 
#define ndiIRCHK(p, mode)   ndiCommand((p),"IRCHK:%04X",(mode))
 
#define ndiIRED(p, ph, sig)   ndiCommand((p),"IRED:%02X%08X",(ph),(sig))
 
#define ndiIRINIT(p)   ndiCommand((p),"IRINIT:")
 
#define ndiLED(p, ph, led, s)   ndiCommand((p),"LED:%02X%d%c",(ph),(led),(s))
 
#define ndiPDIS(p, ph)   ndiCommand((p),"PDIS:%02X",(ph))
 
#define ndiPENA(p, ph, mode)   ndiCommand((p),"PENA:%02X%c",(ph),(mode))
 
#define ndiPFSEL(p, ph, tf)   ndiCommand((p),"PFSEL:%02X%02X",(ph),(tf))
 
#define ndiPHF(p, ph)   ndiCommand((p),"PHF:%02X",(ph))
 
#define ndiPHINF(p, ph, format)   ndiCommand((p),"PHINF:%02X%04X",(ph),(format))
 
#define ndiPHRQ(p, num, sys, tool, port, chan)   ndiCommand((p),"PHRQ:%-8.8s%1.1s%1.1s%2.2s%2.2s",(num),(sys),(tool),(port),(chan))
 
#define ndiPHSR(p, mode)   ndiCommand((p),"PHSR:%02X",(mode))
 
#define ndiPINIT(p, ph)   ndiCommand((p),"PINIT:%02X",(ph))
 
#define ndiPPRD(p, ph, addr)   ndiCommand((p),"PPRD:%02X%04X",(ph),(addr))
 
#define ndiPPWR(p, ph, a, x)   ndiCommand((p),"PPWR:%02X%04X%.128s",(ph),(a),(x))
 
#define ndiPSEL(p, ph, id)   ndiCommand((p),"PSEL:%02X%s",(ph),(id))
 
#define ndiPSOUT(p, ph, a, b, c)   ndiCommand((p),"PSOUT:%02X%c%c%c",(ph),(a),(b),(c))
 
#define ndiPSRCH(p, ph)   ndiCommand((p),"PSRCH:%02X",(ph))
 
#define ndiPSTAT(p, format)   ndiCommand((p),"PSTAT:%04X",(format))
 
#define ndiPURD(p, ph, addr)   ndiCommand((p),"PURD:%02X%04X",(ph),(addr))
 
#define ndiPUWR(p, ph, a, x)   ndiCommand((p),"PPWR:%02X%04X%.128s",(ph),(a),(x))
 
#define ndiPVCLR(p, port)   ndiCommand((p),"PVCLR:%c",(port))
 
#define ndiPVTIP(p, port, tip, np)   ndiCommand((p),"PVTIP:%c%d%d",(port),(tip),(np))
 
#define ndiPVWR(p, ph, a, x)   ndiCommand((p),"PVWR:%02X%04X%.128s",(ph),(a),(x))
 
#define ndiRESET(p)   ndiCommand((p),NULL)
 
#define ndiSFLIST(p, mode)   ndiCommand((p),"SFLIST:%02X",(mode))
 
#define ndiSSTAT(p, format)   ndiCommand((p),"SSTAT:%04X",(format))
 
#define ndiTCTST(p, ph)   ndiCommand((p),"TCTST:%02X",(ph))
 
#define ndiTSTART(p)   ndiCommand((p),"TSTART:")
 
#define ndiTSTOP(p)   ndiCommand((p),"TSTOP:")
 
#define ndiTTCFG(p, ph)   ndiCommand((p),"TTCFG:%02X",(ph))
 
#define ndiTX(p, mode)   ndiCommand((p),"TX:%04X",(mode))
 
#define ndiVER(p, n)   ndiCommand((p),"VER:%d",(n))
 
#define ndiVSEL(p, n)   ndiCommand((p),"VSEL:%d",(n))
 

Functions

int ndiPVWRFromFile (ndicapi *pol, int ph, char *filename)
 

Detailed Description

These are a set of macros that send commands to the device via ndiCommand().

The ndiGetError() function can be used to determine whether an error occurred.

The return value is a terminated string containing the reply from the device with the CRC and final carriage return chopped off.

Macro Definition Documentation

#define ndi3D (   p,
  ph,
  mode 
)    ndiCommand((p),"3D:%02X%d",(ph),(mode))

Get the 3D position and an error value for a single marker on a tool. The mode should be set to 1 or 3. This command is only available in diagnostic mode.

Parameters
phvalid port handle in the range 0x01 to 0xFF
modesee NDI documentation

The IRED command should be used to set up a marker firing signature before this command is called.

#define ndiBEEP (   p,
  n 
)    ndiCommand((p),"BEEP:%i",(n))

Cause the device to beep.

Parameters
nthe number of times to beep, an integer between 1 and 9

A reply of "0" means that the device is already beeping and cannot service this beep request.

This command can be used in tracking mode.

#define ndiCOMM (   p,
  baud,
  dps,
  h 
)    ndiCommand((p),"COMM:%d%03d%d",(baud),(dps),(h))

Change the device communication parameters. The host parameters will automatically be adjusted to match. If the specified baud rate is not supported by the serial port, then the error code will be set to NDI_BAD_COMM and the device will have to be reset before communication can continue. Most modern UNIX systems accept all baud rates except 14400, and Windows systems support all baud rates.

Parameters
baudone of NDI_9600, NDI_14400, NDI_19200, NDI_38400, NDI_57600, NDI_115200
dpsshould usually be NDI_8N1, the most common mode
hone of NDI_HANDSHAKE or NDI_NOHANDSHAKE
#define ndiDSTART (   p)    ndiCommand((p),"DSTART:")

Put the device into diagnostic mode. This must be done prior to executing the IRCHK() command. Diagnostic mode is only useful on the POLARIS

#define ndiDSTOP (   p)    ndiCommand((p),"DSTOP:")

Take the device out of diagnostic mode.

#define ndiGX (   p,
  mode 
)    ndiCommand((p),"GX:%04X",(mode))

Request tracking information from the system. This command is only available in tracking mode. Please note that this command has been deprecated in favor of the TX command.

Parameters
modea reply mode containing the following bits:
  • NDI_XFORMS_AND_STATUS 0x0001 - transforms and status
  • NDI_ADDITIONAL_INFO 0x0002 - additional tool transform info
  • NDI_SINGLE_STRAY 0x0004 - stray active marker reporting
  • NDI_FRAME_NUMBER 0x0008 - frame number for each tool
  • NDI_PASSIVE 0x8000 - include information for ports 'A', 'B', 'C'
  • NDI_PASSIVE_EXTRA 0x2000 - with NDI_PASSIVE, ports 'A' to 'I'
  • NDI_PASSIVE_STRAY 0x1000 - stray passive marker reporting

The GX command with the appropriate reply mode is used to update the data that is returned by the following functions:

#define ndiINIT (   p)    ndiCommand((p),"INIT:")

Initialize the device. The device must be initialized before any other commands are sent.

#define ndiIRATE (   p,
  rate 
)    ndiCommand((p),"IRATE:%d",(rate))

Set the POLARIS infrared firing rate to 20 Hz = 0, 30 Hz = 1, 20 Hz = 2

#define ndiIRCHK (   p,
  mode 
)    ndiCommand((p),"IRCHK:%04X",(mode))

Check for sources of environmental infrared. This command is only valid in diagnostic mode after an IRINIT command.

Parameters
modereply mode bits:
  • NDI_DETECTED 0x0001 - return '1' if IR detected, else '0'
  • NDI_SOURCES 0x0002 - locations of up to 20 sources per camera

The IRCHK command is used to update the information returned by the ndiGetIRCHKDetected() and ndiGetIRCHKSourceXY() functions.

#define ndiIRED (   p,
  ph,
  sig 
)    ndiCommand((p),"IRED:%02X%08X",(ph),(sig))

Set the infrared firing signature for the specified port. This command is only available in diagnostic mode.

Parameters
phvalid port handle in the range 0x01 to 0xFF
siga 32-bit integer whose bits specify what IREDS to fire
#define ndiIRINIT (   p)    ndiCommand((p),"IRINIT:")

Initialize the diagnostic environmental infrared checking system. This command must be called prior to using the IRCHK command.

#define ndiLED (   p,
  ph,
  led,
  s 
)    ndiCommand((p),"LED:%02X%d%c",(ph),(led),(s))

Set a tool LED to a particular state.

Parameters
phvalid port handle in the range 0x01 to 0xFF
ledan integer between 1 and 3
statedesired state: NDI_BLANK 'B', NDI_FLASH 'F' or NDI_SOLID 'S'

This command can be used in tracking mode.

#define ndiPDIS (   p,
  ph 
)    ndiCommand((p),"PDIS:%02X",(ph))

Disable transform reporting on the specified port handle.

Parameters
phvalid port handle in the range 0x01 to 0xFF
#define ndiPENA (   p,
  ph,
  mode 
)    ndiCommand((p),"PENA:%02X%c",(ph),(mode))

Enable transform reporting on the specified port handle.

Parameters
phvalid port handle in the range 0x01 to 0xFF
modeone of NDI_STATIC 'S', NDI_DYNAMIC 'D' or NDI_BUTTON_BOX 'B'
#define ndiPFSEL (   p,
  ph,
  tf 
)    ndiCommand((p),"PFSEL:%02X%02X",(ph),(tf))

Specify a POLARIS tool faces to use for tracking

Parameters
phvalid port handle in the range 0x01 to 0xFF
tftool face mask in the range 0x01 to 0xFF
#define ndiPHF (   p,
  ph 
)    ndiCommand((p),"PHF:%02X",(ph))

Free the specified port handle.

Parameters
phvalid port handle in the range 0x01 to 0xFF
#define ndiPHINF (   p,
  ph,
  format 
)    ndiCommand((p),"PHINF:%02X%04X",(ph),(format))

Ask the device for information about a tool handle.

Parameters
formata reply format mode composed of the following bits:
  • NDI_BASIC 0x0001 - get port status and basic tool information
  • NDI_TESTING 0x0002 - get current test for active tools
  • NDI_PART_NUMBER 0x0004 - get a 20 character part number
  • NDI_ACCESSORIES 0x0008 - get a summary of the tool accessories
  • NDI_MARKER_TYPE 0x0010 - get the tool marker type
  • NDI_PORT_LOCATION 0x0020 - get the physical port location
  • NDI_GPIO_STATUS 0x0040 - get AURORA GPIO status

The use of the PHINF command with the appropriate reply format updates the information returned by the following commands:

This command is not available during tracking mode.

#define ndiPHRQ (   p,
  num,
  sys,
  tool,
  port,
  chan 
)    ndiCommand((p),"PHRQ:%-8.8s%1.1s%1.1s%2.2s%2.2s",(num),(sys),(tool),(port),(chan))

Requeset a port handle given specific tool criteria.

Parameters
num8-digit device number or wildcard "********"
syssystem type TIU "0" or AURORA SCU "1" or wildcard "*"
toolwired "0" or wireless "1" or wildcard "*"
portwired "01" to "10", wireless "0A" to "0I" or wildcard "**"
chanAURORA tool channel "00" or "01" or wildcard "**"

The use of the PHRQ command updates the information returned by the following commands:

#define ndiPHSR (   p,
  mode 
)    ndiCommand((p),"PHSR:%02X",(mode))

List the port handles.

Parameters
modethe reply mode:
  • NDI_ALL_HANDLES 0x00 - return all handles
  • NDI_STALE_HANDLES 0x01 - only handles waiting to be freed
  • NDI_UNINITIALIZED_HANDLES 0x02 - handles needing initialization
  • NDI_UNENABLED_HANDLES 0x03 - handles needing enabling
  • NDI_ENABLED_HANDLES 0x04 - handles that are enabled

The use of the PHSR command with the appropriate reply format updates the information returned by the following commands:

This command is not available during tracking mode.

#define ndiPINIT (   p,
  ph 
)    ndiCommand((p),"PINIT:%02X",(ph))

Initialize the tool on the specified port handle.

Parameters
phvalid port handle in the range 0x01 to 0xFF
#define ndiPPRD (   p,
  ph,
  addr 
)    ndiCommand((p),"PPRD:%02X%04X",(ph),(addr))

Read the tool SROM. Use ndiHexDecode() to convert reply to binary.

#define ndiPPWR (   p,
  ph,
  a,
  x 
)    ndiCommand((p),"PPWR:%02X%04X%.128s",(ph),(a),(x))

Write the tool SROM. Use ndiHexEncode() to convert data to a hex string.

#define ndiPSEL (   p,
  ph,
  id 
)    ndiCommand((p),"PSEL:%02X%s",(ph),(id))

Select an SROM target by ID.

#define ndiPSOUT (   p,
  ph,
  a,
  b,
  c 
)    ndiCommand((p),"PSOUT:%02X%c%c%c",(ph),(a),(b),(c))

Set the three GPIO wire states for an AURORA tool. The states available are 'N' (no change), 'S' (solid on), 'P' (pulse) and 'O' (off).

Parameters
phvalid port handle in the range 0x01 to 0xFF
aGPIO 1 state
bGPIO 2 state
cGPIO 3 state
#define ndiPSRCH (   p,
  ph 
)    ndiCommand((p),"PSRCH:%02X",(ph))

Search for available SROM targets.

#define ndiPSTAT (   p,
  format 
)    ndiCommand((p),"PSTAT:%04X",(format))

Ask for information about the tool ports. This command has been deprecated in favor of the PHINF command.

Parameters
formata reply format mode composed of the following bits:
  • NDI_BASIC 0x0001 - get port status and basic tool information
  • NDI_TESTING 0x0002 - get current test for active tools
  • NDI_PART_NUMBER 0x0004 - get a 20 character part number
  • NDI_ACCESSORIES 0x0008 - get a summary of the tool accessories
  • NDI_MARKER_TYPE 0x0010 - get the tool marker type
  • NDI_PASSIVE 0x8000 - include information for ports 'A', 'B', 'C'
  • NDI_PASSIVE_EXTRA 0x2000 - with NDI_PASSIVE, ports 'A' to 'I'

The use of the PSTAT command with the appropriate reply format updates the information returned by the following commands:

This command is not available during tracking mode.

#define ndiPURD (   p,
  ph,
  addr 
)    ndiCommand((p),"PURD:%02X%04X",(ph),(addr))

Read the user part of the tool SROM. Use ndiHexDecode() convert reply.

#define ndiPUWR (   p,
  ph,
  a,
  x 
)    ndiCommand((p),"PPWR:%02X%04X%.128s",(ph),(a),(x))

Write the user part of the tool SROM. Use ndiHexEncode() to convert data.

#define ndiPVCLR (   p,
  port 
)    ndiCommand((p),"PVCLR:%c",(port))

Clear the virtual SROM for the specified port. For a passive tool, this is equivalent to unplugging the tool. This command has been deprecated in favor of PHF.

Parameters
portone of '1', '2', '3' or 'A' to 'I'
#define ndiPVTIP (   p,
  port,
  tip,
  np 
)    ndiCommand((p),"PVTIP:%c%d%d",(port),(tip),(np))

Set the virtual TOOL IN PORT and non-POLARIS tool signals for this port. This command has been deprecated in favor of PHRQ.

Parameters
portone of '1', '2', '3' or 'A' to 'I'
tipone of 0 (no tool in port) or 1 (tool in port)
typeone of 0 (non-POLARIS tool) or 1 (POLARIS tool)
#define ndiPVWR (   p,
  ph,
  a,
  x 
)    ndiCommand((p),"PVWR:%02X%04X%.128s",(ph),(a),(x))

Write to a virtual SROM address on the specified port handle. The ndiPVWRFromFile() function provides a more convenient means of uploading tool descriptions.

Parameters
phvalid port handle in the range 0x01 to 0xFF
aan address between 0x0000 and 0x07C0
x64-byte data array encoded as a 128-character hexidecimal string

The ndiHexEncode() function can be used to encode the data into hexidecimal.

#define ndiRESET (   p)    ndiCommand((p),NULL)

Send a serial break to reset the device. If the reset was not successful, the error code will be set to NDI_RESET_FAIL.

#define ndiSFLIST (   p,
  mode 
)    ndiCommand((p),"SFLIST:%02X",(mode))

Get a feature list for this device.

Parameters
modethe desired reply mode
  • 0x00 - 32-bit feature summary encoded as 8 hexidecimal digits
  • 0x01 - the number of active tool ports as a single digit
  • 0x02 - the number of passive tool ports as a single digit
  • 0x03 - list of volumes available (see NDI documentation)
  • 0x04 - the number of ports that support tool-in-port current sensing

The feature summary bits are defined as follow:

  • 0x00000001 - active tool ports are available
  • 0x00000002 - passive tool ports are available
  • 0x00000004 - multiple volumes are available
  • 0x00000008 - tool-in-port current sensing is available
#define ndiSSTAT (   p,
  format 
)    ndiCommand((p),"SSTAT:%04X",(format))

Request status information from the device.

Parameters
formata reply format mode composed of the following bits:
  • NDI_CONTROL 0x0001 - control processor information
  • NDI_SENSORS 0x0002 - sensor processors
  • NDI_TIU 0x0004 - TIU processor

The use of the SSTAT command with the appropriate reply format updates the information returned by the following commands:

This command is not available during tracking mode.

#define ndiTCTST (   p,
  ph 
)    ndiCommand((p),"TCTST:%02X",(ph))

Perform a current test on this port.

#define ndiTSTART (   p)    ndiCommand((p),"TSTART:")

Put the device into tracking mode.

#define ndiTSTOP (   p)    ndiCommand((p),"TSTOP:")

Take the device out of tracking mode.

#define ndiTTCFG (   p,
  ph 
)    ndiCommand((p),"TTCFG:%02X",(ph))

Set default tool configuration prior to testing.

#define ndiTX (   p,
  mode 
)    ndiCommand((p),"TX:%04X",(mode))

Request tracking information from the device. This command is only available in tracking mode.

Parameters
modea reply mode containing the following bits:
  • NDI_XFORMS_AND_STATUS 0x0001 - transforms and status
  • NDI_ADDITIONAL_INFO 0x0002 - additional tool transform info
  • NDI_SINGLE_STRAY 0x0004 - stray active marker reporting
  • NDI_PASSIVE_STRAY 0x1000 - stray passive marker reporting

The TX command with the appropriate reply mode is used to update the data that is returned by the following functions:

#define ndiVER (   p,
  n 
)    ndiCommand((p),"VER:%d",(n))

Get a string that describes the device firmware version.

Parameters
nthe processor to get the firmware revision of:
  • 0 - control firmware
  • 1 - left sensor firmware
  • 2 - right sensor firmware
  • 3 - TIU firmware
  • 4 - control firmware with enhanced versioning
#define ndiVSEL (   p,
  n 
)    ndiCommand((p),"VSEL:%d",(n))

Select from the different calibrated operating volumes available to the device.

Parameters
nthe volume to select, see ndiSFLIST()

Function Documentation

int ndiPVWRFromFile ( ndicapi pol,
int  ph,
char *  filename 
)

Write data from a ROM file into the virtual SROM for the specified port.

Parameters
polvalid NDI device handle
phvalid port handle in the range 0x01 to 0xFF
filenamefile to read the SROM data from
Returns
NDI_OKAY if the write was successful

If the return value is not NDI_OKAY but ndiGetError() returns NDI_OKAY, then the ROM file could not be read and no information was written to the device.

This function uses the PVWR command to write the SROM. The total size of the virtual SROM is 1024 bytes. If the file is shorter than this, then zeros will be written to the remaining space in the SROM.