MATES / Modular Automatic Test Equipment System API  2.5.0.0
Data Structures | Typedefs | Enumerations | Functions
mates.h File Reference

MATES system access library. More...

Data Structures

struct  MATES_DESC_TYPE
 

Typedefs

typedef MATES_DESC_TYPEMATES_HANDLE
 

Enumerations

Functions

void mates_set_verbosity (int level)
 Set the verbosity level. More...
 
UOS_STATUS mates_monitor_version (char *buf, int max)
 Get the underlying uOS_monitor instance version. More...
 
UOS_STATUS mates_monitor_path (char *buf, int max)
 Get the underlying uOS_monitor instance path. More...
 
UOS_STATUS mates_dll_version (char *buf, int max)
 Get the mates.dll file version. More...
 
UOS_STATUS mates_dll_path (char *buf, int max)
 Get the mates.dll file path. More...
 
int mates_get_last_error (char *msg, int max)
 Get the lastly occurred error. More...
 
int mates_get_last_error_ex (MATES_HANDLE h, char *msg, int max)
 Get the lastly occurred error for the specified MATES handle. More...
 
void mates_print_errors (void)
 Print MATES error messages to standard output. More...
 
void mates_print_errors_ex (MATES_HANDLE h)
 Print MATES error messages to standard output. More...
 
void mates_clear_errors (void)
 Clear all error messages without printing. More...
 
void mates_clear_errors_ex (MATES_HANDLE h)
 Clear all error messages without printing. More...
 
MATES_HANDLE mates_open (char *conf_file_name, int addr)
 Open the MATES communication channel. More...
 
MATES_HANDLE mates_open_buffer (char *conf_string, int addr)
 Open the MATES communication channel. More...
 
UOS_STATUS mates_close (MATES_HANDLE h)
 Close the MATES communication channel. More...
 
UOS_STATUS mates_discover_single_node (MATES_HANDLE h, int addr)
 Check if the specified node is present on the bus. More...
 
UOS_STATUS mates_get_din_all (MATES_HANDLE h, int addr, int *value)
 Get value of all digital inputs. More...
 
UOS_STATUS mates_get_din (MATES_HANDLE h, int addr, int channel, int *value)
 Get value of an individual digital input. More...
 
UOS_STATUS mates_set_dout_all (MATES_HANDLE h, int addr, int value)
 Set value of all digital outputs. More...
 
UOS_STATUS mates_set_dout_all_ex (MATES_HANDLE h, int addr, int value, MATES_DIO_OUT_MODE_TYPE mode)
 Set value of all digital outputs using the specified mode. More...
 
UOS_STATUS mates_set_dout (MATES_HANDLE h, int addr, int channel, int value)
 Set value of an individual digital output. More...
 
UOS_STATUS mates_get_dout_all (MATES_HANDLE h, int addr, int *value)
 Get value of all digital outputs. More...
 
UOS_STATUS mates_get_dout (MATES_HANDLE h, int addr, int channel, int *value)
 Get value of an individual digital output. More...
 
UOS_STATUS mates_toggle_dout (MATES_HANDLE h, int addr, int channel)
 Toggle state of an individual digital output. More...
 
UOS_STATUS mates_set_dac_raw (MATES_HANDLE h, int addr, int channel, int value)
 Set raw value of the DAC. More...
 
UOS_STATUS mates_get_dac_raw (MATES_HANDLE h, int addr, int channel, int *value)
 Get the raw value of the DAC. More...
 
UOS_STATUS mates_set_dac (MATES_HANDLE h, int addr, int channel, double value)
 Set the value of the DAC (Volts). More...
 
UOS_STATUS mates_get_dac (MATES_HANDLE h, int addr, int channel, double *value)
 Get the value of the DAC (Volts). More...
 
UOS_STATUS mates_get_adc (MATES_HANDLE h, int addr, int channel, double *value)
 Get the value of the ADC (Volts). More...
 
UOS_STATUS mates_get_adc_raw (MATES_HANDLE h, int addr, int channel, int *value)
 Get the raw value of the ADC. More...
 
UOS_STATUS mates_save_default (MATES_HANDLE h, int addr, int channel)
 Save the current value of an output channel as a default value. More...
 
UOS_STATUS mates_set_register (MATES_HANDLE h, int addr, int reg, int value)
 Set regular (integral) MATES register. More...
 
UOS_STATUS mates_set_register_f (MATES_HANDLE h, int addr, int reg, float value)
 Set floating point MATES register. More...
 
UOS_STATUS mates_get_register (MATES_HANDLE h, int addr, int reg, int *value)
 Get regular (integral) MATES register. More...
 
UOS_STATUS mates_get_register_f (MATES_HANDLE h, int addr, int reg, float *value)
 Get floating point MATES register. More...
 
UOS_STATUS mates_get_register_sr (MATES_HANDLE h, int addr, int *value)
 Convenience function to get the status register SR. More...
 
UOS_STATUS mates_get_register_fir (MATES_HANDLE h, int addr, int *value)
 Convenience function to get the firmware identification register FIR. More...
 
UOS_STATUS mates_node_info (MATES_HANDLE h, int addr, char *buf, int max)
 Get node information as string. More...
 
UOS_STATUS mates_enable_generators (MATES_HANDLE h, int addr, int enable)
 Enable signal generators for a node. More...
 
UOS_STATUS mates_setup_generator (MATES_HANDLE h, int addr, int channel, unsigned int period, unsigned int rise_time, unsigned int fall_time)
 Setup signal generator for a digital channel. More...
 
UOS_STATUS mates_lamp_test (MATES_HANDLE h, int addr)
 Execute the lamp test. See CR register documentation for details. More...
 
UOS_STATUS mates_alcd_write (MATES_HANDLE h, int addr, int row, int col, char *text)
 Write text onto the alphanumeric LCD display. More...
 
char * mates_status_name (UOS_STATUS code)
 Translate MATES status code into string representation. More...
 

Detailed Description

MATES system access library.

mates.h


  Copyright (C) 2013-2018 Viresco
  Lukasz Matecki lukas.nosp@m.z.ma.nosp@m.tecki.nosp@m.@vir.nosp@m.esco..nosp@m.pl
  All rights reserved

  Project:           MATES-DLL
  Platform:          Windows XP SP3, Windows 7, Windows 8, Windows 10
  Processor:         x86
  
Version
$Revision: 4022 $
Date
Created: 2013-07-19
Last modified: $Date:: 2019-01-21#$
Author
Created by: Lukasz Matecki
Last modified by: $Author: Lukasz $

Typedef Documentation

Represents MATES connection handle.

Enumeration Type Documentation

enum UOS_STATUS

Generic status.

Enumerator
UOS_STATUS_ONE 

(1) When non-negative, UOS_STATUS may be used to indicate amount.

UOS_STATUS_OK 

(0) No error or 0 when used to return amount.

UOS_STATUS_ERROR 

(-1) Generic error.

UOS_STATUS_EINVAL 

(-2) Invalid input value.

UOS_STATUS_ETIMEOUT 

(-3) Timeout.

UOS_STATUS_ECORRUPT 

(-4) Data corrupt.

UOS_STATUS_EBUSY 

(-5) Resource is busy.

UOS_STATUS_ERANGE 

(-6) Range error.

UOS_STATUS_EAGAIN 

(-7) Could not complete operation, try again.

UOS_STATUS_ENODATA 

(-8) There is no data available.

UOS_STATUS_ETOOBIG 

(-9) There is too much data or too little room.

UOS_STATUS_EFULL 

(-10) No more space available.

UOS_STATUS_ESTALE 

(-11) The data is no longer valid.

MATES node address enumeration. Used to distinguish node types and node specimens.

Enumerator
CANopen_node_min 

(1) Minimum node number.

mates_node_min_addr 

(20) Minimum address for MATES node.

mates_dio3_mk1_1 

(20) MATES-DIO3-MK1, 1st device in the system.

mates_dio3_mk1_2 

(21) MATES-DIO3-MK1, 2nd device in the system.

mates_dio3_mk1_3 

(22) MATES-DIO3-MK1, 3rd device in the system.

mates_dio3_mk1_4 

(23) MATES-DIO3-MK1, 4th device in the system.

mates_dio3_mk1_5 

(24) MATES-DIO3-MK1, 5th device in the system.

mates_dio3_mk1_6 

(25) MATES-DIO3-MK1, 6th device in the system.

mates_dio3_mk1_7 

(26) MATES-DIO3-MK1, 7th device in the system.

mates_dio3_mk1_8 

(27) MATES-DIO3-MK1, 8th device in the system.

mates_dio3_mk1_9 

(28) MATES-DIO3-MK1, 9th device in the system.

mates_dio3_mk1_10 

(29) MATES-DIO3-MK1, 10th device in the system.

mates_ucc_mk1_1 

(30) MATES-UCC-MK1, 1st device in the system.

mates_ucc_mk1_2 

(31) MATES-UCC-MK1, 2nd device in the system.

mates_ucc_mk1_3 

(32) MATES-UCC-MK1, 3rd device in the system.

mates_ucc_mk1_4 

(33) MATES-UCC-MK1, 4th device in the system.

mates_ucc_mk1_5 

(34) MATES-UCC-MK1, 5th device in the system.

mates_ucc_mk1_6 

(35) MATES-UCC-MK1, 6th device in the system.

mates_ucc_mk1_7 

(36) MATES-UCC-MK1, 7th device in the system.

mates_ucc_mk1_8 

(37) MATES-UCC-MK1, 8th device in the system.

mates_ucc_mk1_9 

(38) MATES-UCC-MK1, 9th device in the system.

mates_ucc_mk1_10 

(39) MATES-UCC-MK1, 10th device in the system.

mates_diox_mk1_1 

(40) MATES-DIOX-MK1, 1st device in the system.

mates_diox_mk1_2 

(41) MATES-DIOX-MK1, 2nd device in the system.

mates_diox_mk1_3 

(42) MATES-DIOX-MK1, 3rd device in the system.

mates_diox_mk1_4 

(43) MATES-DIOX-MK1, 4th device in the system.

mates_diox_mk1_5 

(44) MATES-DIOX-MK1, 5th device in the system.

mates_diox_mk1_6 

(45) MATES-DIOX-MK1, 6th device in the system.

mates_diox_mk1_7 

(46) MATES-DIOX-MK1, 7th device in the system.

mates_diox_mk1_8 

(47) MATES-DIOX-MK1, 8th device in the system.

mates_diox_mk1_9 

(48) MATES-DIOX-MK1, 9th device in the system.

mates_diox_mk1_10 

(49) MATES-DIOX-MK1, 10th device in the system.

mates_dac5_mk1_1 

(50) MATES-DAC5-MK1, 1st device in the system.

mates_dac5_mk1_2 

(51) MATES-DAC5-MK1, 2nd device in the system.

mates_dac5_mk1_3 

(52) MATES-DAC5-MK1, 3rd device in the system.

mates_dac5_mk1_4 

(53) MATES-DAC5-MK1, 4th device in the system.

mates_dac5_mk1_5 

(54) MATES-DAC5-MK1, 5th device in the system.

mates_dac5_mk1_6 

(55) MATES-DAC5-MK1, 5th device in the system.

mates_dac5_mk1_7 

(56) MATES-DAC5-MK1, 6th device in the system.

mates_dac5_mk1_8 

(57) MATES-DAC5-MK1, 7th device in the system.

mates_dac5_mk1_9 

(58) MATES-DAC5-MK1, 8th device in the system.

mates_dac5_mk1_10 

(59) MATES-DAC5-MK1, 10th device in the system.

mates_adc5_mk1_1 

(60) MATES-ADC5-MK1, 1st device in the system.

mates_adc5_mk1_2 

(61) MATES-ADC5-MK1, 2nd device in the system.

mates_adc5_mk1_3 

(62) MATES-ADC5-MK1, 3rd device in the system.

mates_adc5_mk1_4 

(63) MATES-ADC5-MK1, 4th device in the system.

mates_adc5_mk1_5 

(64) MATES-ADC5-MK1, 5th device in the system.

mates_adc5_mk1_6 

(65) MATES-ADC5-MK1, 5th device in the system.

mates_adc5_mk1_7 

(66) MATES-ADC5-MK1, 6th device in the system.

mates_adc5_mk1_8 

(67) MATES-ADC5-MK1, 7th device in the system.

mates_adc5_mk1_9 

(68) MATES-ADC5-MK1, 8th device in the system.

mates_adc5_mk1_10 

(69) MATES-ADC5-MK1, 10th device in the system.

mates_node_max_addr 

(69) Maximum address for MATES node.

CANopen_node_max 

(127) Maximum node number.

MATES output channels enumeration.

Enumerator
MATES_OUT01 

(0) Output #1 - front panel designation: OUT01.

MATES_OUT02 

(1) Output #2 - front panel designation: OUT02.

MATES_OUT03 

(2) Output #3 - front panel designation: OUT03.

MATES_OUT04 

(3) Output #4 - front panel designation: OUT04.

MATES_OUT05 

(4) Output #5 - front panel designation: OUT05.

MATES_OUT06 

(5) Output #6 - front panel designation: OUT06.

MATES_OUT07 

(6) Output #7 - front panel designation: OUT07.

MATES_OUT08 

(7) Output #8 - front panel designation: OUT08.

MATES_OUT09 

(8) Output #9 - front panel designation: OUT09.

MATES_OUT10 

(9) Output #10 - front panel designation: OUT10.

MATES_OUT11 

(10) Output #11 - front panel designation: OUT11.

MATES_OUT12 

(11) Output #12 - front panel designation: OUT12.

MATES_OUT13 

(12) Output #13 - front panel designation: OUT13.

MATES_OUT14 

(13) Output #14 - front panel designation: OUT14.

MATES_OUT15 

(14) Output #15 - front panel designation: OUT15.

MATES_OUT16 

(15) Output #16 - front panel designation: OUT16.

MATES_OUT17 

(16) Output #17 - front panel designation: OUT17.

MATES_OUT18 

(17) Output #18 - front panel designation: OUT18.

MATES_OUT19 

(18) Output #19 - front panel designation: OUT19.

MATES_OUT20 

(19) Output #20 - front panel designation: OUT20.

MATES_OUT21 

(20) Output #21 - front panel designation: OUT21.

MATES_OUT22 

(21) Output #22 - front panel designation: OUT22.

MATES_OUT23 

(22) Output #23 - front panel designation: OUT23.

MATES_OUT24 

(23) Output #24 - front panel designation: OUT24.

MATES_OUT25 

(24) Output #25 - front panel designation: OUT25.

MATES_OUT26 

(25) Output #26 - front panel designation: OUT26.

MATES_OUT27 

(26) Output #27 - front panel designation: OUT27.

MATES_OUT28 

(27) Output #28 - front panel designation: OUT28.

MATES_OUT29 

(28) Output #29 - front panel designation: OUT29.

MATES_OUT30 

(29) Output #30 - front panel designation: OUT30.

MATES_OUT31 

(30) Output #31 - front panel designation: OUT31.

MATES_OUT32 

(31) Output #32 - front panel designation: OUT32.

MATES_OUT33 

(32) Output #33 - front panel designation: OUT33.

MATES_OUT34 

(33) Output #34 - front panel designation: OUT34.

MATES_OUT35 

(34) Output #35 - front panel designation: OUT35.

MATES_OUT36 

(35) Output #36 - front panel designation: OUT36.

MATES_OUT37 

(36) Output #37 - front panel designation: OUT37.

MATES_OUT38 

(37) Output #38 - front panel designation: OUT38.

MATES_OUT39 

(38) Output #39 - front panel designation: OUT39.

MATES_OUT40 

(39) Output #40 - front panel designation: OUT40.

Enumerator
MATES_IN01 

(0) Input #1 - front panel designation: IN01.

MATES_IN02 

(1) Input #2 - front panel designation: IN02.

MATES_IN03 

(2) Input #3 - front panel designation: IN03.

MATES_IN04 

(3) Input #4 - front panel designation: IN04.

MATES_IN05 

(4) Input #5 - front panel designation: IN05.

MATES_IN06 

(5) Input #6 - front panel designation: IN06.

MATES_IN07 

(6) Input #7 - front panel designation: IN07.

MATES_IN08 

(7) Input #8 - front panel designation: IN08.

MATES_IN09 

(8) Input #9 - front panel designation: IN09.

MATES_IN10 

(9) Input #10 - front panel designation: IN10.

MATES_IN11 

(10) Input #11 - front panel designation: IN11.

MATES_IN12 

(11) Input #12 - front panel designation: IN12.

MATES_IN13 

(12) Input #13 - front panel designation: IN13.

MATES_IN14 

(13) Input #14 - front panel designation: IN14.

MATES_IN15 

(14) Input #15 - front panel designation: IN15.

MATES_IN16 

(15) Input #16 - front panel designation: IN16.

MATES_IN17 

(16) Input #17 - front panel designation: IN17.

MATES_IN18 

(17) Input #18 - front panel designation: IN18.

MATES_IN19 

(18) Input #19 - front panel designation: IN19.

MATES_IN20 

(19) Input #20 - front panel designation: IN20.

MATES_IN21 

(20) Input #21 - front panel designation: IN21.

MATES_IN22 

(21) Input #22 - front panel designation: IN22.

MATES_IN23 

(22) Input #23 - front panel designation: IN23.

MATES_IN24 

(23) Input #24 - front panel designation: IN24.

MATES_IN25 

(24) Input #25 - front panel designation: IN25.

MATES_IN26 

(25) Input #26 - front panel designation: IN26.

MATES_IN27 

(26) Input #27 - front panel designation: IN27.

MATES_IN28 

(27) Input #28 - front panel designation: IN28.

MATES_IN29 

(28) Input #29 - front panel designation: IN29.

MATES_IN30 

(29) Input #30 - front panel designation: IN30.

MATES_IN31 

(30) Input #31 - front panel designation: IN31.

MATES_IN32 

(31) Input #32 - front panel designation: IN32.

MATES_IN33 

(32) Input #33 - front panel designation: IN33.

MATES_IN34 

(33) Input #34 - front panel designation: IN34.

MATES_IN35 

(34) Input #35 - front panel designation: IN35.

MATES_IN36 

(35) Input #36 - front panel designation: IN36.

MATES_IN37 

(36) Input #37 - front panel designation: IN37.

MATES_IN38 

(37) Input #38 - front panel designation: IN38.

MATES_IN39 

(38) Input #39 - front panel designation: IN39.

MATES_IN40 

(39) Input #40 - front panel designation: IN40.

The outputs setting mode to be used with mates_set_dout_all_ex().

Enumerator
MATES_DIO_OUT_MODE_SET 

(0) SET mode.

MATES_DIO_OUT_MODE_AND 

(1) AND mode.

MATES_DIO_OUT_MODE_OR 

(2) OR mode.

MATES_DIO_OUT_MODE_XOR 

(3) XOR mode.

Function Documentation

void mates_set_verbosity ( int  level)

Set the verbosity level.

Parameters
[in]levelThe verbosity level:
  • 0 to disable verbose output;
  • 1 to print important messages;
  • 2 to print all messages.
Returns
N/A.

All verbose messages are appended to the error log. They can be obtained the same way the error messages (using e.g. mates_get_last_error()).

UOS_STATUS mates_monitor_version ( char *  buf,
int  max 
)

Get the underlying uOS_monitor instance version.

Parameters
[out]bufWhere to place the result; the version format is "X.X.X.X".
[in]maxAmount of space in buf.
Returns
Status of the operation.
Return values
UOS_STATUS_OKwhen successful.
UOS_STATUS_EINVALwhen there was not enough room in buf.
UOS_STATUS_ENODATAwhen there was no alive handle to operate on.

Example usage (mates_test_20.c):

#include <stdio.h>
#include "mates.h"
int main(void)
{
char buf[100];
if (mates_monitor_version(buf, sizeof(buf)) == UOS_STATUS_OK)
{
printf("The monitor version used: %s\n", buf);
}
return (0);
}
Examples:
mates_test_20.c.
UOS_STATUS mates_monitor_path ( char *  buf,
int  max 
)

Get the underlying uOS_monitor instance path.

Parameters
[out]bufWhere to place the result.
[in]maxAmount of space in buf.
[in,out]-
Returns
Status of the operation.
Return values
UOS_STATUS_OKwhen successful.
UOS_STATUS_EINVALwhen buf is NULL.
Since
mates.dll 2.3.0.0

Example usage (mates_test_38.c):

#include <stdio.h>
#include "mates.h"
int main(void)
{
int status;
char buf[260];
if (mates_monitor_path(buf, sizeof(buf)) == UOS_STATUS_OK)
{
printf("Using monitor at '%s'\n", buf);
return (0);
}
else
{
return (1);
}
}
Examples:
mates_test_38.c.
UOS_STATUS mates_dll_version ( char *  buf,
int  max 
)

Get the mates.dll file version.

Parameters
[out]bufWhere to place the result; the version format is "X.X.X.X".
[in]maxAmount of space in buf.
Returns
The status of the operation.
Return values
UOS_STATUS_OKwhen successful.
UOS_STATUS_EINVALwhen there was not enough room in buf.
UOS_STATUS_ERRORwhen the value cannot be established.

Example usage (mates_test_35.c):

#include <stdio.h>
#include "mates.h"
int main(void)
{
char buf[100];
int success;
if (mates_dll_version(buf, sizeof(buf)) == UOS_STATUS_OK)
{
printf("DLL version: %s\n", buf);
return (0);
}
else
{
printf("Cannot get DLL version\n");
return (1);
}
}
Examples:
mates_test_35.c.
UOS_STATUS mates_dll_path ( char *  buf,
int  max 
)

Get the mates.dll file path.

Parameters
[out]bufWhere to place the result.
[in]maxAmount of space in buf.
[in,out]-
Returns
The status of the operation.
Return values
UOS_STATUS_OKwhen successful.
UOS_STATUS_EINVALwhen there was not enough room in buf.
UOS_STATUS_ERRORwhen the value cannot be established.
Since
mates.dll 2.3.0.0

Example usage (mates_test_37.c):

#include <stdio.h>
#include "mates.h"
int main(void)
{
int status;
char buf[260];
if (mates_dll_path(buf, sizeof(buf)) == UOS_STATUS_OK)
{
printf("Using DLL at '%s'\n", buf);
return (0);
}
else
{
return (1);
}
}
Examples:
mates_test_37.c.
int mates_get_last_error ( char *  msg,
int  max 
)

Get the lastly occurred error.

Parameters
[out]msgWhere to place the result.
[in]maxSpace available in msg.
Returns
Status of the operation.
Return values
nNumber of characters that would have been written if there is enough room in msg.
0on error.
Note
This will get errors for any open MATES handle as well as errors not related to any handle (like handle creation errors). To get errors related only to a specific handle, use mates_get_last_error_ex().

Example usage (mates_test_21.c):

#include <stdio.h>
#include "mates.h"
int main(void)
{
char buf[100];
int idx = 0;
(void)mates_open(NULL, 0);
while (mates_get_last_error(buf, sizeof(buf)) > 0)
{
/* Note: each message has a newline. */
printf("MSG #%04d: %s", idx++, buf);
}
}
Examples:
mates_test_03.c, and mates_test_21.c.
int mates_get_last_error_ex ( MATES_HANDLE  h,
char *  msg,
int  max 
)

Get the lastly occurred error for the specified MATES handle.

Parameters
[in]hThe MATES communication handle.
[out]msgWhere to place the result.
[in]maxAmount of space in msg.
Returns
Status of the operation.
Return values
Numberof characters that would have been written if there is enough room in msg.
0on error.
See also
mates_get_last_error().
Since
mates.dll 2.0.0.0

Example usage (mates_test_34.c):

#include <stdio.h>
#include "mates.h"
int main(void)
{
char buf[100];
int val;
MATES_HANDLE h1 = mates_open("proxy.mon", 1);
MATES_HANDLE h2 = mates_open("missing.mon", 0);
int idx = 0;
while (mates_get_last_error_ex(h1, buf, sizeof(buf)) > 0)
{
/* Note: each message has a newline. */
printf("GET EX 1 #%04d: %s", idx++, buf);
}
/* Try empty handle. */
while (mates_get_last_error_ex(NULL, buf, sizeof(buf)) > 0)
{
/* Note: each message has a newline. */
printf("GET EX 2 #%04d: %s", idx++, buf);
}
/* Try another handle. */
while (mates_get_last_error_ex(h2, buf, sizeof(buf)) > 0)
{
/* Note: each message has a newline. */
printf("GET EX 3 #%04d: %s", idx++, buf);
}
return (0);
}
Examples:
mates_test_34.c.
void mates_print_errors ( void  )

Print MATES error messages to standard output.

Parameters
[in]-
Returns
N/A.

Example usage (mates_test_18.c):

#include <stdio.h>
#include "mates.h"
int main(void)
{
MATES_HANDLE h = mates_open(NULL, 0);
if (h == NULL)
{
printf("MATES opening failed because:\n");
}
}
Examples:
mates_test_08.c, mates_test_10.c, mates_test_18.c, mates_test_27.c, mates_test_28.c, mates_test_29.c, mates_test_33.c, and mates_test_41.c.
void mates_print_errors_ex ( MATES_HANDLE  h)

Print MATES error messages to standard output.

Parameters
[in]hThe MATES communication handle.
Returns
N/A.

Example usage (mates_test_36.c):

#include <stdio.h>
#include "mates.h"
int main(void)
{
MATES_HANDLE h = mates_open("default.mon", 0);
printf("MATES doscovery failed because:\n");
}
Examples:
mates_test_36.c, and mates_test_39.c.
void mates_clear_errors ( void  )

Clear all error messages without printing.

Parameters
[in]-
Returns
N/A.
Note
The error buffer is never cleared internally (except the moment when handle is closed using mates_close()). If errors are expected, the user code should periodically clear them using this function, mates_clear_errors_ex(), mates_get_last_error() or mates_print_errors().
Deprecated:
Use mates_clear_errors_ex() in new code.

Example usage (mates_test_19.c):

#include <stdio.h>
#include "mates.h"
int main(void)
{
MATES_HANDLE h = mates_open(NULL, 0);
int i;
int sr;
if (h == NULL)
{
for (i = 0; i < 100; i++)
{
/* Poll the status register. */
{
printf("SR: %u\n", (unsigned)sr);
}
}
}
}
Examples:
mates_test_19.c.
void mates_clear_errors_ex ( MATES_HANDLE  h)

Clear all error messages without printing.

Parameters
[in]hThe MATES communication handle.
Returns
N/A.
Note
The error buffer is never cleared internally (except the moment when handle is closed using mates_close()). If errors are expected, the user code should periodically clear them using this function, mates_clear_errors(), mates_get_last_error() or mates_print_errors().
Remarks
Use this function instead of mates_clear_errors() in new code.
Since
mates.dll 1.2.0.0
MATES_HANDLE mates_open ( char *  conf_file_name,
int  addr 
)

Open the MATES communication channel.

Parameters
[in]conf_file_nameuOS_monitor configuration file.
[in]addrThe MATES device communication address to use (in the uOS_monitor communication network). Physical devices of the MK1 family have always addresses equal to 0. This has to have the same value as the corresponding @map attribute of the *.mon configuration file specified. The mates_proxy server assumes clients to connect using address of 1. Other values can be used when there is a proxy transport layer implemented between the physical device and mates.dll (like e.g. socket).
Returns
MATES communication handle or NULL on error.

Example usage (mates_test_03.c):

#include <stdio.h>
#include <windows.h>
#include "mates.h"
int main(void)
{
MATES_HANDLE h = mates_open("proxy.mon", 1);
if (h != NULL)
{
printf("Successfully opened MATES\n");
}
else
{
char buf[4096];
while (mates_get_last_error(buf, sizeof(buf)) > 0)
{
printf(buf);
}
}
/* Always close the handle. */
return (0);
}
Examples:
mates_test_03.c, mates_test_04.c, mates_test_05.c, mates_test_06.c, mates_test_07.c, mates_test_08.c, mates_test_09.c, mates_test_10.c, mates_test_11.c, mates_test_12.c, mates_test_13.c, mates_test_14.c, mates_test_15.c, mates_test_16.c, mates_test_17.c, mates_test_18.c, mates_test_19.c, mates_test_21.c, mates_test_22.c, mates_test_23.c, mates_test_24.c, mates_test_25.c, mates_test_26.c, mates_test_27.c, mates_test_28.c, mates_test_29.c, mates_test_30.c, mates_test_31.c, mates_test_32.c, mates_test_33.c, mates_test_34.c, mates_test_36.c, mates_test_39.c, and mates_test_40.c.
MATES_HANDLE mates_open_buffer ( char *  conf_string,
int  addr 
)

Open the MATES communication channel.

Parameters
[in]conf_stringuOS_monitor XML configuration string.
[in]addrThe MATES device communication address to use (in the uOS_monitor communication network). Physical devices of the MK1 family have always addresses equal to 0. This has to have the same value as the corresponding @map attribute of the *.mon configuration file specified. The mates_proxy server assumes clients to connect using address of 1. Other values can be used when there is a proxy transport layer implemented between the physical device and mates.dll (like e.g. socket).
Returns
MATES communication handle or NULL on error.
Since
mates.dll 2.7.0.0

Example usage (mates_test_41.c):

#include <stdio.h>
#include "mates.h"
static char *conf = \
"<?xml version=\"1.0\" encoding=\"utf-8\"?>"
"<uOS_monitor_configuration>"
" <local_address>1</local_address>"
" <named_pipe map=\"1\">"
" <name>\\\\RAKIETA\\pipe\\MATES_PROXY_PIPE</name>"
" <timeout>5000</timeout>"
" </named_pipe>"
"</uOS_monitor_configuration>";
int main(void)
{
int success = 0;
char buf[0x200];
int node = mates_ucc_mk1_1;
{
if (mates_node_info(h, node, buf, sizeof(buf)) == UOS_STATUS_OK)
{
success++;
printf("Found node #%d:\n", node);
printf("%s\n", buf);
}
else
{
}
return (success == 1 ? 0 : -1);
}
else
{
return (0);
}
}
Examples:
mates_test_41.c.
UOS_STATUS mates_close ( MATES_HANDLE  h)

Close the MATES communication channel.

Parameters
[in]hThe MATES communication handle.
Returns
Status of the operation.
Return values
UOS_STATUS_OKwhen successful.
UOS_STATUS_EINVALfor invalid handle.
UOS_STATUS_ECORRUPTwhen handle was already closed.

Example usage (mates_test_39.c):

#include <stdio.h>
#include "mates.h"
int main(void)
{
int success = 0;
MATES_HANDLE h = mates_open("default.mon", 0);
{
printf("Found UCC node.\n");
/* After closing of the handle it is not usable anymore. */
{
success++;
}
{
success++;
}
return (success == 2 ? 0 : -1);
}
else
{
return (0);
}
}

This functions performs all necessary cleanup - closes the communication channels and frees any allocated resources.

Examples:
mates_test_03.c, mates_test_04.c, mates_test_05.c, mates_test_06.c, mates_test_07.c, mates_test_08.c, mates_test_09.c, mates_test_10.c, mates_test_11.c, mates_test_12.c, mates_test_13.c, mates_test_14.c, mates_test_15.c, mates_test_16.c, mates_test_17.c, mates_test_18.c, mates_test_19.c, mates_test_22.c, mates_test_23.c, mates_test_24.c, mates_test_25.c, mates_test_26.c, mates_test_27.c, mates_test_28.c, mates_test_29.c, mates_test_30.c, mates_test_31.c, mates_test_32.c, mates_test_33.c, mates_test_34.c, mates_test_36.c, mates_test_39.c, mates_test_40.c, and mates_test_41.c.
UOS_STATUS mates_discover_single_node ( MATES_HANDLE  h,
int  addr 
)

Check if the specified node is present on the bus.

Parameters
[in]hThe MATES communication handle.
[in]addrThe node CAN address.
Returns
Status of the operation.
Return values
UOS_STATUS_OKwhen the given node was found in the system.
UOS_STATUS_EINVALwhen h is invalid or addr is out of range.
UOS_STATUS_ETIMEOUTwhen the node cannot be found.
UOS_STATUS_ERRORon any other error.

Example usage (mates_test_04.c):

#include <stdio.h>
#include "mates.h"
int main(void)
{
MATES_HANDLE h = mates_open("proxy.mon", 1);
{
printf("Found node #20\n");
}
}

See also MATES manual

Examples:
mates_test_04.c, mates_test_07.c, mates_test_08.c, mates_test_09.c, mates_test_10.c, mates_test_11.c, mates_test_22.c, mates_test_23.c, mates_test_24.c, mates_test_25.c, mates_test_26.c, mates_test_27.c, mates_test_28.c, mates_test_29.c, mates_test_30.c, mates_test_31.c, mates_test_32.c, mates_test_33.c, mates_test_36.c, mates_test_39.c, mates_test_40.c, and mates_test_41.c.
UOS_STATUS mates_get_din_all ( MATES_HANDLE  h,
int  addr,
int *  value 
)

Get value of all digital inputs.

Parameters
[in]hThe MATES communication handle.
[in]addrThe node CAN address.
[out]valueWhere to store the result, LSB is IN01.
Returns
Status of the operation.
Return values
UOS_STATUS_OKwhen successful.

Example usage (mates_test_23.c):

#include <stdio.h>
#include "mates.h"
int main(void)
{
MATES_HANDLE h = mates_open("proxy.mon", 1);
int success = 0;
int value = 0;
/* Check if node is present. */
{
return (0);
}
/* Get the values of all digital inputs. */
{
success++;
printf("Successfully got all inputs: 0x%X\n", value);
}
return ((success == 1) ? 0 : -1);
}
Examples:
mates_test_23.c, mates_test_24.c, and mates_test_34.c.
UOS_STATUS mates_get_din ( MATES_HANDLE  h,
int  addr,
int  channel,
int *  value 
)

Get value of an individual digital input.

Parameters
[in]hThe MATES communication handle.
[in]addrThe node CAN address.
[in]channelThe DIN channel number [0,19].
[out]valueWhere to store the result.
Returns
Status of the operation.
Return values
UOS_STATUS_OKwhen successful.

Example usage (mates_test_05.c):

#include <stdio.h>
#include "mates.h"
int main(void)
{
MATES_HANDLE h = mates_open("proxy.mon", 1);
int value;
{
printf("Channel #1: %d\n", value);
}
{
printf("Channel #1: %d\n", value);
}
}
Examples:
mates_test_05.c, mates_test_06.c, and mates_test_32.c.
UOS_STATUS mates_set_dout_all ( MATES_HANDLE  h,
int  addr,
int  value 
)

Set value of all digital outputs.

Parameters
[in]hThe MATES communication handle.
[in]addrThe node CAN address.
[in]valueThe output value, LSB is OUT01.
Returns
Status of the operation.
Return values
UOS_STATUS_OKwhen successful.

Example usage (mates_test_25.c):

#include <stdio.h>
#include "mates.h"
int main(void)
{
MATES_HANDLE h = mates_open("proxy.mon", 1);
int success = 0;
int value = 0xCAFE;
/* Check if node is present. */
{
return (0);
}
/* Set the values of all digital outputs. */
{
success++;
printf("Successfully set all outputs: 0x%X\n", value);
}
value = 0;
/* Read back. */
{
success++;
printf("Successfully got all outputs: 0x%X\n", value);
}
return ((success == 2) ? 0 : -1);
}
Examples:
mates_test_24.c, mates_test_25.c, mates_test_26.c, and mates_test_32.c.
UOS_STATUS mates_set_dout_all_ex ( MATES_HANDLE  h,
int  addr,
int  value,
MATES_DIO_OUT_MODE_TYPE  mode 
)

Set value of all digital outputs using the specified mode.

Parameters
[in]hThe MATES communication handle.
[in]addrThe node CAN address.
[in]valueThe output value, LSB is OUT01.
[in]modeValue setting mode:
  • 0: SET (OUT <- value)
  • 1: AND (OUT <- OUT & value)
  • 2: OR (OUT <- OUT | value)
  • 3: XOR (OUT <- OUT ^ value)
Returns
Status of the operation.
Return values
UOS_STATUS_OKwhen successful.

Example usage (mates_test_26.c):

#include <stdio.h>
#include "mates.h"
int main(void)
{
MATES_HANDLE h = mates_open("proxy.mon", 1);
int success = 0;
int value = 0xBACA;
/* Check if node is present. */
{
return (0);
}
/* Set the values of all digital outputs. */
{
success++;
printf("Successfully set all outputs: 0x%X\n", value);
}
/* Now use AND mode to clear part of the outputs. */
value = 0xFF0F;
{
success++;
printf("Successfully ANDed outputs: 0x%X\n", value);
}
value == 0xBA0A)
{
success++;
printf("Successfully got all outputs: 0x%X\n", value);
}
return ((success == 3) ? 0 : -1);
}
Examples:
mates_test_26.c.
UOS_STATUS mates_set_dout ( MATES_HANDLE  h,
int  addr,
int  channel,
int  value 
)

Set value of an individual digital output.

Parameters
[in]hThe MATES communication handle.
[in]addrThe node CAN address.
[in]channelThe DOUT channel number [0,19].
[in]valueThe output value.
Returns
Status of the operation.
Return values
UOS_STATUS_OKwhen successful.

Example usage (mates_test_06.c):

#include <stdio.h>
#include "mates.h"
int main(void)
{
MATES_HANDLE h = mates_open("proxy.mon", 1);
int value;
{
printf("Channel #1: %d\n", value);
}
/* Create a bridge between the input of one node and output of another node. */
}
Examples:
mates_test_06.c, mates_test_07.c, and mates_test_30.c.
UOS_STATUS mates_get_dout_all ( MATES_HANDLE  h,
int  addr,
int *  value 
)

Get value of all digital outputs.

Parameters
[in]hThe MATES communication handle.
[in]addrThe node CAN address.
[out]valueWhere to store the result, LSB is OUT01.
Returns
Status of the operation.
Return values
UOS_STATUS_OKwhen successful.

Example usage (mates_test_24.c):

#include <stdio.h>
#include "mates.h"
int main(void)
{
MATES_HANDLE h = mates_open("proxy.mon", 1);
int success = 0;
unsigned int value = 0;
/* Check if node is present. */
{
return (0);
}
/* Get the values of all digital outputs. */
{
success++;
printf("Successfully got all outputs: 0x%X\n", value);
}
/* Now negate. */
value = (~value) & 0xFFFFF;
{
success++;
printf("Successfully set outputs: 0x%X\n", value);
}
/* Read back. */
{
success++;
printf("Successfully got all outputs: 0x%X\n", value);
}
/* If we have loopback between inputs and outputs, we can also verify
the outputs. */
{
success++;
printf("Successfully got all inputs: 0x%X\n", value);
}
return ((success == 4) ? 0 : -1);
}
Examples:
mates_test_24.c, mates_test_25.c, and mates_test_26.c.
UOS_STATUS mates_get_dout ( MATES_HANDLE  h,
int  addr,
int  channel,
int *  value 
)

Get value of an individual digital output.

Parameters
[in]hThe MATES communication handle.
[in]addrThe node CAN address.
[in]channelThe DOUT channel number [0,19].
[out]valueWhere to store the result.
Returns
Status of the operation.
Return values
UOS_STATUS_OKwhen successful.

Example usage (mates_test_07.c):

#include <stdio.h>
#include "mates.h"
int main(void)
{
MATES_HANDLE h = mates_open("proxy.mon", 1);
int success = 0;
int value;
/* Check if node is present. */
{
return (0);
}
{
success++;
printf("Channel #40 is set to: %d\n", value);
}
{
success++;
printf("Successfully toggled output\n");
}
return ((success == 2) ? 0 : -1);
}
Examples:
mates_test_07.c.
UOS_STATUS mates_toggle_dout ( MATES_HANDLE  h,
int  addr,
int  channel 
)

Toggle state of an individual digital output.

Parameters
[in]hThe MATES communication handle.
[in]addrThe node CAN address.
[in]channelThe DOUT channel number [0,19].
Returns
Status of the operation.
Return values
UOS_STATUS_OKwhen successful.

Example usage (mates_test_08.c):

#include <stdio.h>
#include "mates.h"
int main(void)
{
MATES_HANDLE h = mates_open("proxy.mon", 1);
int success = 0;
{
return (0);
}
{
success++;
printf("Successfully toggled output\n");
}
else
{
}
return ((success == 1) ? 0 : -1);
}
Examples:
mates_test_08.c.
UOS_STATUS mates_set_dac_raw ( MATES_HANDLE  h,
int  addr,
int  channel,
int  value 
)

Set raw value of the DAC.

Parameters
[in]hThe MATES communication handle.
[in]addrThe node CAN address.
[in]channelThe DAC channel number [0,39].
[in]valueThe raw DAC binary code to write.
Returns
Status of the operation.
Return values
UOS_STATUS_OKwhen successful.
Note
This function ignores the DAC calibration data.

Example usage (mates_test_09.c):

#include <stdio.h>
#include "mates.h"
int main(void)
{
MATES_HANDLE h = mates_open("proxy.mon", 1);
int success = 0;
{
return (0);
}
/* Set output to 1/10 of the full scale. */
{
success++;
printf("Successfully set raw DAC value\n");
}
return ((success == 1) ? 0 : -1);
}
Examples:
mates_test_09.c, and mates_test_22.c.
UOS_STATUS mates_get_dac_raw ( MATES_HANDLE  h,
int  addr,
int  channel,
int *  value 
)

Get the raw value of the DAC.

Parameters
[in]hThe MATES communication handle.
[in]addrThe node CAN address.
[in]channelThe DAC channel number [0,39].
[out]valueWhere to place the result (raw DAC value).
Returns
Status of the operation.
Return values
UOS_STATUS_OKwhen successful.

Example usage (mates_test_22.c):

#include <stdio.h>
#include "mates.h"
int main(void)
{
MATES_HANDLE h = mates_open("proxy.mon", 1);
int success = 0;
int value = 0;
{
return (0);
}
/* Set output to 1/10 of the full scale. */
{
success++;
printf("Successfully set raw DAC value\n");
}
/* Read back the value. */
value = 0;
{
success++;
printf("Successfully got raw DAC value: %d\n", value);
if (value == (0xFFFF / 10))
{
success++;
}
}
return ((success == 3) ? 0 : -1);
}
Examples:
mates_test_22.c.
UOS_STATUS mates_set_dac ( MATES_HANDLE  h,
int  addr,
int  channel,
double  value 
)

Set the value of the DAC (Volts).

Parameters
[in]hThe MATES communication handle.
[in]addrThe node CAN address.
[in]channelThe DAC channel number [0,39].
[in]valueThe voltage value to set (Volts).
Returns
Status of the operation.
Return values
UOS_STATUS_OKwhen successful.
UOS_STATUS_ERANGEwhen written value is out of range.
Note
This function takes calibration data into account.

Example usage (mates_test_10.c):

#include <stdio.h>
#include "mates.h"
int main(void)
{
MATES_HANDLE h = mates_open("proxy.mon", 1);
int success = 0;
{
return (0);
}
/* Set output to 2.5 V. */
{
success++;
printf("Successfully set DAC voltage value\n");
}
else
{
}
return ((success == 1) ? 0 : -1);
}
Examples:
mates_test_10.c, and mates_test_11.c.
UOS_STATUS mates_get_dac ( MATES_HANDLE  h,
int  addr,
int  channel,
double *  value 
)

Get the value of the DAC (Volts).

Parameters
[in]hThe MATES communication handle.
[in]addrThe node CAN address.
[in]channelThe DAC channel number [0,39].
[out]valueWhere to place the result (voltage value in Volts).
Returns
Status of the operation.
Return values
UOS_STATUS_OKwhen successful.
Warning
When using mates_set_dac() and mates_get_dac() in a pair, the verified value may be slightly different than the set value. This is due to the fact that the value is internally converted to single precision floating point value so precision of the double precision argument can be lost. This behaviour may change in the future.

Example usage (mates_test_11.c):

#include <stdio.h>
#include "mates.h"
int main(void)
{
MATES_HANDLE h = mates_open("proxy.mon", 1);
int success = 0;
double val;
{
return (0);
}
/* Set output to 1.0 V. */
{
success++;
printf("Successfully set DAC voltage value\n");
}
{
success++;
printf("Successfully get DAC voltage value\n");
}
if (val == 1.0)
{
success++;
}
return ((success == 3) ? 0 : -1);
}
Examples:
mates_test_11.c.
UOS_STATUS mates_get_adc ( MATES_HANDLE  h,
int  addr,
int  channel,
double *  value 
)

Get the value of the ADC (Volts).

Parameters
[in]hThe MATES communication handle.
[in]addrThe node CAN address.
[in]channelThe ADC channel number [0,39].
[out]valueWhere to place the result (voltage value in Volts).
Returns
Status of the operation.
Return values
UOS_STATUS_OKwhen successful.
Note
This function takes calibration data into account.

Example usage (mates_test_28.c):

#include <stdio.h>
#include "mates.h"
int main(void)
{
int success = 0;
double val;
MATES_HANDLE h = mates_open("proxy.mon", 1);
/* Check if node is present. */
{
return (0);
}
{
success++;
printf("Value at channel IN 01: %f V\n", val);
}
else
{
}
return ((success == 1) ? 0 : -1);
}
Examples:
mates_test_28.c.
UOS_STATUS mates_get_adc_raw ( MATES_HANDLE  h,
int  addr,
int  channel,
int *  value 
)

Get the raw value of the ADC.

Parameters
[in]hThe MATES communication handle.
[in]addrThe node CAN address.
[in]channelThe ADC channel number [0,39].
[out]valueWhere to place the result (raw DAC value)).
Returns
Status of the operation.
Return values
UOS_STATUS_OKwhen successful.

Example usage (mates_test_29.c):

#include <stdio.h>
#include "mates.h"
int main(void)
{
int success = 0;
int val;
MATES_HANDLE h = mates_open("proxy.mon", 1);
/* Check if node is present. */
{
return (0);
}
{
success++;
printf("Binary value at channel IN 01: %d\n", val);
}
else
{
}
return ((success == 1) ? 0 : -1);
}
Examples:
mates_test_29.c.
UOS_STATUS mates_save_default ( MATES_HANDLE  h,
int  addr,
int  channel 
)

Save the current value of an output channel as a default value.

Parameters
[in]hThe MATES communication handle.
[in]addrThe node CAN address.
[in]channelThe output node channel number, [0,39] for DAC node, [0,19] for DIO3 or DIOX node.
Returns
Status of the operation.
Return values
UOS_STATUS_OKwhen successful.
UOS_STATUS_EINVALwhen the node is not an output node or the channel number is out of range.

Example usage (mates_test_30.c):

#include <stdio.h>
#include "mates.h"
int main(void)
{
MATES_HANDLE h = mates_open("proxy.mon", 1);
int success = 0;
/* Check if node is present. */
{
return (0);
}
/* Set value of output OUT01. */
{
success++;
}
/* Now save the new value as default. */
{
success++;
}
/* Repeat with default value of 0. */
{
success++;
}
{
success++;
}
return ((success == 4) ? 0 : -1);
}
Examples:
mates_test_30.c.
UOS_STATUS mates_set_register ( MATES_HANDLE  h,
int  addr,
int  reg,
int  value 
)

Set regular (integral) MATES register.

Parameters
[in]hThe MATES communication handle.
[in]addrThe node CAN address.
[in]regThe register number to access (see MATES_REG_TYPE).
[in]valueThe register value.
Returns
Status of the operation.
Return values
UOS_STATUS_OKwhen successful.
UOS_STATUS_EINVALwhen register number is invalid.
UOS_STATUS_ERANGEwhen written value is out of range.

Example usage (mates_test_12.c):

#include <stdio.h>
#include "mates.h"
int main(void)
{
MATES_HANDLE h = mates_open("proxy.mon", 1);
/* Outputs startup values for the fist 3.3 V node. */
{
printf("Successfully set default values\n");
}
}
Examples:
mates_test_12.c.
UOS_STATUS mates_set_register_f ( MATES_HANDLE  h,
int  addr,
int  reg,
float  value 
)

Set floating point MATES register.

Parameters
[in]hThe MATES communication handle.
[in]addrThe node CAN address.
[in]regThe register number to access (see MATES_REG_TYPE).
[in]valueThe register value.
Returns
Status of the operation.
Return values
UOS_STATUS_OKwhen successful.
UOS_STATUS_EINVALwhen register number is invalid.
UOS_STATUS_ERANGEwhen written value is out of range.

Example usage (mates_test_13.c):

#include <stdio.h>
#include "mates.h"
int main(void)
{
MATES_HANDLE h = mates_open("proxy.mon", 1);
/* Set minimum value of 0.1 V for second DAC node at channel 1. */
{
printf("Successfully set minimum value\n");
}
}
Examples:
mates_test_13.c.
UOS_STATUS mates_get_register ( MATES_HANDLE  h,
int  addr,
int  reg,
int *  value 
)

Get regular (integral) MATES register.

Parameters
[in]hThe MATES communication handle.
[in]addrThe node CAN address.
[in]regThe register number to access (see MATES_REG_TYPE).
[out]valueWhere to place the result.
Returns
Status of the operation.
Return values
UOS_STATUS_OKwhen successful.
UOS_STATUS_EINVALwhen register number is invalid.

Example usage (mates_test_14.c):

#include <stdio.h>
#include "mates.h"
int main(void)
{
MATES_HANDLE h = mates_open("proxy.mon", 1);
int bir;
/* Get bootloader identification register. */
{
printf("Successfully got BIR: 0x%X\n", bir);
}
}
Examples:
mates_test_14.c.
UOS_STATUS mates_get_register_f ( MATES_HANDLE  h,
int  addr,
int  reg,
float *  value 
)

Get floating point MATES register.

Parameters
[in]hThe MATES communication handle.
[in]addrThe node CAN address.
[in]regThe register number to access (see MATES_REG_TYPE).
[out]valueWhere to place the result.
Returns
Status of the operation.
Return values
UOS_STATUS_OKwhen successful.
UOS_STATUS_EINVALwhen register number is invalid.

Example usage (mates_test_15.c):

#include <stdio.h>
#include "mates.h"
int main(void)
{
MATES_HANDLE h = mates_open("proxy.mon", 1);
float offset;
/* Get calibration offset for second DAC node, channel 1. */
{
printf("Successfully got offset voltage: %f V\n", offset);
}
}
Examples:
mates_test_15.c.
UOS_STATUS mates_get_register_sr ( MATES_HANDLE  h,
int  addr,
int *  value 
)

Convenience function to get the status register SR.

Parameters
[in]hThe MATES communication handle.
[in]addrThe node CAN address.
[out]valueWhere to place the result.
Returns
Status of the operation.
Return values
UOS_STATUS_OKwhen successful.

Example usage (mates_test_16.c):

#include <stdio.h>
#include "mates.h"
int main(void)
{
MATES_HANDLE h = mates_open("proxy.mon", 1);
int sr;
/* Get error status bit from SR. */
{
printf("Error bit: %d\n", (sr & (1 << 1)) ? 1 : 0);
}
}

For registers definitions see MATES manual.

Examples:
mates_test_16.c, and mates_test_19.c.
UOS_STATUS mates_get_register_fir ( MATES_HANDLE  h,
int  addr,
int *  value 
)

Convenience function to get the firmware identification register FIR.

Parameters
[in]hThe MATES communication handle.
[in]addrThe node CAN address.
[out]valueWhere to place the result.
Returns
Status of the operation.
Return values
UOS_STATUS_OKwhen successful.

Example usage (mates_test_17.c):

#include <stdio.h>
#include "mates.h"
int main(void)
{
MATES_HANDLE h = mates_open("proxy.mon", 1);
int fir;
/* Get firmware major version. */
{
printf("Major firmware version: %d\n", (fir >> 24) & 0xFF);
}
}

For registers definitions see MATES manual.

Examples:
mates_test_17.c.
UOS_STATUS mates_node_info ( MATES_HANDLE  h,
int  addr,
char *  buf,
int  max 
)

Get node information as string.

Parameters
[in]hThe MATES communication handle.
[in]addrThe node CAN address.
[out]bufWhere to place the result.
[in]maxThe amount of space in buf.
Returns
Status of the operation.
Return values
UOS_STATUS_OKwhen successful.

Example usage (mates_test_27.c):

#include <stdio.h>
#include "mates.h"
int main(void)
{
char buf[0x200];
int success = 0;
MATES_HANDLE h = mates_open("proxy.mon", 1);
/* Check if node is present. */
{
return (0);
}
if (mates_node_info(h, 20, buf, sizeof(buf)) == UOS_STATUS_OK)
{
success++;
printf("Found node #20:\n");
printf(buf);
}
else
{
}
return ((success == 1) ? 0 : -1);
}
Examples:
mates_test_27.c, and mates_test_41.c.
UOS_STATUS mates_enable_generators ( MATES_HANDLE  h,
int  addr,
int  enable 
)

Enable signal generators for a node.

Parameters
[in]hThe MATES communication handle.
[in]addrThe node CAN address.
[in]enableThe generators enable state.
Returns
Status of the operation.
Return values
UOS_STATUS_OKwhen successful.
Remarks
Only MATES-DIO3-MK1 support signal generators.

Example usage (mates_test_31.c):

#include <stdio.h>
#include "mates.h"
int main(void)
{
MATES_HANDLE h = mates_open("proxy.mon", 1);
int success = 0;
/* Check if node is present. */
{
return (0);
}
/* Disable the generators and then enable them,
this resets all time bases of the generators. */
{
success++;
}
{
success++;
}
return ((success == 2) ? 0 : -1);
}
Examples:
mates_test_31.c, and mates_test_32.c.
UOS_STATUS mates_setup_generator ( MATES_HANDLE  h,
int  addr,
int  channel,
unsigned int  period,
unsigned int  rise_time,
unsigned int  fall_time 
)

Setup signal generator for a digital channel.

Parameters
[in]hThe MATES communication handle.
[in]addrThe node CAN address.
[in]channelThe generator channel to setup [0,19].
[in]periodThe waveform period in microseconds.
[in]rise_timeSignal rise time within the period in microseconds.
[in]fall_timeSignal fall time within the period in microseconds.
Returns
Status of the operation.
Return values
UOS_STATUS_OKwhen successful.
UOS_STATUS_EINVALif
  • period, rise_time or fall_time are not multiple of 125 us;
  • rise_time or fall_time are greater than period;
  • addr points to a node that doesn't support digital signal generators;
  • channel is out of range.
Note
period, rise_time and fall_time have to be a multiple of 125 us.
Remarks
Signal generators are supported by MATES-DIO3-MK1 and MATES-UCC-MK1 nodes.

Example usage (mates_test_32.c):

#include <stdio.h>
#include "mates.h"
int main(void)
{
MATES_HANDLE h = mates_open("proxy.mon", 1);
int success = 0;
int i1, i2;
/* Check if node is present. */
{
return (0);
}
/* Generate quadrature waveform on OUT01 and OUT02 at 1 Hz. */
mates_setup_generator(h, mates_dio3_mk1_1, 0, 1000000, 0, 500000);
mates_setup_generator(h, mates_dio3_mk1_1, 1, 1000000, 250000, 750000);
/* Assume we have outputs to inputs loopback present. */
i1 == 1 && i2 == 0)
{
success++;
}
printf("i1 = %d, i2 = %d\n", i1, i2);
Sleep(260);
i1 == 1 && i2 == 1)
{
success++;
}
printf("i1 = %d, i2 = %d\n", i1, i2);
Sleep(250);
i1 == 0 && i2 == 1)
{
success++;
}
printf("i1 = %d, i2 = %d\n", i1, i2);
Sleep(250);
i1 == 0 && i2 == 0)
{
success++;
}
printf("i1 = %d, i2 = %d\n", i1, i2);
/* Disable generators. */
return ((success == 4) ? 0 : -1);
}
Examples:
mates_test_32.c.
UOS_STATUS mates_lamp_test ( MATES_HANDLE  h,
int  addr 
)

Execute the lamp test. See CR register documentation for details.

Parameters
[in]hThe MATES communication handle.
[in]addrThe node CAN address.
Returns
Status of the operation.
Return values
UOS_STATUS_OKwhen successful.
Note
This function blocks until entire lamp test sequence is executed. For MK1 nodes this lasts ca 5 seconds.

Example usage (mates_test_33.c):

#include <stdio.h>
#include "mates.h"
int main(void)
{
MATES_HANDLE h = mates_open("proxy.mon", 1);
int success = 0;
{
return (0);
}
/* Locate node by blinking its LEDs. */
{
success++;
}
return ((success == 1) ? 0 : -1);
}
Examples:
mates_test_33.c.
UOS_STATUS mates_alcd_write ( MATES_HANDLE  h,
int  addr,
int  row,
int  col,
char *  text 
)

Write text onto the alphanumeric LCD display.

Parameters
[in]hThe MATES communication handle.
[in]addrThe node CAN address.
[in]rowThe LCD row number (0 - based).
[in]colThe LCD column number (0 - based).
[in]textThe NUL - terminated text to write at the given position.
Returns
Status of the operation.
Return values
UOS_STATUS_OKwhen successful.
UOS_STATUS_ERANGEwhen row or col are out of display's range.
UOS_STATUS_ETOOBIGwhen text doesn't fit into the display.
Remarks
This functionality is available only on MATES-UCC-MK1 devices.
Since
mates.dll 2.4.0.0

Example usage (mates_test_40.c):

#include <stdio.h>
#include "mates.h"
int main(void)
{
int success = 0;
MATES_HANDLE h = mates_open("proxy.mon", 1);
{
if (mates_alcd_write(h, mates_ucc_mk1_1, 0, 0, "Hello World!") == UOS_STATUS_OK)
{
success++;
}
if (mates_alcd_write(h, mates_ucc_mk1_1, 1, 0, "MATES LCD") == UOS_STATUS_OK)
{
success++;
}
return (success == 2 ? 0 : -1);
}
else
{
return (0);
}
}
Examples:
mates_test_40.c.
char* mates_status_name ( UOS_STATUS  code)

Translate MATES status code into string representation.

Parameters
[in]codeThe status code.
Returns
The status name.