etherlab/plc_etherlab.c
author Laurent Bessard
Wed, 19 Sep 2012 11:03:25 +0200
changeset 2077 14dfb786c53e
parent 2075 21eb91dc7071
child 2076 22e9993348f6
permissions -rw-r--r--
Fix bug when modifying slave position
2022
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
     1
/*
2032
766078d83e22 Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents: 2028
diff changeset
     2
 * Etherlab execution code
2022
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
     3
 *
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
     4
 * */
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
     5
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
     6
#include <rtdm/rtdm.h>
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
     7
#include <native/task.h>
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
     8
#include <native/timer.h>
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
     9
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    10
#include "ecrt.h"
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    11
#include "ec_rtdm.h"
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    12
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    13
#ifdef _WINDOWS_H
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    14
  #include "iec_types.h"
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    15
#else
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    16
  #include "iec_std_lib.h"
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    17
#endif
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    18
2036
7c31fab22c74 Adding support for setting TargetPosition only if PositionSetPoint value from MCL is valid
laurent
parents: 2032
diff changeset
    19
extern unsigned long long common_ticktime__;
7c31fab22c74 Adding support for setting TargetPosition only if PositionSetPoint value from MCL is valid
laurent
parents: 2032
diff changeset
    20
2022
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    21
// declaration of interface variables
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    22
%(located_variables_declaration)s
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    23
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    24
// Optional features
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    25
#define CONFIGURE_PDOS  %(configure_pdos)d
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    26
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    27
// process data
2032
766078d83e22 Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents: 2028
diff changeset
    28
uint8_t *domain1_pd = NULL;
2022
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    29
%(used_pdo_entry_offset_variables_declaration)s
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    30
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    31
const static ec_pdo_entry_reg_t domain1_regs[] = {
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    32
%(used_pdo_entry_configuration)s
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    33
    {}
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    34
};
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    35
/*****************************************************************************/
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    36
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    37
#if CONFIGURE_PDOS
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    38
%(pdos_configuration_declaration)s
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    39
#endif
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    40
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    41
int rt_fd = -1;
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    42
CstructMstrAttach MstrAttach;
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    43
char rt_dev_file[64];
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    44
long long wait_period_ns = 100000LL;
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    45
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    46
// EtherCAT
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    47
static ec_master_t *master = NULL;
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    48
static ec_domain_t *domain1 = NULL;
2075
21eb91dc7071 Different etherlab sequencing within retrieve and publish. Now, timer is polled after PLC exec until frame have to be sent. This slightly reduce jitter, compared to previous sequencing
Edouard Tisserant
parents: 2039
diff changeset
    49
static int first_sent=0;
2022
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    50
%(slaves_declaration)s
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    51
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    52
/* Beremiz plugin functions */
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    53
int __init_%(location)s(int argc,char **argv)
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    54
{
2032
766078d83e22 Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents: 2028
diff changeset
    55
    uint32_t abort_code;
2039
3a218f6bd805 Adding support for uploading default value for unused entries in output pdos from slaves before starting master
laurent
parents: 2036
diff changeset
    56
    size_t result_size;
3a218f6bd805 Adding support for uploading default value for unused entries in output pdos from slaves before starting master
laurent
parents: 2036
diff changeset
    57
    int i, rtstatus;
2032
766078d83e22 Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents: 2028
diff changeset
    58
    
2022
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    59
	MstrAttach.masterindex = %(master_number)d;
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    60
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    61
	master = ecrt_request_master(MstrAttach.masterindex);
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    62
	if (!master) return -1;
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    63
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    64
	domain1 = ecrt_master_create_domain(master);
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    65
	if (!domain1) return -1;
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    66
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    67
#if CONFIGURE_PDOS
2032
766078d83e22 Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents: 2028
diff changeset
    68
    fprintf(stdout, "Configure PDOs...\n");
2022
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    69
	%(slaves_configuration)s
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    70
#endif
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    71
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    72
    if (ecrt_domain_reg_pdo_entry_list(domain1, domain1_regs)) {
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    73
        fprintf(stderr, "PDO entry registration failed!\n");
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    74
        return -1;
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    75
    }
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    76
2036
7c31fab22c74 Adding support for setting TargetPosition only if PositionSetPoint value from MCL is valid
laurent
parents: 2032
diff changeset
    77
	ecrt_master_set_send_interval(master, common_ticktime__);
7c31fab22c74 Adding support for setting TargetPosition only if PositionSetPoint value from MCL is valid
laurent
parents: 2032
diff changeset
    78
2032
766078d83e22 Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents: 2028
diff changeset
    79
%(slaves_initialization)s
766078d83e22 Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents: 2028
diff changeset
    80
2039
3a218f6bd805 Adding support for uploading default value for unused entries in output pdos from slaves before starting master
laurent
parents: 2036
diff changeset
    81
%(slaves_output_pdos_default_values_extraction)s
3a218f6bd805 Adding support for uploading default value for unused entries in output pdos from slaves before starting master
laurent
parents: 2036
diff changeset
    82
2022
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    83
    sprintf(&rt_dev_file[0],"%%s%%u",EC_RTDM_DEV_FILE_NAME,0);
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    84
    rt_fd = rt_dev_open( &rt_dev_file[0], 0);
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    85
    if (rt_fd < 0) {
2032
766078d83e22 Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents: 2028
diff changeset
    86
        fprintf(stderr, "Can't open %%s\n", &rt_dev_file[0]);
2022
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    87
        return -1;
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    88
    }
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    89
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    90
    // attach the master over rtdm driver
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    91
    MstrAttach.domainindex = ecrt_domain_index(domain1);
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    92
    rtstatus = ecrt_rtdm_master_attach(rt_fd, &MstrAttach);
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    93
    if (rtstatus < 0) {
2032
766078d83e22 Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents: 2028
diff changeset
    94
        fprintf(stderr, "Cannot attach to master over rtdm\n");
2022
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    95
        return -1;
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    96
    }
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    97
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    98
    if (ecrt_master_activate(master))
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    99
        return -1;
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
   100
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
   101
    if (!(domain1_pd = ecrt_domain_data(domain1))) {
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
   102
        fprintf(stderr, "domain1_pd:  0x%%.6lx\n", (unsigned long)domain1_pd);
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
   103
        return -1;
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
   104
    }
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
   105
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
   106
    fprintf(stdout, "Master %(master_number)d activated...\n");
2075
21eb91dc7071 Different etherlab sequencing within retrieve and publish. Now, timer is polled after PLC exec until frame have to be sent. This slightly reduce jitter, compared to previous sequencing
Edouard Tisserant
parents: 2039
diff changeset
   107
    
21eb91dc7071 Different etherlab sequencing within retrieve and publish. Now, timer is polled after PLC exec until frame have to be sent. This slightly reduce jitter, compared to previous sequencing
Edouard Tisserant
parents: 2039
diff changeset
   108
    first_sent = 0;
21eb91dc7071 Different etherlab sequencing within retrieve and publish. Now, timer is polled after PLC exec until frame have to be sent. This slightly reduce jitter, compared to previous sequencing
Edouard Tisserant
parents: 2039
diff changeset
   109
2022
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
   110
    return 0;
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
   111
}
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
   112
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
   113
void __cleanup_%(location)s(void)
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
   114
{
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
   115
	if (rt_fd >= 0) {
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
   116
		rt_dev_close(rt_fd);
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
   117
	}
2024
08d67a0af2c1 Master release code added
Donggu Kang <dgkang@higenmotor.com>
parents: 2022
diff changeset
   118
	//release master
2025
87f428326f9b Master relase code added
Donggu Kang <dgkang@higenmotor.com>
parents: 2022
diff changeset
   119
	ecrt_release_master(master);
2075
21eb91dc7071 Different etherlab sequencing within retrieve and publish. Now, timer is polled after PLC exec until frame have to be sent. This slightly reduce jitter, compared to previous sequencing
Edouard Tisserant
parents: 2039
diff changeset
   120
    first_sent = 0;
2022
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
   121
}
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
   122
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
   123
void __retrieve_%(location)s(void)
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
   124
{
2075
21eb91dc7071 Different etherlab sequencing within retrieve and publish. Now, timer is polled after PLC exec until frame have to be sent. This slightly reduce jitter, compared to previous sequencing
Edouard Tisserant
parents: 2039
diff changeset
   125
//    // send process data
21eb91dc7071 Different etherlab sequencing within retrieve and publish. Now, timer is polled after PLC exec until frame have to be sent. This slightly reduce jitter, compared to previous sequencing
Edouard Tisserant
parents: 2039
diff changeset
   126
//    ecrt_rtdm_domain_queque(rt_fd);
21eb91dc7071 Different etherlab sequencing within retrieve and publish. Now, timer is polled after PLC exec until frame have to be sent. This slightly reduce jitter, compared to previous sequencing
Edouard Tisserant
parents: 2039
diff changeset
   127
//    ecrt_rtdm_master_send(rt_fd);
21eb91dc7071 Different etherlab sequencing within retrieve and publish. Now, timer is polled after PLC exec until frame have to be sent. This slightly reduce jitter, compared to previous sequencing
Edouard Tisserant
parents: 2039
diff changeset
   128
//
21eb91dc7071 Different etherlab sequencing within retrieve and publish. Now, timer is polled after PLC exec until frame have to be sent. This slightly reduce jitter, compared to previous sequencing
Edouard Tisserant
parents: 2039
diff changeset
   129
//    rt_task_sleep(rt_timer_ns2tsc(wait_period_ns));
2036
7c31fab22c74 Adding support for setting TargetPosition only if PositionSetPoint value from MCL is valid
laurent
parents: 2032
diff changeset
   130
2022
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
   131
    // receive ethercat
2075
21eb91dc7071 Different etherlab sequencing within retrieve and publish. Now, timer is polled after PLC exec until frame have to be sent. This slightly reduce jitter, compared to previous sequencing
Edouard Tisserant
parents: 2039
diff changeset
   132
    if(first_sent){
21eb91dc7071 Different etherlab sequencing within retrieve and publish. Now, timer is polled after PLC exec until frame have to be sent. This slightly reduce jitter, compared to previous sequencing
Edouard Tisserant
parents: 2039
diff changeset
   133
        ecrt_rtdm_master_recieve(rt_fd);
21eb91dc7071 Different etherlab sequencing within retrieve and publish. Now, timer is polled after PLC exec until frame have to be sent. This slightly reduce jitter, compared to previous sequencing
Edouard Tisserant
parents: 2039
diff changeset
   134
        ecrt_rtdm_domain_process(rt_fd);
21eb91dc7071 Different etherlab sequencing within retrieve and publish. Now, timer is polled after PLC exec until frame have to be sent. This slightly reduce jitter, compared to previous sequencing
Edouard Tisserant
parents: 2039
diff changeset
   135
%(retrieve_variables)s
21eb91dc7071 Different etherlab sequencing within retrieve and publish. Now, timer is polled after PLC exec until frame have to be sent. This slightly reduce jitter, compared to previous sequencing
Edouard Tisserant
parents: 2039
diff changeset
   136
    }
2022
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
   137
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
   138
}
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
   139
2075
21eb91dc7071 Different etherlab sequencing within retrieve and publish. Now, timer is polled after PLC exec until frame have to be sent. This slightly reduce jitter, compared to previous sequencing
Edouard Tisserant
parents: 2039
diff changeset
   140
static RTIME _last_occur=0;
21eb91dc7071 Different etherlab sequencing within retrieve and publish. Now, timer is polled after PLC exec until frame have to be sent. This slightly reduce jitter, compared to previous sequencing
Edouard Tisserant
parents: 2039
diff changeset
   141
RTIME _current_lag=0;
21eb91dc7071 Different etherlab sequencing within retrieve and publish. Now, timer is polled after PLC exec until frame have to be sent. This slightly reduce jitter, compared to previous sequencing
Edouard Tisserant
parents: 2039
diff changeset
   142
2022
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
   143
void __publish_%(location)s(void)
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
   144
{
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
   145
%(publish_variables)s
2075
21eb91dc7071 Different etherlab sequencing within retrieve and publish. Now, timer is polled after PLC exec until frame have to be sent. This slightly reduce jitter, compared to previous sequencing
Edouard Tisserant
parents: 2039
diff changeset
   146
    ecrt_rtdm_domain_queque(rt_fd);
21eb91dc7071 Different etherlab sequencing within retrieve and publish. Now, timer is polled after PLC exec until frame have to be sent. This slightly reduce jitter, compared to previous sequencing
Edouard Tisserant
parents: 2039
diff changeset
   147
    {
21eb91dc7071 Different etherlab sequencing within retrieve and publish. Now, timer is polled after PLC exec until frame have to be sent. This slightly reduce jitter, compared to previous sequencing
Edouard Tisserant
parents: 2039
diff changeset
   148
        RTIME _current_time = rt_timer_read();
21eb91dc7071 Different etherlab sequencing within retrieve and publish. Now, timer is polled after PLC exec until frame have to be sent. This slightly reduce jitter, compared to previous sequencing
Edouard Tisserant
parents: 2039
diff changeset
   149
        RTIME deadline = _last_occur ?
21eb91dc7071 Different etherlab sequencing within retrieve and publish. Now, timer is polled after PLC exec until frame have to be sent. This slightly reduce jitter, compared to previous sequencing
Edouard Tisserant
parents: 2039
diff changeset
   150
            _last_occur + common_ticktime__:
21eb91dc7071 Different etherlab sequencing within retrieve and publish. Now, timer is polled after PLC exec until frame have to be sent. This slightly reduce jitter, compared to previous sequencing
Edouard Tisserant
parents: 2039
diff changeset
   151
            _current_time; 
21eb91dc7071 Different etherlab sequencing within retrieve and publish. Now, timer is polled after PLC exec until frame have to be sent. This slightly reduce jitter, compared to previous sequencing
Edouard Tisserant
parents: 2039
diff changeset
   152
        _last_occur = _current_time;
21eb91dc7071 Different etherlab sequencing within retrieve and publish. Now, timer is polled after PLC exec until frame have to be sent. This slightly reduce jitter, compared to previous sequencing
Edouard Tisserant
parents: 2039
diff changeset
   153
        _current_lag = deadline - _current_time;
21eb91dc7071 Different etherlab sequencing within retrieve and publish. Now, timer is polled after PLC exec until frame have to be sent. This slightly reduce jitter, compared to previous sequencing
Edouard Tisserant
parents: 2039
diff changeset
   154
        while(_current_time < deadline) {
21eb91dc7071 Different etherlab sequencing within retrieve and publish. Now, timer is polled after PLC exec until frame have to be sent. This slightly reduce jitter, compared to previous sequencing
Edouard Tisserant
parents: 2039
diff changeset
   155
            _last_occur = _current_time;
21eb91dc7071 Different etherlab sequencing within retrieve and publish. Now, timer is polled after PLC exec until frame have to be sent. This slightly reduce jitter, compared to previous sequencing
Edouard Tisserant
parents: 2039
diff changeset
   156
            _current_time = rt_timer_read();
21eb91dc7071 Different etherlab sequencing within retrieve and publish. Now, timer is polled after PLC exec until frame have to be sent. This slightly reduce jitter, compared to previous sequencing
Edouard Tisserant
parents: 2039
diff changeset
   157
        }
21eb91dc7071 Different etherlab sequencing within retrieve and publish. Now, timer is polled after PLC exec until frame have to be sent. This slightly reduce jitter, compared to previous sequencing
Edouard Tisserant
parents: 2039
diff changeset
   158
    }
21eb91dc7071 Different etherlab sequencing within retrieve and publish. Now, timer is polled after PLC exec until frame have to be sent. This slightly reduce jitter, compared to previous sequencing
Edouard Tisserant
parents: 2039
diff changeset
   159
    ecrt_rtdm_master_send(rt_fd);
21eb91dc7071 Different etherlab sequencing within retrieve and publish. Now, timer is polled after PLC exec until frame have to be sent. This slightly reduce jitter, compared to previous sequencing
Edouard Tisserant
parents: 2039
diff changeset
   160
    first_sent = 1;
2022
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
   161
}