Only this pageAll pages
Powered by GitBook
1 of 22

ReXgen- Open API Application

Loading...

ReXgen API Documentation

Loading...

Data Conversion Library

Loading...

Loading...

Loading...

Loading...

Device Library

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

ReXgen Open API

The ReXgen Open API libraries contain various functions that the user can use to interact with the ReXgen Series hardware and the files generated from the ReXgen series Data loggers.

Device Library : RgUSBdrv.dll

Data Conversion Library : RxLibrary.dll()

Demo Application:

3MB
ReXgenAPIDemo_V2.zip
archive

RxLib.XmlToRxc()

Converts XML to Configuration file (RXC)

C#

Bool XmlToRxc(string xmlFileName, string rxcFileName)

Parameters:

[in] xmlFileName full Path of the XML configuration settings.

[out] rxcFileName full Path of the ReXgen binary configuration settings.

C# Example:

private void btnXMLToRXC_Click(object sender, EventArgs e)
        {
            if (dlgOpenXML.ShowDialog() != DialogResult.OK)
                return;
            if (dlgSaveRXC.ShowDialog() != DialogResult.OK)
                return;
            RxLib.XmlToRxc(dlgOpenXML.FileName, dlgSaveRXC.FileName);
        }

RxLib.ConvertData()

Converts RXD to MF4, ASC, BLF, MAT, CSV

C#

Bool ConvertData(string inputpath, string outputpath)

Parameters:

[in] Inputpath full Path of the RXD log file.

[out] outputpath full Path of the converted file (should include the output format extension).

C# Example:

private void btnConvertRXD_Click(object sender, EventArgs e)
        {
            if (dlgopenRXD.ShowDialog() != DialogResult.OK)
                return;
            if (dlgSaveConvertedData.ShowDialog() != DialogResult.OK)
                return;
            RxLib.ConvertData(dlgopenRXD.FileName, dlgSaveConvertedData.FileName);
        }

GetFirmwareVersion()

Gets the current firmware version of the logger.

C#

[DllImport("RGUSBdrv.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern byte GetFirmwareVersion(out ushort MajorVersion, out byte 
MinVersion, out byte BranchVersion, out byte FwType);

Returns:

out ushort MajorVersion, out byte MinVersion, out byte BranchVersion, out byte FwType

C# Example:

public static string GetFirmware()
{
 string[] FirmwareReleaseType = new string[4] { "", "A", "B", "RC" };
 byte MinVersion, Res, BranchVersion, fwType;
 ushort MajorVersion;
 Res = GetFirmwareVersion(out MajorVersion, out MinVersion, out BranchVersion, out fwType);
 return $"{MajorVersion}.{MinVersion}.{BranchVersion} {FirmwareReleaseType[fwType]}";
}
private void btnGetFirmware_Click(object sender, EventArgs e)
{
  if (USBDllComm.Connected)
  lblGetFirmware.Text = GetFirmware();
}

SendConfiguration()

Sends the current configuration in RXC format to the logger

C#

[DllImport("RGUSBdrv.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern byte SendConfiguration(char[] FileName, out short Status);

Parameter

[in] FileName

[out] Status

Returns

0 if successfully sent.

If the function returns 0, check Status.

Status 0 – Configuration OK

Status 1 – Bad Config

C# Example:

private void btnSendConfiguration_Click(object sender, EventArgs e)
 {
 if (dlgOpenRxc.ShowDialog() == DialogResult.OK)
  {
   byte Res;
   short Status;
   if (Connected)  //Check if the logger is connected
   {
   Res = SendConfiguration((dlgOpenRxc.FileName + '\0').ToCharArray(), out Status);
   if (Res == 0)
    {
     if (Status != 0)
     MessageBox.Show("Bad Config");
     MessageBox.Show("Logger Configured Successfully");
    }
   else
   MessageBox.Show("Communication Error");
   }                
  }
 }

SetDateTime()

Sets logger date time in UNIX format.

C#

[DllImport("RGUSBdrv.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern byte SetDateTime(uint DateTimeUNIX);

Parameter

[in] DateTimeUNIX

C# Example

private void btnSetDateTime_Click(object sender, EventArgs e)
     {
      uint unixTimestamp;
      unixTimestamp = (UInt32)(DateTime.Now - new DateTime(1970, 1, 1, 0, 0, 0)).TotalSeconds;
      if (Connected)
      SetDateTime(unixTimestamp);
     }

GetLogData()

Retrieves the selected data from eMMC to the PC

C#

Parameter

[in]

FileName (Path including filename.rxd)

Data Start Sector

Data End Sector

Returns:

0 on success

C# Example:

Refer the example application code.

Downloads Section > API

[DllImport("RGUSBdrv.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern byte GetLogData(Char* FileName, uint StartSector, uint EndSector);
https://www.influxtechnology.com/rexgen-support

GetLogCount()

Gets the log count of the main partition.

C#

[DllImport("RGUSBdrv.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern UInt16 GetLogCount();

Returns:

Number of Log Files in the eMMC

C# Example:

private void button2_Click(object sender, EventArgs e)
        {
            if (Connected)
                richTextBox1.AppendText(Convert.ToString(GetLogCount()) + "\n");
        }

RgUSBdrv.dll

The RgUSBdrv library is used to interact with all the ReXgen devices (ReXgen, ReXgen Air etc.) from Influx. Using this function, the user can perform various functions on the ReXgen devices, such as set data/time, reflash logger, send config, get log count etc.

To build an application:

C#

The user will need to import the DLL and create a wrapper.

Open API Application

DeviceIsReady()
GetFirmwareVersion()
SendConfiguration()
ReflashLogger()
InitLiveData()
StopLiveData()
GetDateTime()
SetDateTime()
GetLogCount()
FormatSDCard()
GetSDLogInfo()
GetLogData()

API documentation

Data Conversion Library

Device Library

Example Application

ReflashLogger()

Re-flashes the logger with the firmware.bin file.

C#

[DllImport("RGUSBdrv.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern byte ReflashLogger(char[] FileName, out short Status);

Parameter

[in] FileName

[out] Status

Returns:

0 if file successfully sent.

If the function returns 0 check Status.

Status 0 – Reflash OK

C# Example

private void btnReflash_Click(object sender, EventArgs e)
        {
            if (dlgOpenReflash.ShowDialog() == DialogResult.OK)
            {
                if (Connected) //Check if the logger is connected

                {
                    timerReflash.Start();
                    //Using timer to start the reflash as Async() method
                }
            }
        }

async Task<bool> Reflash(string fwFileName)
        {
            try
            {
                Cursor.Current = Cursors.WaitCursor;
                lblStatus.Text = "Reflash procedure started...";
                byte res = ReflashLogger((fwFileName + '\0').ToCharArray(), out Int16 Status);
                bool error = res == 1 && Status != 0;
                bool connected = false;
                do
                {
                    await Task.Delay(1000);
                    lblStatus.Text = "Logger is updating. Waiting to reconnect...";
                    connected = DeviceIsReady() > 0;
                    if (connected)
                    {
                        await Task.Delay(1000);
                        lblStatus.Text = "";
                        MessageBox.Show("Reflash completed successfully");
                    }

                }
                while (!connected);
                string msg = error ? "Reflash error " + Status.ToString() : "Reflash Completed!";
                lblStatus.Text = msg;
                return !error;
            }
            catch (Exception e)
            {
               return false;
            }
            finally
            {
                Cursor.Current = Cursors.Default;

            }
private async void timer1_Tick(object sender, EventArgs e)
        {
            timerReflash.Enabled = false;
            await Reflash(dlgOpenReflash.FileName);
            Close();
        }

RxLibrary.dll()

The RxLibrary library contains the functions for converting XML to the Configuration file (RXC). It also allows users to perform functions like converting RXD to MF4, ASC, BLF, MAT, and CSV.

The dll is a .Net Standard 2.0 dll and works under Linux, too.

Naming:

The function calls in the ReXgen API all have names starting with RxLib.

To build an application:

C#

The user will need to reference RxLibrary.dll in your programs.

Functions:

RxLib.XmlToRxc()

RxLib.ConvertData()

RxLib.ConvertStatus()

InitLiveData()

Starts live data streaming

C#

unsigned char InitLiveData (unsigned char Channel)

Initialise live data mode

Parameter

[in] Channel

C# Example:

Refer the example application code.

https://www.influxtechnology.com/rexgen-support

Downloads Section > API

GetSDLogInfo()

Gets the Details of log from the eMMC storage

C#

[DllImport("RGUSBdrv.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern byte GetSDLogInfo(
            ushort LogNumber,
            IntPtr StartLogDateTime, IntPtr EndLogDateTime,
            IntPtr LoggingTimeStart, IntPtr LoggingTimeEnd,
            IntPtr LogStartDataSector, IntPtr LogEndDataSector,
            IntPtr LogDataSize, IntPtr GUID, IntPtr FileName, IntPtr isEncrypted);

Parameter

[in] LogNumber

Returns:

Log Start and End Date Time

Logging Time start and End Time

Data Sector where logging started and Data Sector where logging ended

Log Data Size

GUID

File Name

Encryption Status

C# Example:

Refer the example application code.

https://www.influxtechnology.com/rexgen-support

Downloads Section > API

GetDateTime()

Gets the set RTC time

C#

[DllImport("RGUSBdrv.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern UInt32 GetDateTime();

Returns:

Date time in UNIX Date time format

C# Example:

public static DateTime GetDateandTime()
        {
            uint uDateTime;
            uDateTime = GetDateTime();
            return DateTimeOffset.FromUnixTimeSeconds(uDateTime).DateTime;
        }
        private void button1_Click(object sender, EventArgs e)
        {
            if (Connected)
                label1.Text = GetDateandTime().ToString();

        }

DeviceIsReady()

Checks the status of the connected device.

C#

[DllImport("RGUSBdrv.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern byte DeviceIsReady();

Returns:

> 0 if the device is connected.

C# Example:

public static bool Connected
{
get
{
  bool ok = DeviceIsReady() > 0 ? true : DeviceIsReady() > 0;

  return ok;
}
}

FormatSDCard()

Formats the SD Card.

C#

[DllImport("RGUSBdrv.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern byte FormatSDCard(ushort FormatType, out short Status);

Returns:

0 if success

1 if there is a problem with USB communication

C# Example:

Refer to the example application code.

https://www.influxtechnology.com/rexgen-support

Downloads Section > API

RxLib.ConvertStatus()

Returns the last conversion status

C#

string LastConvertStatus()

Returns:

The last conversion status.

C# Example:

private void btnConvertRXD_Click(object sender, EventArgs e)
        {
            if (dlgopenRXD.ShowDialog() != DialogResult.OK)
                return;
            if (dlgSaveConvertedData.ShowDialog() != DialogResult.OK)
                return;
            RxLib.ConvertData(dlgopenRXD.FileName, dlgSaveConvertedData.FileName);
            MessageBox.Show(RxLib.LastConvertStatus());
        }

StopLiveData()

Stops live data streaming

C#

unsigned char StopLiveData(unsigned char Channel)

stop sending live data

Parameter

[in] Channel

C# Example:

Refer the example application code.

https://www.influxtechnology.com/rexgen-support

Downloads Section > API