Unmanaged C APIs - VRTRIX/VRTRIXGlove_Unity3D_SDK GitHub Wiki

C++ DLL for Unity 3D Plugin

bool get_LH_port(char* buf)

Auto Detect Serial Port Name/Number for Left-Hand Glove from Win32 API.

Parameters

  • buf: Char Pointer for the Serial Port Name (Left-Hand) output.

Return

  • true if found the Left-Hand Receiver, false if no Left-Hand Receiver found.

bool get_RH_port(char* buf)

Auto Detect Serial Port Name/Number for Right-Hand Glove from Win32 API.

Parameters

  • buf: Char Pointer for the Serial Port Name (Right-Hand) output.

Return

  • true if found the Right-Hand Receiver, false if no Right-Hand Receiver found.

SerialPort* init_port()

Creat a new instance of SerialPort class.

Return

  • Return a new instance of SerialPort class.

bool open_port(SerialPort *sp, const char* com_port_name, int baud_rate, HANDTYPE type)

Open a Serial Port using serial port name & baud rate.

Parameters

  • SerialPort *sp: Serial Port instance.
  • const char* com_port_name: Serial Port name string.
  • int baud_rate: Serial Port baud rate.
  • HANDTYPE type: Left Hand or Right Hand.

Return

  • true if the serial port successfully opened, false if the serial port open failed.

int data_write(SerialPort *sp , const char* buf)

Synchronized Write string/char array through serial port.

Parameters

  • SerialPort *sp: Serial Port instance.
  • const char* buf: Char buffer to be sent.

Return

  • Return the number of bytes that has been received by serial port.

typedef void(__stdcall *ReceivedDataCallback)(VRTRIX_Quat* data_buf, int data_rate)

Define a function pointer used for receiving data call back (C# Delegate).

Parameters

  • VRTRIX_Quat* data_buf: Data buffer that store imu data struct array.
  • int data_rate: Data transmission rate calculated (data packets received number per second).

void __stdcall RegisterDataCallback(SerialPort* sp, ReceivedDataCallback callback)

Register a data read call back for a specified serial port instance. Used for asynchronized data read from serial port.

Parameters

  • SerialPort *sp: Serial Port instance.
  • ReceivedDataCallback callback: A ReceivedDataCallback instance.

bool close_port(SerialPort *sp)

Close serial port.

Parameters

  • SerialPort *sp: Serial Port instance.

Return

  • true if the serial port successfully closed, false if the serial port close failed.