libsmoco
Low-level interface library for Segment Motion Controller system
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
API Types
Collaboration diagram for API Types:

Data Structures

struct  smoco_can_connect_t
 Structure for specifying the details for connecting to the smocand daemon's CAN communication ports. More...
 
struct  SMOCO_Command
 Detailed information about a SMOCO command. More...
 
struct  SMOCO_Response
 Structure containing the details of a message received from the SMOCO hardware. More...
 
union  SMOCO_ParameterValue
 A union for convenient access to the component bytes of a 32-bit SMOCO parameter. More...
 
union  SMOCO_Parameters
 A union type for specifying parameters to SMOCO commands. More...
 
struct  SMOCO_CmdSpec
 Fully specified command to SMOCO, comprising the command, node and actuator identifiers. More...
 

Macros

#define SMOCO_ADDR_VMAX_I   0x1028
 
#define SMOCO_ADDR_VMAX_J   0x2028
 
#define SMOCO_ADDR_VMAX_K   0x3028
 
#define ALL_SMOCO_NODES   -2
 SMOCO_NodeID value representing all accessible SMOCO nodes. More...
 
#define NODE_NONE   -1
 SMOCO_NodeID value representing an initialization value or a result that does not refer to a specific node. Not for use with commands. More...
 
#define SMOCO_NODES   256
 
#define SMOCO_ACTUATORS_PER_NODE   3
 

Typedefs

typedef void * SMOCO_CTX
 "SMOCO Context" opaque resource handle. More...
 
typedef int SMOCO_NodeID
 Identifier of a SMOCO Node (motor controller), controlling up to three actuators (motors). More...
 
typedef struct smoco_can_connect_t smoco_can_connect_t
 Structure for specifying the details for connecting to the smocand daemon's CAN communication ports. More...
 
typedef struct SMOCO_Response SMOCO_Response
 Structure containing the details of a message received from the SMOCO hardware. More...
 
typedef void(* SMOCO_HANDLER )(SMOCO_CTX ctx, const SMOCO_Response *p_resp)
 General handler for received messages from SMOCO hardware. More...
 
typedef union SMOCO_ParameterValue SMOCO_ParameterValue
 A union for convenient access to the component bytes of a 32-bit SMOCO parameter. More...
 
typedef union SMOCO_Parameters SMOCO_Parameters
 A union type for specifying parameters to SMOCO commands. More...
 
typedef struct SMOCO_CmdSpec SMOCO_CmdSpec
 Fully specified command to SMOCO, comprising the command, node and actuator identifiers. More...
 

Enumerations

enum  SMOCO_ActuatorID {
  ACT_NONE = -1, ACT_ALL = -2, ACT_I = 0, ACT_0 = 0,
  ACT_J = 1, ACT_1 = 1, ACT_K = 2, ACT_2 = 2
}
 Actuator identifiers. More...
 
enum  SMOCO_CommandID {
  ESTOP = 0, SETABS = 1, SETRELUP = 2, SETRELDN = 3,
  ACTMOVE = 13, ACTINIT = 8, ACTUNINIT = 9, GETACTSTAT = 7,
  GETCTLTEMP = 21, SETVMXMOVE = 4, SETVMXHOME = 5, ACTMOVELL = 15,
  ACTMOVEUL = 16, ACTHOME = 14, RESETNODE = 17, POSOVW = 6,
  POWERON = 10, POWEROFF = 11, LSACTREGS = 12, DIRECTCMD = 18,
  WRITEDATA = 19, READDATA = 20, READACTSW = 22, REQERR = 23,
  READDATAPG = 24, MCOVERTEMP = 25, CMD_NONE = -1
}
 API command identifiers. More...
 
enum  SMOCO_ResponseID {
  SMOCO_RSP_OK = 0, SMOCO_RSP_STARTED = 0x1, SMOCO_RSP_NOTMOVING = 0x4, SMOCO_RSP_LLIMSTART = 0x6,
  SMOCO_RSP_ULIMSTART = 0x7, SMOCO_RSP_EMERGENCY = 0x8, SMOCO_RSP_UNEXP_LIM_FL = 0x9, SMOCO_RSP_BOTHLIM = 0xA,
  SMOCO_RSP_LLIMERR_INIT = 0xB, SMOCO_RSP_LLIMERR_FL = 0xC, SMOCO_RSP_ULIMERR_FL = 0xD, SMOCO_RSP_NOLIM = 0xE,
  SMOCO_RSP_ACTDISAB = 0x1D, SMOCO_RSP_ACTMOVING = 0x1E, SMOCO_RSP_RANGE = 0x1F, SMOCO_RSP_LLIM = 0x20,
  SMOCO_RSP_ULIM = 0x21, SMOCO_RSP_NONE = 0xFF, SMOCO_RSP_TIMEOUT = 0xFD, SMOCO_RSP_NOSTART = 0xFC,
  SMOCO_RSP_MULTIPLE = 0xFB, SMOCO_RSP_ERR_UNKNOWN = 0xFE, SMOCO_RSP_ABORT = 0xFA
}
 Response codes from SMOCO hardware. More...
 
enum  SMOCO_UIlevel { SMOCO_UI_PUBLIC = 0, SMOCO_UI_ADMIN = 1, SMOCO_UI_FULL = 2 }
 Operational level at which a command should be made visible to users in a client application's user interface. More...
 
enum  SMOCO_Status_Flags {
  STF_MSK_MV = 7, STF_VAL_STANDING = 0, STF_VAL_HOMING = 1, STF_VAL_MOVING = 3,
  STF_VAL_LLMOVE = 5, STF_VAL_ULMOVE = 7, STF_MSK_ESTOP_ACTIVE = 8, STF_MSK_ESTOP_REQ = 16,
  STF_MSK_POWERON = 64, STF_MSK_ENABLED = 128
}
 Flag values for decoding bit-packed status information from SMOCO. More...
 
enum  SMOCO_STATUS {
  SMOCO_ST_SUCCESS = 0, SMOCO_ST_BADCTX = 1, SMOCO_ST_BADHOST = 2, SMOCO_ST_CONNERR = 3,
  SMOCO_ST_BADCONN = 4, SMOCO_ST_THREADERR = 5, SMOCO_ST_BADRESPONSE = 6, SMOCO_ST_INFORESPONSE = 7,
  SMOCO_ST_BUSY = 8, SMOCO_ST_BADNODE = 9, SMOCO_ST_BADHANDSHAKE = 10, SMOCO_ST_TIMEOUT = 11,
  SMOCO_ST_BADCMDPREP = 12, SMOCO_ST_BADCOMMAND = 13, SMOCO_ST_BADPARAM = 99, SMOCO_ST_EXIT = -1
}
 Status return for public functions. More...
 
enum  SMOCO_TXEventID_t {
  SMOCO_TXEVT_START = 1, SMOCO_TXEVT_RESPONSE = 2, SMOCO_TXEVT_TIMEOUT = 3, SMOCO_TXEVT_EXIT = 4,
  SMOCO_TXEVT_NOSTART = 5, SMOCO_TXEVT_TIMER_TICK = 6, SMOCO_TXEVT_DONE = 7
}
 Types of asynchronous "event" notifications resulting from a command sent to SMOCO. More...
 
enum  Actuator_Limit_Flags { LMF_ULIM = 1, LMF_LLIM = 2 }
 Flags for limit switch status of a single actuator. More...
 

Detailed Description

Macro Definition Documentation

#define ALL_SMOCO_NODES   -2

SMOCO_NodeID value representing all accessible SMOCO nodes.

#define NODE_NONE   -1

SMOCO_NodeID value representing an initialization value or a result that does not refer to a specific node. Not for use with commands.

#define SMOCO_ACTUATORS_PER_NODE   3

Maximum number of actuators supported by a SMOCO node.

#define SMOCO_ADDR_VMAX_I   0x1028

Address of velocity setting value for actuator I in SMOCO memory. Used for sending a READDATA command to fetch this value from SMOCO controller.

#define SMOCO_ADDR_VMAX_J   0x2028

Address of velocity setting value for actuator J in SMOCO memory. Used for sending a READDATA command to fetch this value from SMOCO controller.

#define SMOCO_ADDR_VMAX_K   0x3028

Address of velocity setting value for actuator K in SMOCO memory. Used for sending a READDATA command to fetch this value from SMOCO controller.

#define SMOCO_NODES   256

Maximum number of SMOCO nodes supported by the hardware.

Typedef Documentation

Structure for specifying the details for connecting to the smocand daemon's CAN communication ports.

Use with smoco_set_conn_spec(). The smocand daemon has 3 TCP ports provided for communication and control: Transmit, Receive and Control. These are numbered sequentially starting from the base_port value in this structure. See SMOCAND_CANCOMM_PORT_DFLT_BASE in smocand_protocol.h

typedef struct SMOCO_CmdSpec SMOCO_CmdSpec

Fully specified command to SMOCO, comprising the command, node and actuator identifiers.

typedef void* SMOCO_CTX

"SMOCO Context" opaque resource handle.

Allocated by smoco_init(), and used for all other public interface functions.

typedef void(* SMOCO_HANDLER)(SMOCO_CTX ctx, const SMOCO_Response *p_resp)

General handler for received messages from SMOCO hardware.

A callback of this type is supplied to smoco_register_handler_universal() or smoco_register_handler_commandresponse(). The registered handler is then called for every corresponding message received.

typedef int SMOCO_NodeID

Identifier of a SMOCO Node (motor controller), controlling up to three actuators (motors).

ALL_SMOCO_NODES is used for commands that are to be broadcast to all accessible nodes in a SMOCO system. NODE_NONE is reserved for API communications that do not refer to a particular node, or as an initialization value.

A union type for specifying parameters to SMOCO commands.

SMOCO commands generally accept two 32-bit values for parameters, which can be supplies in the values[2] array.

A union for convenient access to the component bytes of a 32-bit SMOCO parameter.

Structure containing the details of a message received from the SMOCO hardware.

Provided to handlers and transaction event callbacks.

Enumeration Type Documentation

Flags for limit switch status of a single actuator.

Enumerator
LMF_ULIM 
LMF_LLIM 

Actuator identifiers.

Enumerator
ACT_NONE 

Placeholder value for commands that are not specific to a particular actuator, eg. RESETNODE, GETCTLTEMP, etc.

ACT_ALL 

Indicates command should be broadcast to all actuators on given node(s).

ACT_I 

Actuator 'I' (first actuator on node).

ACT_0 

Actuator 'I' (first actuator on node).

ACT_J 

Actuator 'J' (second actuator on node).

ACT_1 

Actuator 'J' (second actuator on node).

ACT_K 

Actuator 'K' (third actuator on node).

ACT_2 

Actuator 'K' (third actuator on node).

API command identifiers.

The command identifiers in this enumeration are for libsmoco API use only. They are distinct from the numeric IDs used in the SMOCO hardware communication protocol. smoco_command_find_by_hwid() can be used to obtain a SMOCO_CommandID from a SMOCO hardware identifier.

Enumerator
ESTOP 

Emergency stop

SETABS 

Set absolute target position

SETRELUP 

Set positive relative movement

SETRELDN 

Set negative relative movement

ACTMOVE 

Move to previously set target

ACTINIT 

Set status to "initialized"

ACTUNINIT 

Set status to "uninitialized"

GETACTSTAT 

Get axis status

GETCTLTEMP 

Get controller temperature

SETVMXMOVE 

Set maximum speed for normal motion

SETVMXHOME 

Set maximum speed for homing motion

ACTMOVELL 

Move to lower limit

ACTMOVEUL 

Move to upper limit

ACTHOME 

Perform a homing movement on actuator

RESETNODE 

Reset motor controller

POSOVW 

Overwrite current position with value

POWERON 

Set motor power on

POWEROFF 

Set motor power off

LSACTREGS 

List controller axis registers

DIRECTCMD 

Send direct command to motor controller

WRITEDATA 

Write 32-bit data to controller EEPROM

READDATA 

Read 32-bit data from controller EEPROM

READACTSW 

Read all actuator status switches

REQERR 
READDATAPG 

Read data page from controller EEPROM

MCOVERTEMP 

Motor controller over-temperature alert. This identifier isn't actually a "command" (it is not sent to SMOCO) but it is used like a command ID in the SMOCO firmware, so we may receive spontaneous "responses" with this value

CMD_NONE 

Initialization value, since 0 is in use for ESTOP command. Note that there is no corresponding detail entry in the SMOCO_Commands[] table!

Response codes from SMOCO hardware.

Enumerator
SMOCO_RSP_OK 

Success, no error.

SMOCO_RSP_STARTED 

Successful start of movement, motor is in motion.

SMOCO_RSP_NOTMOVING 

Non-significant error, no motion at request to stop.

SMOCO_RSP_LLIMSTART 

Motor at lower limit at request for downward motion.

SMOCO_RSP_ULIMSTART 

Motor at upper limit at request for upward motion.

SMOCO_RSP_EMERGENCY 

Motion ended at request for emergency stop.

SMOCO_RSP_UNEXP_LIM_FL 

Limit active at command for limit search

SMOCO_RSP_BOTHLIM 

Hardware error: both limits active simultaneously

SMOCO_RSP_LLIMERR_INIT 

Lower limit remains active during homing operation; possible hardware fault

SMOCO_RSP_LLIMERR_FL 

Lower limit remains active during lower limit search; possible hardware fault

SMOCO_RSP_ULIMERR_FL 

Upper limit remains active during upper limit search; possible hardware fault

SMOCO_RSP_NOLIM 

Limit not found

SMOCO_RSP_ACTDISAB 

Actuator is not enabled

SMOCO_RSP_ACTMOVING 

Motor is moving; command is ignored

SMOCO_RSP_RANGE 

Command for movement out of allowed range, ignored.

SMOCO_RSP_LLIM 

Reached lower limit; motion stopped.

SMOCO_RSP_ULIM 

Reached upper limit; motion stopped.

SMOCO_RSP_NONE 

Initialization value for response ID fields (0x0 is taken, above)

SMOCO_RSP_TIMEOUT 

Indicator that response was not received from SMOCO

SMOCO_RSP_NOSTART 

Indication of missed prerequisite or preemptive error, SMOCO command not sent

SMOCO_RSP_MULTIPLE 

Multiple responses, potential result of a command send to multiple targets if responses do not match

SMOCO_RSP_ERR_UNKNOWN 

Unknown error

SMOCO_RSP_ABORT 

Operation aborted (eg. shutdown)

Status return for public functions.

Enumerator
SMOCO_ST_SUCCESS 

Successful operation

SMOCO_ST_BADCTX 

Bad context (resource handle) supplied

SMOCO_ST_BADHOST 

Bad hostname, or host not found

SMOCO_ST_CONNERR 

Error during attempt to connect

SMOCO_ST_BADCONN 

Socket invalid or not connected

SMOCO_ST_THREADERR 

Error creating thread

SMOCO_ST_BADRESPONSE 

Invalid response data, corrupt response

SMOCO_ST_INFORESPONSE 

Response data contains informational message from CAN interface. Not relevant to system operation

SMOCO_ST_BUSY 

Operation attemped on node(s) and/or actuator(s) already processing a previous operation. Ignored.

SMOCO_ST_BADNODE 

Specified node not configured or connected

SMOCO_ST_BADHANDSHAKE 

Did not receive expected handshake response

SMOCO_ST_TIMEOUT 

Operation timed out

SMOCO_ST_BADCMDPREP 

Error preparing command to send to SMOCO

SMOCO_ST_BADCOMMAND 

Invalid SMOCO command ID

SMOCO_ST_BADPARAM 

General parameter error in API call

SMOCO_ST_EXIT 

Operation aborted due to application exit

Flag values for decoding bit-packed status information from SMOCO.

STF_VAL_* values are to be compared with the status field ANDed with STF_MSK_MV. The other STF_MSK_* masks provide bitwise access to individual bit flags, such as the enabled status of an actuator.

Enumerator
STF_MSK_MV 

Movement status value mask, LS 3 bits

STF_VAL_STANDING 

Movement status value: Actuator is not in motion

STF_VAL_HOMING 

Movement status value: Actuator is performing homing operation

STF_VAL_MOVING 

Movement status value: Actuator is performing normal travel operation

STF_VAL_LLMOVE 

Movement status value: Actuator is performing a lower limit search operation

STF_VAL_ULMOVE 

Movement status value: Actuator is performing an upper limit search operation

STF_MSK_ESTOP_ACTIVE 

Movement status flag mask: Indicates an emergency stop request is in progress; also check movement flags to determine if actuator still in motion

STF_MSK_ESTOP_REQ 

Movement status flag mask: Emergency stop has been requested

STF_MSK_POWERON 

Movement status flag mask: Actuator power forced ON

STF_MSK_ENABLED 

Movement status flag mask: Actuator enabled

Types of asynchronous "event" notifications resulting from a command sent to SMOCO.

Enumerator
SMOCO_TXEVT_START 

Event to indicate command has been sent successfully

SMOCO_TXEVT_RESPONSE 

Normal response from SMOCO received, details in resp structure

SMOCO_TXEVT_TIMEOUT 

Transaction timed out

SMOCO_TXEVT_EXIT 

Forced/abnormal exit

SMOCO_TXEVT_NOSTART 

Operation could not start

SMOCO_TXEVT_TIMER_TICK 

Timer tick event generated at regular intervals during operation

SMOCO_TXEVT_DONE 

Transaction process is complete, signal to caller that no other events will follow.

Operational level at which a command should be made visible to users in a client application's user interface.

Enumerator
SMOCO_UI_PUBLIC 
SMOCO_UI_ADMIN 
SMOCO_UI_FULL