Skip to content

4.7 C99 Signals IO Interface

Overview

C99 Signals provides single-point read, single-point write, batch read, batch write, and IO pulse triggering at time intervals. Pass port numbers using controller-side numbering.

Corresponding header:

  • include/c_arm_signals.h

Interface Signatures

Arm_Signals_Read

c
int Arm_Signals_Read(ArmHandle* h, int signalType, int index, double* outValue);
ItemDescription
DescriptionReads one IO signal
Request Parametersh : ArmHandle* , C99 session handle, usually from Arm_Create() ; business APIs require connection first
signalType : int , signal type. See the supported-scope table
index : int , IO port number
outValue : double* , output signal value pointer
Return ValueSTATUS_CODE integer value; 0 means success, other values should be handled as status codes

Arm_Signals_WriteInt

c
int Arm_Signals_WriteInt(ArmHandle* h, int signalType, int index, int value);
ItemDescription
DescriptionWrites an integer IO signal
Request Parametersh : ArmHandle* , C99 session handle, usually from Arm_Create() ; business APIs require connection first
signalType : int , signal type. Only the values corresponding to DO , RO , GO , and TDO are supported
index : int , IO port number
value : int , integer IO value to write
Return ValueSTATUS_CODE integer value; 0 means success, other values should be handled as status codes

Arm_Signals_WriteFloat

c
int Arm_Signals_WriteFloat(ArmHandle* h, int signalType, int index, double value);
ItemDescription
DescriptionWrites a floating-point IO signal
Request Parametersh : ArmHandle* , C99 session handle, usually from Arm_Create() ; business APIs require connection first
signalType : int , signal type. Only the value corresponding to AO is supported
index : int , IO port number
value : double , floating-point IO value to write
Return ValueSTATUS_CODE integer value; 0 means success, other values should be handled as status codes

Arm_Signals_MultiRead

c
int Arm_Signals_MultiRead(ArmHandle* h, int signalType, const int* portList, size_t portCount, int* outValues, size_t maxCount, size_t* outCount);
ItemDescription
DescriptionBatch-reads IO signals
Request Parametersh : ArmHandle* , C99 session handle, usually from Arm_Create() ; business APIs require connection first
signalType : int , signal type. Only the value corresponding to DO is supported
portList : const int* , port number array
portCount : size_t , number of port numbers
outValues : int* , batch output array allocated by the caller
maxCount : size_t , output array capacity, meaning the maximum number of elements the caller can receive
outCount : size_t* , output count pointer. On success, receives the actual count
Return ValueSTATUS_CODE integer value; 0 means success, other values should be handled as status codes

Arm_Signals_MultiWrite

c
int Arm_Signals_MultiWrite(ArmHandle* h, int signalType, const int* ioList, size_t ioCount);
ItemDescription
DescriptionBatch-writes IO signals
Request Parametersh : ArmHandle* , C99 session handle, usually from Arm_Create() ; business APIs require connection first
signalType : int , signal type. Only the value corresponding to DO is supported
ioList : const int* , flattened IO write array organized as [port, value, port, value]
ioCount : size_t , number of elements in the flattened IO array
Return ValueSTATUS_CODE integer value; 0 means success, other values should be handled as status codes

Arm_Signals_TriggerIOWithIntervals

c
int Arm_Signals_TriggerIOWithIntervals(ArmHandle* h, int inPort, const int* intervals, size_t intervalCount, const int* outPorts, size_t outPortCount, int pulseDuration);
ItemDescription
DescriptionTriggers IO output pulses at time intervals
Request Parametersh : ArmHandle* , C99 session handle, usually from Arm_Create() ; business APIs require connection first
inPort : int , input port number
intervals : const int* , trigger interval array
intervalCount : size_t , number of trigger intervals
outPorts : const int* , output port number array
outPortCount : size_t , number of output ports
pulseDuration : int , output pulse duration
Return ValueSTATUS_CODE integer value; 0 means success, other values should be handled as status codes

Parameters and Rules

Supported Scope

InterfaceSupported Scope
Arm_Signals_ReadDI , DO , UI , UO , RI , RO , GI , GO , TAI , TDI , TDO , AI , AO
Arm_Signals_WriteIntDO , RO , GO , TDO
Arm_Signals_WriteFloatAO
Arm_Signals_MultiReadDO
Arm_Signals_MultiWriteDO

Signal Type Values

C ConstantValueDescription
ARM_SIGNAL_DI1Digital input
ARM_SIGNAL_DO2Digital output
ARM_SIGNAL_UI3Dedicated input
ARM_SIGNAL_UO4Dedicated output
ARM_SIGNAL_RI5Remote input
ARM_SIGNAL_RO6Remote output
ARM_SIGNAL_GI7Group input
ARM_SIGNAL_GO8Group output
ARM_SIGNAL_TAI9Wrist analog input
ARM_SIGNAL_TDI10Wrist digital input
ARM_SIGNAL_TDO11Wrist digital output
ARM_SIGNAL_AI12Analog input
ARM_SIGNAL_AO13Analog output
ItemRule
signalTypeUse a signal type value such as ARM_SIGNAL_DI , ARM_SIGNAL_DO , ARM_SIGNAL_AI , or ARM_SIGNAL_AO
indexController-side port number, passed according to the controller's actual numbering
WriteIntUsed for integer outputs. Unsupported signal types return UNSUPPORTED_SIGNAL_TYPE
WriteFloatUsed for analog outputs. Unsupported signal types return UNSUPPORTED_SIGNAL_TYPE
MultiReadReturns batch values through outValues + maxCount + outCount ; currently supports only DO
MultiWriteioList is a flat array passed as [port, value, port, value]
TriggerIOWithIntervalsTriggers output port pulses according to the input port and time intervals. pulseDuration is in milliseconds

Failure semantics:

ScenarioReturn
Signal type is outside the supported scopeUNSUPPORTED_SIGNAL_TYPE
portList is empty or portCount is 0INVALID_PARAMETER
Output capacity is insufficient in Arm_Signals_MultiRead()BUFFER_TOO_SMALL
ioList is empty, has an odd number of elements, or ioCount is 0INVALID_PARAMETER
intervals / outPorts is empty or its count is 0INVALID_PARAMETER

Arm_Signals_TriggerIOWithIntervals() triggers output pulses on outPorts according to the time intervals in intervals ; pulseDuration is the duration of each output pulse.

Minimal Call Example

c
#include <stdio.h>     // printf for printing DI value
#include "c_arm_api.h" // C99 SDK umbrella header

int main(void)
{
    ArmHandle* h = Arm_Create();
    double value = 0.0;
    if (h == NULL) {
        return 1;
    }

    if (Arm_Connect(h, "10.27.1.2", "10.27.1.102") != 0) {
        Arm_Destroy(h);
        return 1;
    }

    int ret = Arm_Signals_Read(h, ARM_SIGNAL_DI, 0, &value);
    printf("di0=%f\n", value);
    Arm_Disconnect(h);
    Arm_Destroy(h);
    return ret == 0 ? 0 : 1;
}

Scenario Examples

Single-Point and Batch Read

c
double diValue = 0.0;
int ports[2] = {0, 1};
int values[2] = {0};
size_t outCount = 0U;
int readRet = Arm_Signals_Read(h, ARM_SIGNAL_DI, 0, &diValue);
int multiRet = Arm_Signals_MultiRead(h, ARM_SIGNAL_DO, ports, 2, values, 2, &outCount);
(void)readRet;
(void)multiRet;

Write and Trigger

c
int ioList[4] = {1, 1, 2, 0};
int intervals[2] = {100, 200};
int outPorts[2] = {1, 2};
/* int writeIntRet = Arm_Signals_WriteInt(h, ARM_SIGNAL_DO, 1, 1); */
/* int writeFloatRet = Arm_Signals_WriteFloat(h, ARM_SIGNAL_AO, 1, 1.5); */
/* int multiWriteRet = Arm_Signals_MultiWrite(h, ARM_SIGNAL_DO, ioList, 4); */
/* int triggerRet = Arm_Signals_TriggerIOWithIntervals(h, 0, intervals, 2, outPorts, 2, 50); */

Example code:

c99/signals_basic/src/main.cpp
cpp
#include <stdio.h>

extern "C" {
#include "c_arm_api.h"
}

int main(void)
{
    // [ZH] 本示例直接在源码中写死连接地址,不解析命令行参数。
    // [EN] This example hard-codes the connection addresses in the source code and does not parse command-line arguments.
    // [ZH] 创建并连接 SDK 句柄。
    // [EN] Create the SDK handle and connect to the robot.
    ArmHandle* handle = Arm_Create();
    if (handle == NULL) {
        printf("[c99_signals] 创建句柄失败 / Failed to create the handle\n");
        return 1;
    }
    int ret = Arm_Connect(handle, "10.27.1.2", "10.27.1.102");
    if (ret != 0) {
        printf("[c99_signals] 连接失败 / Connect failed, 状态码 / Status code: %d\n", ret);
        Arm_Destroy(handle);
        return 1;
    }
    printf("[c99_signals] 机器人连接成功 / Robot connected successfully\n");

    // [ZH] 读取单路信号与批量信号。
    // [EN] Read a single signal and a batch of signals.
    double diValue = 0.0;
    int ports[2] = {0, 1};
    int values[2] = {0, 0};
    size_t outCount = 0U;
    ret = Arm_Signals_Read(handle, ARM_SIGNAL_DI, 0, &diValue);
    printf("[c99_signals] Read 状态码 / Read status code: %d, DI[0]=%.6f\n", ret, diValue);
    ret = Arm_Signals_MultiRead(handle, ARM_SIGNAL_DI, ports, 2U, values, 2U, &outCount);
    printf("[c99_signals] MultiRead 状态码 / MultiRead status code: %d, 数量 / Count: %zu, 值 / Values: [%d, %d]\n",
        ret,
        outCount,
        values[0],
        values[1]);

    // [ZH] 顺序执行全部写接口。
    // [EN] Execute all write APIs in sequence.
    ret = Arm_Signals_WriteInt(handle, ARM_SIGNAL_DO, 1, 1);
    printf("[c99_signals] WriteInt 状态码 / WriteInt status code: %d\n", ret);
    ret = Arm_Signals_WriteFloat(handle, ARM_SIGNAL_AO, 1, 1.5);
    printf("[c99_signals] WriteFloat 状态码 / WriteFloat status code: %d\n", ret);
    int ioList[4] = {4, 1, 6, 0};
    ret = Arm_Signals_MultiWrite(handle, ARM_SIGNAL_DO, ioList, 4U);
    printf("[c99_signals] MultiWrite 状态码 / MultiWrite status code: %d\n", ret);
    int intervals[2] = {100, 200};
    int outPorts[2] = {4, 5};
    ret = Arm_Signals_TriggerIOWithIntervals(handle, 1, intervals, 2U, outPorts, 2U, 60);
    printf("[c99_signals] TriggerIOWithIntervals 状态码 / TriggerIOWithIntervals status code: %d\n", ret);

    // [ZH] 断开连接并销毁句柄。
    // [EN] Disconnect and destroy the handle.
    Arm_Disconnect(handle);
    Arm_Destroy(handle);
    printf("[c99_signals] 示例结束 / Example finished\n");
    return 0;
}