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);| Item | Description |
|---|---|
| Description | Reads one IO signal |
| Request Parameters | h : ArmHandle* , C99 session handle, usually from Arm_Create() ; business APIs require connection firstsignalType : int , signal type. See the supported-scope tableindex : int , IO port numberoutValue : double* , output signal value pointer |
| Return Value | STATUS_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);| Item | Description |
|---|---|
| Description | Writes an integer IO signal |
| Request Parameters | h : ArmHandle* , C99 session handle, usually from Arm_Create() ; business APIs require connection firstsignalType : int , signal type. Only the values corresponding to DO , RO , GO , and TDO are supportedindex : int , IO port numbervalue : int , integer IO value to write |
| Return Value | STATUS_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);| Item | Description |
|---|---|
| Description | Writes a floating-point IO signal |
| Request Parameters | h : ArmHandle* , C99 session handle, usually from Arm_Create() ; business APIs require connection firstsignalType : int , signal type. Only the value corresponding to AO is supportedindex : int , IO port numbervalue : double , floating-point IO value to write |
| Return Value | STATUS_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);| Item | Description |
|---|---|
| Description | Batch-reads IO signals |
| Request Parameters | h : ArmHandle* , C99 session handle, usually from Arm_Create() ; business APIs require connection firstsignalType : int , signal type. Only the value corresponding to DO is supportedportList : const int* , port number arrayportCount : size_t , number of port numbersoutValues : int* , batch output array allocated by the callermaxCount : size_t , output array capacity, meaning the maximum number of elements the caller can receiveoutCount : size_t* , output count pointer. On success, receives the actual count |
| Return Value | STATUS_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);| Item | Description |
|---|---|
| Description | Batch-writes IO signals |
| Request Parameters | h : ArmHandle* , C99 session handle, usually from Arm_Create() ; business APIs require connection firstsignalType : int , signal type. Only the value corresponding to DO is supportedioList : const int* , flattened IO write array organized as [port, value, port, value] ioCount : size_t , number of elements in the flattened IO array |
| Return Value | STATUS_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);| Item | Description |
|---|---|
| Description | Triggers IO output pulses at time intervals |
| Request Parameters | h : ArmHandle* , C99 session handle, usually from Arm_Create() ; business APIs require connection firstinPort : int , input port numberintervals : const int* , trigger interval arrayintervalCount : size_t , number of trigger intervalsoutPorts : const int* , output port number arrayoutPortCount : size_t , number of output portspulseDuration : int , output pulse duration |
| Return Value | STATUS_CODE integer value; 0 means success, other values should be handled as status codes |
Parameters and Rules
Supported Scope
| Interface | Supported Scope |
|---|---|
Arm_Signals_Read | DI , DO , UI , UO , RI , RO , GI , GO , TAI , TDI , TDO , AI , AO |
Arm_Signals_WriteInt | DO , RO , GO , TDO |
Arm_Signals_WriteFloat | AO |
Arm_Signals_MultiRead | DO |
Arm_Signals_MultiWrite | DO |
Signal Type Values
| C Constant | Value | Description |
|---|---|---|
ARM_SIGNAL_DI | 1 | Digital input |
ARM_SIGNAL_DO | 2 | Digital output |
ARM_SIGNAL_UI | 3 | Dedicated input |
ARM_SIGNAL_UO | 4 | Dedicated output |
ARM_SIGNAL_RI | 5 | Remote input |
ARM_SIGNAL_RO | 6 | Remote output |
ARM_SIGNAL_GI | 7 | Group input |
ARM_SIGNAL_GO | 8 | Group output |
ARM_SIGNAL_TAI | 9 | Wrist analog input |
ARM_SIGNAL_TDI | 10 | Wrist digital input |
ARM_SIGNAL_TDO | 11 | Wrist digital output |
ARM_SIGNAL_AI | 12 | Analog input |
ARM_SIGNAL_AO | 13 | Analog output |
| Item | Rule |
|---|---|
signalType | Use a signal type value such as ARM_SIGNAL_DI , ARM_SIGNAL_DO , ARM_SIGNAL_AI , or ARM_SIGNAL_AO |
index | Controller-side port number, passed according to the controller's actual numbering |
WriteInt | Used for integer outputs. Unsupported signal types return UNSUPPORTED_SIGNAL_TYPE |
WriteFloat | Used for analog outputs. Unsupported signal types return UNSUPPORTED_SIGNAL_TYPE |
MultiRead | Returns batch values through outValues + maxCount + outCount ; currently supports only DO |
MultiWrite | ioList is a flat array passed as [port, value, port, value] |
TriggerIOWithIntervals | Triggers output port pulses according to the input port and time intervals. pulseDuration is in milliseconds |
Failure semantics:
| Scenario | Return |
|---|---|
| Signal type is outside the supported scope | UNSUPPORTED_SIGNAL_TYPE |
portList is empty or portCount is 0 | INVALID_PARAMETER |
Output capacity is insufficient in Arm_Signals_MultiRead() | BUFFER_TOO_SMALL |
ioList is empty, has an odd number of elements, or ioCount is 0 | INVALID_PARAMETER |
intervals / outPorts is empty or its count is 0 | INVALID_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:
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;
}