etherlab/etherlab.py
changeset 2107 6f9aa410a997
parent 2105 a62c0de6986f
child 2109 86832a0e113d
equal deleted inserted replaced
2106:4ec3b833f2d5 2107:6f9aa410a997
  1186 };
  1186 };
  1187 """
  1187 """
  1188 
  1188 
  1189 SLAVE_CONFIGURATION_TEMPLATE = """
  1189 SLAVE_CONFIGURATION_TEMPLATE = """
  1190     if (!(slave%(slave)d = ecrt_master_slave_config(master, %(alias)d, %(position)d, 0x%(vendor).8x, 0x%(product_code).8x))) {
  1190     if (!(slave%(slave)d = ecrt_master_slave_config(master, %(alias)d, %(position)d, 0x%(vendor).8x, 0x%(product_code).8x))) {
  1191         fprintf(stderr, "Failed to get slave %(device_type)s configuration at alias %(alias)d and position %(position)d.\\n");
  1191         SLOGF(LOG_CRITICAL, "Failed to get slave %(device_type)s configuration at alias %(alias)d and position %(position)d.\\n");
  1192         return -1;
  1192         return -1;
  1193     }
  1193     }
  1194 
  1194 
  1195     if (ecrt_slave_config_pdos(slave%(slave)d, EC_END, slave_%(slave)d_syncs)) {
  1195     if (ecrt_slave_config_pdos(slave%(slave)d, EC_END, slave_%(slave)d_syncs)) {
  1196         fprintf(stderr, "Failed to configure PDOs for slave %(device_type)s at alias %(alias)d and position %(position)d.\\n");
  1196         SLOGF(LOG_CRITICAL, "Failed to configure PDOs for slave %(device_type)s at alias %(alias)d and position %(position)d.\\n");
  1197         return -1;
  1197         return -1;
  1198     }
  1198     }
  1199 """
  1199 """
  1200 
  1200 
  1201 SLAVE_INITIALIZATION_TEMPLATE = """
  1201 SLAVE_INITIALIZATION_TEMPLATE = """
  1202     {
  1202     {
  1203         uint8_t value[%(data_size)d];
  1203         uint8_t value[%(data_size)d];
  1204         EC_WRITE_%(data_type)s((uint8_t *)value, %(data)s);
  1204         EC_WRITE_%(data_type)s((uint8_t *)value, %(data)s);
  1205         if (ecrt_master_sdo_download(master, %(slave)d, 0x%(index).4x, 0x%(subindex).2x, (uint8_t *)value, %(data_size)d, &abort_code)) {
  1205         if (ecrt_master_sdo_download(master, %(slave)d, 0x%(index).4x, 0x%(subindex).2x, (uint8_t *)value, %(data_size)d, &abort_code)) {
  1206             fprintf(stderr, "Failed to initialize slave %(device_type)s at alias %(alias)d and position %(position)d.\\nError: %%d\\n", abort_code);
  1206             SLOGF(LOG_CRITICAL, "Failed to initialize slave %(device_type)s at alias %(alias)d and position %(position)d.\\nError: %%d\\n", abort_code);
  1207             return -1;
  1207             return -1;
  1208         }
  1208         }
  1209     }
  1209     }
  1210 """
  1210 """
  1211 
  1211 
  1212 SLAVE_OUTPUT_PDO_DEFAULT_VALUE = """
  1212 SLAVE_OUTPUT_PDO_DEFAULT_VALUE = """
  1213     {
  1213     {
  1214         uint8_t value[%(data_size)d];
  1214         uint8_t value[%(data_size)d];
  1215         if (ecrt_master_sdo_upload(master, %(slave)d, 0x%(index).4x, 0x%(subindex).2x, (uint8_t *)value, %(data_size)d, &result_size, &abort_code)) {
  1215         if (ecrt_master_sdo_upload(master, %(slave)d, 0x%(index).4x, 0x%(subindex).2x, (uint8_t *)value, %(data_size)d, &result_size, &abort_code)) {
  1216             fprintf(stderr, "Failed to get default value for output PDO in slave %(device_type)s at alias %(alias)d and position %(position)d.\\nError: %%d\\n", abort_code);
  1216             SLOGF(LOG_CRITICAL, "Failed to get default value for output PDO in slave %(device_type)s at alias %(alias)d and position %(position)d.\\nError: %%d\\n", abort_code);
  1217             return -1;
  1217             return -1;
  1218         }
  1218         }
  1219         %(real_var)s = EC_READ_%(data_type)s((uint8_t *)value);
  1219         %(real_var)s = EC_READ_%(data_type)s((uint8_t *)value);
  1220     }
  1220     }
  1221 """
  1221 """