ecx_waitinframe_red
阻塞冗余接收。
在非冗余模式下,该函数跳过secondary stack及冗余相关的函数。
在冗余模式下,该函数等待两个帧(primary、secondary)都到达。
该函数的结果会进入一个决策树,决策树决定下次的路由方式,以便保证下次可以正确接收。
入参1:port结构体
入参2:请求的帧index序号
入参3:绝对超时时间
出参:workcounter
static int ecx_waitinframe_red(ecx_portt *port, int idx, osal_timert *timer)
因为有入参3(绝对超时时间),所以需要有一个osal_timert结构体来描述具体的时间,精确到us。
typedef struct
{
uint32 sec; /*< Seconds elapsed since the Epoch (Jan 1, 1970) */
uint32 usec; /*< Microseconds elapsed since last second boundary */
}ec_timet;
typedef struct osal_timer
{
ec_timet stop_time;
}osal_timert;
先判断是否是冗余模式,如果非冗余模式,则wkc2==0。也就是第2个端口不参与操作。
之后是一个do while结构,只要workcounter依旧是初始值EC_NOFRAME(-1)且没有超时,主站就一直接收从站发过来的帧,注意冗余模式下需要两个端口都收到才有效。
之后先不分析了,因为我想让主站利用非冗余模式进行操作,先把搭建好环境再细改。