[etherlab-users] Slave RxPDOs exchange problem
Olivier Tempier
olivier.tempier at lirmm.fr
Tue Nov 20 10:40:09 CET 2012
Hello,
I try to use an maxon EPOS3 driver with igh ethercat library.
I wrote a test code in c, all seems ok. I don't see any message error in
debug file.
But i can't read/write RxPDOS and i don't see why... I have no problem
to read TXPDOs...
I join debug file and my source file.
I'm on this problem for a week, i'm starting to go crazy :p
Please, If someone could help me?
Regards
Oliver TEMPIER
-------------- next part --------------
/* Master 0, Slave 1, "EPOS3"
* Vendor ID: 0x000000fb
* Product code: 0x64400000
* Revision number: 0x22000000
*/
ec_pdo_entry_info_t slave_1_pdo_entries[] = {
{0x6040, 0x00, 16}, /* 0x6040:00 */
{0x607a, 0x00, 32}, /* 0x607A:00 */
{0x60ff, 0x00, 32}, /* 0x60FF:00 */
{0x6071, 0x00, 16}, /* 0x6071:00 */
{0x60b0, 0x00, 32}, /* 0x60B0:00 */
{0x60b1, 0x00, 32}, /* 0x60B1:00 */
{0x60b2, 0x00, 16}, /* 0x60B2:00 */
{0x6060, 0x00, 8}, /* 0x6060:00 */
{0x2078, 0x01, 16}, /* 0x2078:01 */
{0x6041, 0x00, 16}, /* 0x6041:00 */
{0x6064, 0x00, 32}, /* 0x6064:00 */
{0x606c, 0x00, 32}, /* 0x606C:00 */
{0x6077, 0x00, 16}, /* 0x6077:00 */
{0x6061, 0x00, 8}, /* 0x6061:00 */
{0x2071, 0x01, 16}, /* 0x2071:01 */
};
ec_pdo_info_t slave_1_pdos[] = {
{0x1603, 9, slave_1_pdo_entries + 0}, /* 0x1603:00 */
{0x1a03, 6, slave_1_pdo_entries + 9}, /* 0x1A03:00 */
};
ec_sync_info_t slave_1_syncs[] = {
{0, EC_DIR_OUTPUT, 0, NULL, EC_WD_DISABLE},
{1, EC_DIR_INPUT, 0, NULL, EC_WD_DISABLE},
{2, EC_DIR_OUTPUT, 1, slave_1_pdos + 0, EC_WD_ENABLE},
{3, EC_DIR_INPUT, 1, slave_1_pdos + 1, EC_WD_DISABLE},
{0xff}
};
-------------- next part --------------
[ 885.844284] EtherCAT ec_rtai_sample: Robotics => Starting ...
[ 885.844287] EtherCAT ec_rtai_sample: Robotics => Request Master ...
[ 885.844290] EtherCAT: Requesting master 0...
[ 885.844294] EtherCAT DEBUG 0: IDLE -> OPERATION.
[ 885.844297] EtherCAT: Successfully requested master 0.
[ 885.844299] EtherCAT ec_rtai_sample: Robotics => Init Master Callback ...
[ 885.844303] EtherCAT DEBUG 0: ecrt_master_callbacks(master = 0xf48f0800, send_cb = 0xf784f165, receive_cb = 0xf784f122, cb_data = 0xf48f0800)
[ 885.844306] EtherCAT ec_rtai_sample: Robotics => Registering Domain...
[ 885.844309] EtherCAT DEBUG 0: ecrt_master_create_domain(master = 0xf48f0800)
[ 885.844312] EtherCAT DEBUG 0: Created domain 0.
[ 885.844314] EtherCAT ec_rtai_sample: Robotics => Master Slave EPOS3_0 config...
[ 885.844318] EtherCAT DEBUG 0: ecrt_master_slave_config(master = 0xf48f0800, alias = 0, position = 1, vendor_id = 0x000000fb, product_code = 0x64400000)
[ 885.844322] EtherCAT DEBUG 0: Creating slave configuration for 0:1, 0x000000FB/0x64400000.
[ 885.844326] EtherCAT DEBUG 0 0:1: Attached slave 1.
[ 885.844337] EtherCAT ec_rtai_sample: Robotics => Master Slave EK1100 config...
[ 885.844340] EtherCAT DEBUG 0: ecrt_master_slave_config(master = 0xf48f0800, alias = 0, position = 0, vendor_id = 0x00000002, product_code = 0x044c2c52)
[ 885.844344] EtherCAT DEBUG 0: Creating slave configuration for 0:0, 0x00000002/0x044C2C52.
[ 885.844347] EtherCAT DEBUG 0 0:0: Attached slave 0.
[ 885.844351] EtherCAT DEBUG 0: ecrt_master_slave_config(master = 0xf48f0800, alias = 0, position = 1, vendor_id = 0x000000fb, product_code = 0x64400000)
[ 885.844354] EtherCAT ec_rtai_sample: Robotics => Configuring EPOS3_0 PDOs...
[ 885.844361] EtherCAT DEBUG 0 0:1: ecrt_slave_config_pdos(sc = 0xf4d77c00, n_syncs = 4294967295, syncs = 0xf78508b4)
[ 885.844366] EtherCAT DEBUG 0 0:1: ecrt_slave_config_sync_manager(sc = 0xf4d77c00, sync_index = 0, dir = 1, watchdog_mode = 2)
[ 885.844370] EtherCAT DEBUG 0 0:1: ecrt_slave_config_sync_manager(sc = 0xf4d77c00, sync_index = 1, dir = 2, watchdog_mode = 2)
[ 885.844374] EtherCAT DEBUG 0 0:1: ecrt_slave_config_sync_manager(sc = 0xf4d77c00, sync_index = 2, dir = 1, watchdog_mode = 1)
[ 885.844388] EtherCAT DEBUG 0 0:1: ecrt_slave_config_pdo_assign_clear(sc = 0xf4d77c00, sync_index = 2)
[ 885.844395] EtherCAT DEBUG 0 0:1: ecrt_slave_config_pdo_assign_add(sc = 0xf4d77c00, sync_index = 2, pdo_index = 0x1603)
[ 885.844399] EtherCAT DEBUG 0 0:1: Loading default mapping for PDO 0x1603.
[ 885.844403] EtherCAT DEBUG 0 0:1: Found PDO name "0x1603:00".
[ 885.844410] EtherCAT DEBUG 0 0:1: Entry 0x6040:00.
[ 885.844413] EtherCAT DEBUG 0 0:1: Entry 0x607A:00.
[ 885.844415] EtherCAT DEBUG 0 0:1: Entry 0x60FF:00.
[ 885.844419] EtherCAT DEBUG 0 0:1: Entry 0x6071:00.
[ 885.844423] EtherCAT DEBUG 0 0:1: Entry 0x60B0:00.
[ 885.844426] EtherCAT DEBUG 0 0:1: Entry 0x60B1:00.
[ 885.844428] EtherCAT DEBUG 0 0:1: Entry 0x60B2:00.
[ 885.844432] EtherCAT DEBUG 0 0:1: Entry 0x6060:00.
[ 885.844435] EtherCAT DEBUG 0 0:1: Entry 0x2078:01.
[ 885.844440] EtherCAT DEBUG 0 0:1: ecrt_slave_config_pdo_mapping_clear(sc = 0xf4d77c00, pdo_index = 0x1603)
[ 885.844447] EtherCAT DEBUG 0 0:1: ecrt_slave_config_pdo_mapping_add(sc = 0xf4d77c00, pdo_index = 0x1603, entry_index = 0x6040, entry_subindex = 0x00, entry_bit_length = 16)
[ 885.844452] EtherCAT DEBUG 0 0:1: ecrt_slave_config_pdo_mapping_add(sc = 0xf4d77c00, pdo_index = 0x1603, entry_index = 0x607A, entry_subindex = 0x00, entry_bit_length = 32)
[ 885.844458] EtherCAT DEBUG 0 0:1: ecrt_slave_config_pdo_mapping_add(sc = 0xf4d77c00, pdo_index = 0x1603, entry_index = 0x60FF, entry_subindex = 0x00, entry_bit_length = 32)
[ 885.844464] EtherCAT DEBUG 0 0:1: ecrt_slave_config_pdo_mapping_add(sc = 0xf4d77c00, pdo_index = 0x1603, entry_index = 0x6071, entry_subindex = 0x00, entry_bit_length = 16)
[ 885.844470] EtherCAT DEBUG 0 0:1: ecrt_slave_config_pdo_mapping_add(sc = 0xf4d77c00, pdo_index = 0x1603, entry_index = 0x60B0, entry_subindex = 0x00, entry_bit_length = 32)
[ 885.844475] EtherCAT DEBUG 0 0:1: ecrt_slave_config_pdo_mapping_add(sc = 0xf4d77c00, pdo_index = 0x1603, entry_index = 0x60B1, entry_subindex = 0x00, entry_bit_length = 32)
[ 885.844481] EtherCAT DEBUG 0 0:1: ecrt_slave_config_pdo_mapping_add(sc = 0xf4d77c00, pdo_index = 0x1603, entry_index = 0x60B2, entry_subindex = 0x00, entry_bit_length = 16)
[ 885.844487] EtherCAT DEBUG 0 0:1: ecrt_slave_config_pdo_mapping_add(sc = 0xf4d77c00, pdo_index = 0x1603, entry_index = 0x6060, entry_subindex = 0x00, entry_bit_length = 8)
[ 885.844493] EtherCAT DEBUG 0 0:1: ecrt_slave_config_pdo_mapping_add(sc = 0xf4d77c00, pdo_index = 0x1603, entry_index = 0x2078, entry_subindex = 0x01, entry_bit_length = 16)
[ 885.844498] EtherCAT DEBUG 0 0:1: ecrt_slave_config_sync_manager(sc = 0xf4d77c00, sync_index = 3, dir = 2, watchdog_mode = 2)
[ 885.844502] EtherCAT DEBUG 0 0:1: ecrt_slave_config_pdo_assign_clear(sc = 0xf4d77c00, sync_index = 3)
[ 885.844511] EtherCAT DEBUG 0 0:1: ecrt_slave_config_pdo_assign_add(sc = 0xf4d77c00, sync_index = 3, pdo_index = 0x1A03)
[ 885.844517] EtherCAT DEBUG 0 0:1: Loading default mapping for PDO 0x1A03.
[ 885.844522] EtherCAT DEBUG 0 0:1: Found PDO name "0x1A03:00".
[ 885.844527] EtherCAT DEBUG 0 0:1: Entry 0x6041:00.
[ 885.844530] EtherCAT DEBUG 0 0:1: Entry 0x6064:00.
[ 885.844534] EtherCAT DEBUG 0 0:1: Entry 0x606C:00.
[ 885.844539] EtherCAT DEBUG 0 0:1: Entry 0x6077:00.
[ 885.844544] EtherCAT DEBUG 0 0:1: Entry 0x6061:00.
[ 885.844548] EtherCAT DEBUG 0 0:1: Entry 0x2071:01.
[ 885.844552] EtherCAT DEBUG 0 0:1: ecrt_slave_config_pdo_mapping_clear(sc = 0xf4d77c00, pdo_index = 0x1A03)
[ 885.844559] EtherCAT DEBUG 0 0:1: ecrt_slave_config_pdo_mapping_add(sc = 0xf4d77c00, pdo_index = 0x1A03, entry_index = 0x6041, entry_subindex = 0x00, entry_bit_length = 16)
[ 885.844566] EtherCAT DEBUG 0 0:1: ecrt_slave_config_pdo_mapping_add(sc = 0xf4d77c00, pdo_index = 0x1A03, entry_index = 0x6064, entry_subindex = 0x00, entry_bit_length = 32)
[ 885.844572] EtherCAT DEBUG 0 0:1: ecrt_slave_config_pdo_mapping_add(sc = 0xf4d77c00, pdo_index = 0x1A03, entry_index = 0x606C, entry_subindex = 0x00, entry_bit_length = 32)
[ 885.844579] EtherCAT DEBUG 0 0:1: ecrt_slave_config_pdo_mapping_add(sc = 0xf4d77c00, pdo_index = 0x1A03, entry_index = 0x6077, entry_subindex = 0x00, entry_bit_length = 16)
[ 885.844584] EtherCAT DEBUG 0 0:1: ecrt_slave_config_pdo_mapping_add(sc = 0xf4d77c00, pdo_index = 0x1A03, entry_index = 0x6061, entry_subindex = 0x00, entry_bit_length = 8)
[ 885.844589] EtherCAT DEBUG 0 0:1: ecrt_slave_config_pdo_mapping_add(sc = 0xf4d77c00, pdo_index = 0x1A03, entry_index = 0x2071, entry_subindex = 0x01, entry_bit_length = 16)
[ 885.844595] EtherCAT ec_rtai_sample: Robotics => Registering PDO entries...
[ 885.844599] EtherCAT DEBUG 0: ecrt_domain_reg_pdo_entry_list(domain = 0xf214bf80, regs = 0xf784f874)
[ 885.844603] EtherCAT DEBUG 0: ecrt_master_slave_config(master = 0xf48f0800, alias = 0, position = 1, vendor_id = 0x000000fb, product_code = 0x64400000)
[ 885.844608] EtherCAT DEBUG 0 0:1: ecrt_slave_config_reg_pdo_entry(sc = 0xf4d77c00, index = 0x6040, subindex = 0x00, domain = 0xf214bf80, bit_position = 0x(null))
[ 885.844614] EtherCAT DEBUG 0: Domain 0: Added 25 bytes, total 25.
[ 885.844618] EtherCAT DEBUG 0: ecrt_master_slave_config(master = 0xf48f0800, alias = 0, position = 1, vendor_id = 0x000000fb, product_code = 0x64400000)
[ 885.844623] EtherCAT DEBUG 0 0:1: ecrt_slave_config_reg_pdo_entry(sc = 0xf4d77c00, index = 0x607A, subindex = 0x00, domain = 0xf214bf80, bit_position = 0x(null))
[ 885.844628] EtherCAT DEBUG 0: ecrt_master_slave_config(master = 0xf48f0800, alias = 0, position = 1, vendor_id = 0x000000fb, product_code = 0x64400000)
[ 885.844632] EtherCAT DEBUG 0 0:1: ecrt_slave_config_reg_pdo_entry(sc = 0xf4d77c00, index = 0x60FF, subindex = 0x00, domain = 0xf214bf80, bit_position = 0x(null))
[ 885.844637] EtherCAT DEBUG 0: ecrt_master_slave_config(master = 0xf48f0800, alias = 0, position = 1, vendor_id = 0x000000fb, product_code = 0x64400000)
[ 885.844643] EtherCAT DEBUG 0 0:1: ecrt_slave_config_reg_pdo_entry(sc = 0xf4d77c00, index = 0x6071, subindex = 0x00, domain = 0xf214bf80, bit_position = 0x(null))
[ 885.844647] EtherCAT DEBUG 0: ecrt_master_slave_config(master = 0xf48f0800, alias = 0, position = 1, vendor_id = 0x000000fb, product_code = 0x64400000)
[ 885.844653] EtherCAT DEBUG 0 0:1: ecrt_slave_config_reg_pdo_entry(sc = 0xf4d77c00, index = 0x60B0, subindex = 0x00, domain = 0xf214bf80, bit_position = 0x(null))
[ 885.844659] EtherCAT DEBUG 0: ecrt_master_slave_config(master = 0xf48f0800, alias = 0, position = 1, vendor_id = 0x000000fb, product_code = 0x64400000)
[ 885.844664] EtherCAT DEBUG 0 0:1: ecrt_slave_config_reg_pdo_entry(sc = 0xf4d77c00, index = 0x60B1, subindex = 0x00, domain = 0xf214bf80, bit_position = 0x(null))
[ 885.844673] EtherCAT DEBUG 0: ecrt_master_slave_config(master = 0xf48f0800, alias = 0, position = 1, vendor_id = 0x000000fb, product_code = 0x64400000)
[ 885.844678] EtherCAT DEBUG 0 0:1: ecrt_slave_config_reg_pdo_entry(sc = 0xf4d77c00, index = 0x60B2, subindex = 0x00, domain = 0xf214bf80, bit_position = 0x(null))
[ 885.844683] EtherCAT DEBUG 0: ecrt_master_slave_config(master = 0xf48f0800, alias = 0, position = 1, vendor_id = 0x000000fb, product_code = 0x64400000)
[ 885.844688] EtherCAT DEBUG 0 0:1: ecrt_slave_config_reg_pdo_entry(sc = 0xf4d77c00, index = 0x6060, subindex = 0x00, domain = 0xf214bf80, bit_position = 0x(null))
[ 885.844692] EtherCAT DEBUG 0: ecrt_master_slave_config(master = 0xf48f0800, alias = 0, position = 1, vendor_id = 0x000000fb, product_code = 0x64400000)
[ 885.844697] EtherCAT DEBUG 0 0:1: ecrt_slave_config_reg_pdo_entry(sc = 0xf4d77c00, index = 0x2078, subindex = 0x01, domain = 0xf214bf80, bit_position = 0x(null))
[ 885.844702] EtherCAT DEBUG 0: ecrt_master_slave_config(master = 0xf48f0800, alias = 0, position = 1, vendor_id = 0x000000fb, product_code = 0x64400000)
[ 885.844707] EtherCAT DEBUG 0 0:1: ecrt_slave_config_reg_pdo_entry(sc = 0xf4d77c00, index = 0x6041, subindex = 0x00, domain = 0xf214bf80, bit_position = 0x(null))
[ 885.844711] EtherCAT DEBUG 0: Domain 0: Added 15 bytes, total 40.
[ 885.844715] EtherCAT DEBUG 0: ecrt_master_slave_config(master = 0xf48f0800, alias = 0, position = 1, vendor_id = 0x000000fb, product_code = 0x64400000)
[ 885.844719] EtherCAT DEBUG 0 0:1: ecrt_slave_config_reg_pdo_entry(sc = 0xf4d77c00, index = 0x6064, subindex = 0x00, domain = 0xf214bf80, bit_position = 0x(null))
[ 885.844724] EtherCAT DEBUG 0: ecrt_master_slave_config(master = 0xf48f0800, alias = 0, position = 1, vendor_id = 0x000000fb, product_code = 0x64400000)
[ 885.844729] EtherCAT DEBUG 0 0:1: ecrt_slave_config_reg_pdo_entry(sc = 0xf4d77c00, index = 0x606C, subindex = 0x00, domain = 0xf214bf80, bit_position = 0x(null))
[ 885.844734] EtherCAT DEBUG 0: ecrt_master_slave_config(master = 0xf48f0800, alias = 0, position = 1, vendor_id = 0x000000fb, product_code = 0x64400000)
[ 885.844739] EtherCAT DEBUG 0 0:1: ecrt_slave_config_reg_pdo_entry(sc = 0xf4d77c00, index = 0x6077, subindex = 0x00, domain = 0xf214bf80, bit_position = 0x(null))
[ 885.844744] EtherCAT DEBUG 0: ecrt_master_slave_config(master = 0xf48f0800, alias = 0, position = 1, vendor_id = 0x000000fb, product_code = 0x64400000)
[ 885.844749] EtherCAT DEBUG 0 0:1: ecrt_slave_config_reg_pdo_entry(sc = 0xf4d77c00, index = 0x6061, subindex = 0x00, domain = 0xf214bf80, bit_position = 0x(null))
[ 885.844753] EtherCAT DEBUG 0: ecrt_master_slave_config(master = 0xf48f0800, alias = 0, position = 1, vendor_id = 0x000000fb, product_code = 0x64400000)
[ 885.844758] EtherCAT DEBUG 0 0:1: ecrt_slave_config_reg_pdo_entry(sc = 0xf4d77c00, index = 0x2071, subindex = 0x01, domain = 0xf214bf80, bit_position = 0x(null))
[ 885.844762] EtherCAT ec_rtai_sample: Robotics => Activating master...
[ 885.844765] EtherCAT DEBUG 0: ecrt_master_activate(master = 0xf48f0800)
[ 885.844770] EtherCAT 0: Domain0: Logical address 0x00000000, 40 byte, expected working counter 3.
[ 885.844774] EtherCAT 0: Datagram domain0-0: Logical offset 0x00000000, 40 byte, type LRW.
[ 885.844777] EtherCAT DEBUG 0: Stopping master thread.
[ 885.844784] EtherCAT DEBUG 0: Master IDLE thread exiting...
[ 885.844805] EtherCAT 0: Master thread exited.
[ 885.844810] EtherCAT DEBUG 0: FSM datagram is f48f0be0.
[ 885.844812] EtherCAT 0: Starting EtherCAT-OP thread.
[ 885.844869] EtherCAT ec_rtai_sample: Robotics => Master activate...
[ 885.844872] EtherCAT ec_rtai_sample: Robotics => Domain data initialisation ok.
[ 885.844875] EtherCAT ec_rtai_sample: Robotics => Init Netlink =>Entering: init_mod
[ 885.844881] EtherCAT DEBUG 0: Operation thread running with fsm interval = 1000 us, max data size=11250
[ 885.844888] EtherCAT WARNING 0: 1 datagram UNMATCHED!
[ 885.844890] EtherCAT ec_rtai_sample: Robotics => Starting cyclic sample thread...
[ 885.845919] EtherCAT ec_rtai_sample: Robotics => RT timer started with 10415/10416 ticks.
[ 885.845926] EtherCAT ec_rtai_sample: Robotics => Initialized.
[ 885.846419] EtherCAT DEBUG 0: Configuration changed (aborting state check).
[ 885.846423] EtherCAT DEBUG 0: Writing system time offsets...
[ 885.846425] EtherCAT WARNING 0: No app_time received up to now, but master already active.
[ 885.846428] EtherCAT DEBUG 0: Requesting OP...
[ 885.846430] EtherCAT ec_rtai_sample: Robotics => go in run ***************************************.
[ 885.846433] EtherCAT ec_rtai_sample: Robotics =>master state=> 2 slave(s).
[ 885.846436] EtherCAT ec_rtai_sample: Robotics => master state is PREOP now222222222222222222222222222222222222.
[ 885.846439] EtherCAT ec_rtai_sample: Robotics => master state=>Link is up .
[ 885.846442] EtherCAT ec_rtai_sample: Robotics => EPOS3_0 state 0x02.
[ 885.846445] EtherCAT ec_rtai_sample: Robotics => EPOS3_0 online.
[ 885.848430] EtherCAT DEBUG 0-0: Changing state from PREOP to OP.
[ 885.848434] EtherCAT DEBUG 0-0: Configuring...
[ 885.850420] EtherCAT DEBUG 0-0: Now in INIT.
[ 885.850435] EtherCAT DEBUG 0-0: Clearing FMMU configurations...
[ 885.851424] EtherCAT DEBUG 0-0: Clearing sync manager configurations...
[ 885.852415] EtherCAT DEBUG 0-0: Clearing DC assignment...
[ 885.853414] EtherCAT DEBUG 0-0: Slave does not support mailbox communication.
[ 885.855420] EtherCAT DEBUG 0-0: Now in PREOP.
[ 885.857919] EtherCAT DEBUG 0-0: Now in SAFEOP.
[ 885.858920] EtherCAT DEBUG 0-0: Now in OP. Finished configuration.
[ 885.859456] EtherCAT DEBUG 0-1: Changing state from PREOP to OP.
[ 885.859459] EtherCAT DEBUG 0-1: Configuring...
[ 885.860921] EtherCAT DEBUG 0-1: Now in INIT.
[ 885.860923] EtherCAT DEBUG 0-1: Clearing FMMU configurations...
[ 885.860930] EtherCAT ec_rtai_sample: Robotics => EPOS3_0 state 0x01.
[ 885.861922] EtherCAT DEBUG 0-1: Clearing sync manager configurations...
[ 885.862915] EtherCAT DEBUG 0-1: Clearing DC assignment...
[ 885.863413] EtherCAT DEBUG 0-1: Configuring mailbox sync managers...
[ 885.863431] EtherCAT DEBUG 0-1: SM0: Addr 0x1000, Size 1024, Ctrl 0x26, En 1
[ 885.863435] EtherCAT DEBUG 0-1: SM1: Addr 0x1400, Size 1024, Ctrl 0x22, En 1
[ 885.867924] EtherCAT DEBUG 0-1: Now in PREOP.
[ 885.867932] EtherCAT ec_rtai_sample: Robotics => EPOS3_0 state 0x02.
[ 885.867937] EtherCAT DEBUG 0-1: Setting PDO assignment of SM2:
[ 885.867939] EtherCAT DEBUG 0-1: Currently assigned PDOs: 0x1603. PDOs to assign: 0x1603
[ 885.867946] EtherCAT DEBUG 0-1: Setting number of assigned PDOs to zero.
[ 885.867950] EtherCAT DEBUG 0-1: Downloading SDO 0x1C12:00.
[ 885.867952] EtherCAT DEBUG: 00
[ 885.867956] EtherCAT DEBUG 0-1: Expedited download request:
[ 885.867958] EtherCAT DEBUG: 00 20 2F 12 1C 00 00 00 00 00
[ 885.870429] EtherCAT DEBUG 0-1: Download response:
[ 885.870431] EtherCAT DEBUG: 00 30 60 12 1C 00 00 00 00 00
[ 885.870445] EtherCAT DEBUG 0-1: Assigning PDO 0x1603 at position 1.
[ 885.870448] EtherCAT DEBUG 0-1: Downloading SDO 0x1C12:01.
[ 885.870450] EtherCAT DEBUG: 03 16
[ 885.870454] EtherCAT DEBUG 0-1: Expedited download request:
[ 885.870456] EtherCAT DEBUG: 00 20 2B 12 1C 01 03 16 00 00
[ 885.874424] EtherCAT DEBUG 0-1: Download response:
[ 885.874430] EtherCAT DEBUG: 00 30 60 12 1C 01 03 16 00 00
[ 885.874440] EtherCAT DEBUG 0-1: Setting number of assigned PDOs to 1.
[ 885.874443] EtherCAT DEBUG 0-1: Downloading SDO 0x1C12:00.
[ 885.874445] EtherCAT DEBUG: 01
[ 885.874448] EtherCAT DEBUG 0-1: Expedited download request:
[ 885.874450] EtherCAT DEBUG: 00 20 2F 12 1C 00 01 00 00 00
[ 885.876920] EtherCAT DEBUG 0-1: Download response:
[ 885.876926] EtherCAT DEBUG: 00 30 60 12 1C 00 01 00 00 00
[ 885.876938] EtherCAT DEBUG 0-1: Successfully configured PDO assignment of SM2.
[ 885.876945] EtherCAT DEBUG 0-1: Setting PDO assignment of SM3:
[ 885.876948] EtherCAT DEBUG 0-1: Currently assigned PDOs: 0x1A03. PDOs to assign: 0x1A03
[ 885.876954] EtherCAT DEBUG 0-1: Setting number of assigned PDOs to zero.
[ 885.876957] EtherCAT DEBUG 0-1: Downloading SDO 0x1C13:00.
[ 885.876959] EtherCAT DEBUG: 00
[ 885.876963] EtherCAT DEBUG 0-1: Expedited download request:
[ 885.876965] EtherCAT DEBUG: 00 20 2F 13 1C 00 00 00 00 00
[ 885.879426] EtherCAT DEBUG 0-1: Download response:
[ 885.879432] EtherCAT DEBUG: 00 30 60 13 1C 00 00 00 00 00
[ 885.879444] EtherCAT DEBUG 0-1: Assigning PDO 0x1A03 at position 1.
[ 885.879447] EtherCAT DEBUG 0-1: Downloading SDO 0x1C13:01.
[ 885.879449] EtherCAT DEBUG: 03 1A
[ 885.879453] EtherCAT DEBUG 0-1: Expedited download request:
[ 885.879455] EtherCAT DEBUG: 00 20 2B 13 1C 01 03 1A 00 00
[ 885.881424] EtherCAT DEBUG 0-1: Download response:
[ 885.881426] EtherCAT DEBUG: 00 30 60 13 1C 01 03 1A 00 00
[ 885.881442] EtherCAT DEBUG 0-1: Setting number of assigned PDOs to 1.
[ 885.881444] EtherCAT DEBUG 0-1: Downloading SDO 0x1C13:00.
[ 885.881446] EtherCAT DEBUG: 01
[ 885.881450] EtherCAT DEBUG 0-1: Expedited download request:
[ 885.881452] EtherCAT DEBUG: 00 20 2F 13 1C 00 01 00 00 00
[ 885.884425] EtherCAT DEBUG 0-1: Download response:
[ 885.884428] EtherCAT DEBUG: 00 30 60 13 1C 00 01 00 00 00
[ 885.884439] EtherCAT DEBUG 0-1: Successfully configured PDO assignment of SM3.
[ 885.884445] EtherCAT DEBUG 0-1: SM2: Addr 0x1800, Size 25, Ctrl 0x64, En 1
[ 885.884449] EtherCAT DEBUG 0-1: SM3: Addr 0x1C00, Size 15, Ctrl 0x20, En 1
[ 885.885429] EtherCAT DEBUG 0 0:1: FMMU: LogAddr 0x00000000, Size 25, PhysAddr 0x1800, SM2, Dir out
[ 885.885435] EtherCAT DEBUG 0 0:1: FMMU: LogAddr 0x00000019, Size 15, PhysAddr 0x1C00, SM3, Dir in
[ 885.890414] EtherCAT DEBUG 0-1: Now in SAFEOP.
[ 885.890438] EtherCAT 0: Domain 0: Working counter changed to 3/3.
[ 885.890441] EtherCAT ec_rtai_sample: Robotics => Domain1 => Working Counter 3
[ 885.890443] EtherCAT ec_rtai_sample: Robotics => Domain1 => State 2
[ 885.890446] EtherCAT ec_rtai_sample: Robotics => EPOS3_0 state 0x04.
[ 885.893916] EtherCAT DEBUG 0-1: Now in OP. Finished configuration.
[ 885.893936] EtherCAT ec_rtai_sample: Robotics => EPOS3_0 state 0x08.
[ 885.893939] EtherCAT ec_rtai_sample: Robotics => EPOS3_0 operational.
[ 885.894488] EtherCAT 0: Slave states: OP.
[ 885.894930] EtherCAT ec_rtai_sample: Robotics => master state is OP now.88888888888888888888888888888888888888
[ 885.894933] EtherCAT ec_rtai_sample: RxPDOs*********************************************************************
[ 885.894937] EtherCAT ec_rtai_sample: Robotics => Cyclic_task=>EPOS3_0 Control Word = 0
[ 885.894940] EtherCAT ec_rtai_sample: TxPDOs*********************************************************************
[ 885.894943] EtherCAT ec_rtai_sample: Robotics => TxPDO =>EPOS3_0 Status Word = 311
[ 885.895427] EtherCAT ec_rtai_sample: RxPDOs*********************************************************************
[ 885.895432] EtherCAT ec_rtai_sample: Robotics => Cyclic_task=>EPOS3_0 Control Word = 0
[ 885.895435] EtherCAT ec_rtai_sample: TxPDOs*********************************************************************
[ 885.895439] EtherCAT ec_rtai_sample: Robotics => TxPDO =>EPOS3_0 Status Word = 311
[ 885.895929] EtherCAT ec_rtai_sample: RxPDOs*********************************************************************
[ 885.895933] EtherCAT ec_rtai_sample: Robotics => Cyclic_task=>EPOS3_0 Control Word = 0
[ 885.895936] EtherCAT ec_rtai_sample: TxPDOs*********************************************************************
[ 885.895939] EtherCAT ec_rtai_sample: Robotics => TxPDO =>EPOS3_0 Status Word = 311
[ 885.896428] EtherCAT ec_rtai_sample: RxPDOs*********************************************************************
[ 885.896432] EtherCAT ec_rtai_sample: Robotics => Cyclic_task=>EPOS3_0 Control Word = 0
[ 885.896435] EtherCAT ec_rtai_sample: TxPDOs*********************************************************************
[ 885.896438] EtherCAT ec_rtai_sample: Robotics => TxPDO =>EPOS3_0 Status Word = 311
[ 885.896929] EtherCAT ec_rtai_sample: RxPDOs*********************************************************************
[ 885.896933] EtherCAT ec_rtai_sample: Robotics => Cyclic_task=>EPOS3_0 Control Word = 0
[ 885.896936] EtherCAT ec_rtai_sample: TxPDOs*********************************************************************
[ 885.896939] EtherCAT ec_rtai_sample: Robotics => TxPDO =>EPOS3_0 Status Word = 311
[ 885.897430] EtherCAT ec_rtai_sample: RxPDOs*********************************************************************
[ 885.897434] EtherCAT ec_rtai_sample: Robotics => Cyclic_task=>EPOS3_0 Control Word = 0
[ 885.897437] EtherCAT ec_rtai_sample: TxPDOs*********************************************************************
[ 885.897440] EtherCAT ec_rtai_sample: Robotics => TxPDO =>EPOS3_0 Status Word = 311
[ 885.897930] EtherCAT ec_rtai_sample: RxPDOs*********************************************************************
[ 885.897933] EtherCAT ec_rtai_sample: Robotics => Cyclic_task=>EPOS3_0 Control Word = 0
[ 885.897936] EtherCAT ec_rtai_sample: TxPDOs*********************************************************************
[ 885.897940] EtherCAT ec_rtai_sample: Robotics => TxPDO =>EPOS3_0 Status Word = 311
[ 885.898429] EtherCAT ec_rtai_sample: RxPDOs*********************************************************************
[ 885.898433] EtherCAT ec_rtai_sample: Robotics => Cyclic_task=>EPOS3_0 Control Word = 0
[ 885.898436] EtherCAT ec_rtai_sample: TxPDOs*********************************************************************
[ 885.898439] EtherCAT ec_rtai_sample: Robotics => TxPDO =>EPOS3_0 Status Word = 311
[ 885.898929] EtherCAT ec_rtai_sample: RxPDOs*********************************************************************
[ 885.898932] EtherCAT ec_rtai_sample: Robotics => Cyclic_task=>EPOS3_0 Control Word = 0
[ 885.898935] EtherCAT ec_rtai_sample: TxPDOs*********************************************************************
[ 885.898938] EtherCAT ec_rtai_sample: Robotics => TxPDO =>EPOS3_0 Status Word = 311
[ 885.899429] EtherCAT ec_rtai_sample: RxPDOs*********************************************************************
[ 885.899433] EtherCAT ec_rtai_sample: Robotics => Cyclic_task=>EPOS3_0 Control Word = 0
[ 885.899436] EtherCAT ec_rtai_sample: TxPDOs*********************************************************************
[ 885.899439] EtherCAT ec_rtai_sample: Robotics => TxPDO =>EPOS3_0 Status Word = 311
[ 889.248603] EtherCAT ec_rtai_sample: Robotics => Stopping...
[ 889.248636] EtherCAT 0: Releasing master...
[ 889.248644] EtherCAT DEBUG 0: ecrt_master_deactivate(master = 0xf48f0800)
[ 889.248646] EtherCAT DEBUG 0: Stopping master thread.
[ 889.248663] EtherCAT DEBUG 0: Master OP thread exiting...
[ 889.248688] EtherCAT 0: Master thread exited.
[ 889.248700] EtherCAT 0: Starting EtherCAT-IDLE thread.
[ 889.248765] EtherCAT DEBUG 0: OPERATION -> IDLE.
[ 889.248768] EtherCAT DEBUG 0: Idle thread running with send interval = 1000 us, max data size=11250
[ 889.248771] EtherCAT 0: Released.
[ 889.248774] EtherCAT DEBUG 0: UNMATCHED datagram:
[ 889.248775] EtherCAT ec_rtai_sample: Robotics => Unloading...
[ 889.248778] EtherCAT DEBUG: 0C 14 00 00 00 00 28 00 00 00 00 00 00 00 00 00
[ 889.248792] EtherCAT DEBUG: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
[ 889.248806] EtherCAT DEBUG: 00 00 00 37 01 A1 37 3F 05 FE 01 00 00 C9 00 0A
[ 889.248820] EtherCAT DEBUG: 00 00 03 00
[ 889.248831] EtherCAT ERROR 0-1: Failed to receive AL state datagram: Datagram initialized.
[ 889.248840] EtherCAT DEBUG 0: Skipping already queued datagram f48f0be0.
[ 889.248842] EtherCAT DEBUG 0: Skipping re-initialized datagram f48f0be0.
[ 889.250393] EtherCAT DEBUG 0-0: Changing state from OP to PREOP (forced).
[ 889.250396] EtherCAT DEBUG 0-0: Configuring...
[ 889.250433] EtherCAT DEBUG 0-0: Now in INIT.
[ 889.250436] EtherCAT DEBUG 0-0: Clearing FMMU configurations...
[ 889.250468] EtherCAT DEBUG 0-0: Clearing sync manager configurations...
[ 889.250493] EtherCAT DEBUG 0-0: Clearing DC assignment...
[ 889.250512] EtherCAT DEBUG 0-0: Slave does not support mailbox communication.
[ 889.250551] EtherCAT DEBUG 0-0: Now in PREOP.
[ 889.250553] EtherCAT DEBUG 0-0: Finished configuration.
[ 889.251563] EtherCAT DEBUG 0-1: Changing state from OP to PREOP (forced).
[ 889.251567] EtherCAT DEBUG 0-1: Configuring...
[ 889.252424] EtherCAT DEBUG 0-1: Now in INIT.
[ 889.252427] EtherCAT DEBUG 0-1: Clearing FMMU configurations...
[ 889.252447] EtherCAT DEBUG 0-1: Clearing sync manager configurations...
[ 889.252467] EtherCAT DEBUG 0-1: Clearing DC assignment...
[ 889.252486] EtherCAT DEBUG 0-1: Configuring mailbox sync managers...
[ 889.252490] EtherCAT DEBUG 0-1: SM0: Addr 0x1000, Size 1024, Ctrl 0x26, En 1
[ 889.252493] EtherCAT DEBUG 0-1: SM1: Addr 0x1400, Size 1024, Ctrl 0x22, En 1
[ 889.256308] EtherCAT DEBUG 0-1: Now in PREOP.
[ 889.256310] EtherCAT DEBUG 0-1: Finished configuration.
[ 889.257185] EtherCAT 0: Slave states: PREOP.
[ 889.598010] EtherCAT WARNING: Datagram f48f0be0 (master-fsm) was SKIPPED 2 times.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: EPOS3.png
Type: image/png
Size: 14033 bytes
Desc: not available
URL: <http://lists.etherlab.org/pipermail/etherlab-users/attachments/20121120/e8adb046/attachment-0004.png>
-------------- next part --------------
=== Master 0, Slave 1 ===
SM0: PhysAddr 0x1000, DefaultSize 1024, ControlRegister 0x26, Enable 1
SM1: PhysAddr 0x1400, DefaultSize 1024, ControlRegister 0x22, Enable 1
SM2: PhysAddr 0x1800, DefaultSize 0, ControlRegister 0x64, Enable 1
RxPDO 0x1603 "0x1603:00"
PDO entry 0x6040:00, 16 bit, "0x6040:00"
PDO entry 0x607a:00, 32 bit, "0x607A:00"
PDO entry 0x60ff:00, 32 bit, "0x60FF:00"
PDO entry 0x6071:00, 16 bit, "0x6071:00"
PDO entry 0x60b0:00, 32 bit, "0x60B0:00"
PDO entry 0x60b1:00, 32 bit, "0x60B1:00"
PDO entry 0x60b2:00, 16 bit, "0x60B2:00"
PDO entry 0x6060:00, 8 bit, "0x6060:00"
PDO entry 0x2078:01, 16 bit, "0x2078:01"
SM3: PhysAddr 0x1c00, DefaultSize 0, ControlRegister 0x20, Enable 1
TxPDO 0x1a03 "0x1A03:00"
PDO entry 0x6041:00, 16 bit, "0x6041:00"
PDO entry 0x6064:00, 32 bit, "0x6064:00"
PDO entry 0x606c:00, 32 bit, "0x606C:00"
PDO entry 0x6077:00, 16 bit, "0x6077:00"
PDO entry 0x6061:00, 8 bit, "0x6061:00"
PDO entry 0x2071:01, 16 bit, "0x2071:01"
-------------- next part --------------
/*
============================================================================
Name : ightest.c
Author : TO
Version : 1
Copyright :
Description : test IGH ethercat in C, Ansi-style
============================================================================
*/
// Linux
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/err.h>
#include <linux/init.h>
// RTAI
#include <rtai_sched.h>
#include <rtai_sem.h>
// Ethercat
#include "ecrt.h"
// Netlink
#include <net/sock.h>
#include <linux/netlink.h>
#include <linux/skbuff.h>
#define NETLINK_USER 31
struct sock *nl_sk = NULL;
//RTAI
#define FREQUENCY 2000 // task frequency in Hz
#define INHIBIT_TIME 20
#define TIMERTICKS (1000000000 / FREQUENCY)
#define PFX "EtherCAT ec_rtai_sample: "
// RTAI
static RT_TASK task;
static SEM master_sem;
static cycles_t t_last_cycle = 0, t_critical;
static unsigned int counter = 0;
static unsigned int blink = 0;
// EtherCAT
#define PRECONFIGURE_PDOS 1 // use configuration in build
#define CONFIGURE_PDOS 1 // configure at runtime
#define NUMSLAVES 2
static ec_master_t *master = NULL;
static ec_master_state_t master_state = {};
static ec_domain_t *domain1 = NULL;
static ec_domain_state_t domain1_state = {};
static uint8_t *domain1_pd = NULL;
//Définition des entrées PDOs (process data object) qui apparaissent dans le domaine
// pour obtenir les infos suivante "./ethercat slaves"
// va bien sur dépendre de ce qui est branché
#define BusCouplerPos 0, 0
#define EPOS3_0_SlavePos 0,1
// pour obtenir les infos suivante "./ethercat slaves -v"
// vendor id, product code
#define Beckhoff_EK1100 0x00000002, 0x044c2c52
#define Maxon_EPOS3_0 0x000000fb, 0x64400000
//static int32_t EPOS3_0_Device_Type;
static int EPOS3_0_Control_Word;
static int32_t EPOS3_0_Target_Position;
static int32_t EPOS3_0_Target_Velocity;
static int EPOS3_0_Target_Torque;
static int32_t EPOS3_0_Position_Offset;
static int32_t EPOS3_0_Velocity_Offset;
static int EPOS3_0_Torque_Offset;
static int EPOS3_0_Operation_Mode;
static unsigned int EPOS3_0_Digital_Output_funct;
static unsigned int EPOS3_0_Status_Word;//ok
static int EPOS3_0_Position_Actual; //ok
static int EPOS3_0_Velocity_Actual;
static int EPOS3_0_Torque_Actual;
static int EPOS3_0_Operation_Display_Mode; //ok
static unsigned int EPOS3_0_Digital_Input_funct;
static unsigned int status=0;
static int32_t position=0;
static ec_slave_config_t *sc_EPOS3_0 = NULL;
static ec_slave_config_state_t sc_EPOS3_0_state = {};
//Le Domain registration ne nécessite que l'adresse de base du modules I/O
//le PDO entry index (param n°3) est obtenu par ./ethercat pdos
//exemple EL3102
//réponse ./ethercat pdos
//TxPDO 0x1a00 "TxPDO 001 mapping"
// PDO entry 0x3101:01, 8 bit, "Status"
// PDO entry 0x3101:02, 16 bit, "Value"
// TxPDO 0x1a01 "TxPDO 002 mapping"
// PDO entry 0x3102:01, 8 bit, "Status"
// PDO entry 0x3102:02, 16 bit, "Value"
//
// donne
//
//{AnaInSlavePos, Beckhoff_EL3102, 0x3101, 1, &off_ana_in_status},
//{AnaInSlavePos, Beckhoff_EL3102, 0x3101, 2, &off_ana_in_value},
const static ec_pdo_entry_reg_t domain1_regs[] =
{
//RX_PDO
{EPOS3_0_SlavePos,Maxon_EPOS3_0,0x6040,0,&EPOS3_0_Control_Word}, //Control_Word RW U16bit
{EPOS3_0_SlavePos,Maxon_EPOS3_0,0x607a,0,&EPOS3_0_Target_Position}, //Target Position RW I32bit
{EPOS3_0_SlavePos,Maxon_EPOS3_0,0x60FF,0,&EPOS3_0_Target_Velocity}, //Position Offset RW I32bit
{EPOS3_0_SlavePos,Maxon_EPOS3_0,0x6071,0,&EPOS3_0_Target_Torque}, //Velocity Offset RW I16bit
{EPOS3_0_SlavePos,Maxon_EPOS3_0,0x60b0,0,&EPOS3_0_Position_Offset}, //Torque Offset RW I32bit
{EPOS3_0_SlavePos,Maxon_EPOS3_0,0x60b1,0,&EPOS3_0_Velocity_Offset}, //Torque Offset RW I32bit
{EPOS3_0_SlavePos,Maxon_EPOS3_0,0x60b2,0,&EPOS3_0_Torque_Offset}, //Torque Offset RW I16bit
{EPOS3_0_SlavePos,Maxon_EPOS3_0,0x6060,0,&EPOS3_0_Operation_Mode}, //Modes of operation RW I8bit
{EPOS3_0_SlavePos,Maxon_EPOS3_0,0x2078,1,&EPOS3_0_Digital_Output_funct}, //Digital output functionalities RW U16bit
//TX_PDO
{EPOS3_0_SlavePos,Maxon_EPOS3_0,0x6041,0,&EPOS3_0_Status_Word}, //Status word RO U16bit
{EPOS3_0_SlavePos,Maxon_EPOS3_0,0x6064,0,&EPOS3_0_Position_Actual}, //Position actual value RO I32bit
{EPOS3_0_SlavePos,Maxon_EPOS3_0,0x606c,0,&EPOS3_0_Velocity_Actual}, //Velocity actual value RO I32bit
{EPOS3_0_SlavePos,Maxon_EPOS3_0,0x6077,0,&EPOS3_0_Torque_Actual}, //Torque actual value RO I16bit
{EPOS3_0_SlavePos,Maxon_EPOS3_0,0x6061,0,&EPOS3_0_Operation_Display_Mode}, //Modes of operation display RO I8bit
{EPOS3_0_SlavePos,Maxon_EPOS3_0,0x2071,1,&EPOS3_0_Digital_Input_funct}, //Digital Input functionalities RO record
{}
};
ec_pdo_entry_info_t EPOS3_0_pdo_entries[] =
{
{0x6040, 0x00, 16},
{0x607a, 0x00, 32},
{0x60ff, 0x00, 32},
{0x6071, 0x00, 16},
{0x60b0, 0x00, 32},
{0x60b1, 0x00, 32},
{0x60b2, 0x00, 16},
{0x6060, 0x00, 8},
{0x2078, 0x01, 16},
{0x6041, 0x00, 16},
{0x6064, 0x00, 32},
{0x606c, 0x00, 32},
{0x6077, 0x00, 16},
{0x6061, 0x00, 8},
{0x2071, 0x01, 16},
};
ec_pdo_info_t EPOS3_0_pdos[] =
{
{0x1603, 9, EPOS3_0_pdo_entries + 0}, /* 0x1603:00 */
{0x1a03, 6, EPOS3_0_pdo_entries + 9}, /* 0x1A03:00 */
};
ec_sync_info_t EPOS3_0_syncs[] =
{
{0, EC_DIR_OUTPUT, 0, NULL, EC_WD_DISABLE},
{1, EC_DIR_INPUT, 0, NULL, EC_WD_DISABLE},
{2, EC_DIR_OUTPUT, 1, EPOS3_0_pdos + 0, EC_WD_ENABLE},
{3, EC_DIR_INPUT, 1, EPOS3_0_pdos + 1, EC_WD_DISABLE},
{0xff}
};
void check_domain1_state(void)
{
ec_domain_state_t ds;
rt_sem_wait (&master_sem);
ecrt_domain_state(domain1, &ds);
rt_sem_signal(&master_sem);
#if 1 //equivalent à un commentaire 0=> compile pas 1=> compile
if(ds.working_counter != domain1_state.working_counter)
{
printk(KERN_INFO PFX "Robotics => Domain1 => Working Counter %u \n",ds.working_counter);
}
if(ds.wc_state != domain1_state.wc_state)
{
printk(KERN_INFO PFX "Robotics => Domain1 => State %u \n",ds.wc_state);
}
#endif
//printk(KERN_INFO PFX "Robotics => Domain1 => State %u \n",ds.wc_state);
domain1_state =ds;
}
void check_master_state(void)
{
ec_master_state_t ms;
rt_sem_wait (&master_sem);
ecrt_master_state(master,&ms);
rt_sem_signal(&master_sem);
if (ms.slaves_responding != master_state.slaves_responding)
{
printk(KERN_INFO PFX "Robotics =>master state=> %u slave(s). \n", ms.slaves_responding);
}
if(ms.al_states != master_state.al_states)
{
switch(ms.al_states)
{
case EC_AL_STATE_INIT:
printk(KERN_INFO PFX "Robotics => master state is INIT now1111111111111111111111111111111111111.\n");
break;
case EC_AL_STATE_PREOP:
printk(KERN_INFO PFX "Robotics => master state is PREOP now222222222222222222222222222222222222.\n");
break;
case EC_AL_STATE_SAFEOP:
printk(KERN_INFO PFX "Robotics => master state is SAFEOP now44444444444444444444444444444444444.\n");
break;
case EC_AL_STATE_OP:
printk(KERN_INFO PFX "Robotics => master state is OP now.88888888888888888888888888888888888888\n");
break;
}
//printk(KERN_INFO PFX "Robotics =>master state=> AL states: 0x%02X. \n",ms.al_states);
}
if(ms.link_up != master_state.link_up)
{
printk(KERN_INFO PFX "Robotics => master state=>Link is %s .\n", ms.link_up ? "up" : "down");
}
/* switch(ms.al_states)
{
case EC_AL_STATE_INIT:
printk(KERN_INFO PFX "Robotics => master state is INIT.\n");
break;
case EC_AL_STATE_PREOP:
printk(KERN_INFO PFX "Robotics => master state is PREOP.\n");
break;
case EC_AL_STATE_SAFEOP:
printk(KERN_INFO PFX "Robotics => master state is SAFEOP.\n");
break;
case EC_AL_STATE_OP:
printk(KERN_INFO PFX "Robotics => master state is OP.\n");
break;
}*/
master_state = ms;
}
void check_slave_config_states(void)
{
ec_slave_config_state_t s;
rt_sem_wait (&master_sem);
ecrt_slave_config_state (sc_EPOS3_0, &s);
rt_sem_signal(&master_sem);
if(s.al_state !=sc_EPOS3_0_state.al_state)
{
printk(KERN_INFO PFX "Robotics => EPOS3_0 state 0x%02X. \n",s.al_state);
}
if(s.online != sc_EPOS3_0_state.online)
{
printk(KERN_INFO PFX "Robotics => EPOS3_0 %s. \n",s.online ? "online" : "offline");
}
if(s.operational != sc_EPOS3_0_state.operational)
{
printk(KERN_INFO PFX "Robotics => EPOS3_0 %s operational. \n",s.operational ? "" : "Not");
}
sc_EPOS3_0_state = s;
//printk(KERN_INFO PFX "Robotics => EPOS3_0 State * %d * %d * %d * \n",s.online,s.operational,s.al_state);
/********** rajouter code ici si plusieurs slave ... *********/
}
void run (long data)
{
unsigned int i;
i=0;
printk(KERN_INFO PFX "Robotics => go in run ***************************************.\n");
while(1)
{
//check_master_state();
rt_sem_wait (&master_sem);
ecrt_master_receive(master);
ecrt_domain_process(domain1);
rt_sem_signal(&master_sem);
check_master_state();
check_domain1_state(); //optionel
check_slave_config_states();//optionel
if(counter)
{
counter--;
}
else
{
counter = FREQUENCY;
}
// calculate new process data
blink = !blink;
switch(master_state.al_states)
{
case EC_AL_STATE_INIT:
break;
case EC_AL_STATE_PREOP:
break;
case EC_AL_STATE_SAFEOP:
break;
case EC_AL_STATE_OP:
if(i<10)
{
i++;
printk(KERN_INFO PFX "RxPDOs********************************************************************* \n");
status=EC_READ_U16(domain1_pd + EPOS3_0_Control_Word);
printk(KERN_INFO PFX "Robotics => Cyclic_task=>EPOS3_0 Control Word = %d \n",status);
EC_WRITE_S16(domain1_pd + EPOS3_0_Target_Torque,0);
printk(KERN_INFO PFX "TxPDOs********************************************************************* \n");
status=EC_READ_U16(domain1_pd + EPOS3_0_Status_Word);
printk(KERN_INFO PFX "Robotics => TxPDO =>EPOS3_0 Status Word = %d \n",status);
}
break;
}
// send process data
rt_sem_wait (&master_sem);
ecrt_domain_queue(domain1);
ecrt_master_send(master);
rt_sem_signal(&master_sem);
rt_task_wait_period();
}
}
void send_callback(void *cb_data)
{
ec_master_t *m = (ec_master_t *) cb_data;
//printk(KERN_INFO "Robotics =>Send ext*****************************");
// too close to the next real time cycle: deny access...
if (get_cycles() - t_last_cycle <= t_critical)
{
//printk(KERN_INFO "Robotics =>Send*****************************");
rt_sem_wait(&master_sem);
ecrt_master_send_ext(m);
rt_sem_signal(&master_sem);
}
}
void receive_callback (void *cb_data)
{
ec_master_t *m = (ec_master_t *) cb_data;
//printk(KERN_INFO "Robotics =>Read ext*****************************");
// too close to the next real time cycle: deny acces...
if(get_cycles() - t_last_cycle <= t_critical)
{
//printk(KERN_INFO "Robotics =>Read*****************************");
rt_sem_wait (&master_sem);
ecrt_master_receive(m);
rt_sem_signal(&master_sem);
}
}
static void ethercat_nl_recv_msg(struct sk_buff *skb)
{
struct nlmsghdr *nlh;
int pid;
struct sk_buff *skb_out;
int msg_size;
char *msg="";
int res;
printk(KERN_INFO "Robotics => Entering: %s\n", __FUNCTION__);
nlh=(struct nlmsghdr*)skb->data;
printk(KERN_INFO "Robotics => Netlink received msg payload: %s\n",(char*)nlmsg_data(nlh));
pid = nlh->nlmsg_pid; /*pid of sending process */
sprintf(msg,"EPOS = %u \n",status);
msg_size=strlen(msg);
skb_out = nlmsg_new(msg_size,0);
if(!skb_out)
{
printk(KERN_ERR "Robotics => Failed to allocate new skb\n");
return;
}
nlh=nlmsg_put(skb_out,0,0,NLMSG_DONE,msg_size,0);
NETLINK_CB(skb_out).dst_group = 0; /* not in mcast group */
strncpy(nlmsg_data(nlh),msg,msg_size);
res=nlmsg_unicast(nl_sk,skb_out,pid);
if(res<0)
{
printk(KERN_INFO "Robotics => Error while sending bak to user\n");
}
}
int init_mod(void)
{
int ret = -1;
RTIME tick_period;
RTIME requested_ticks;
RTIME now;
ec_slave_config_t *sc;
printk(KERN_INFO PFX "Robotics => Starting ...\n"); /* prints */
rt_sem_init(&master_sem, 1);
t_critical = cpu_khz * 1000 / FREQUENCY - cpu_khz * INHIBIT_TIME / 1000;
printk(KERN_INFO PFX "Robotics => Request Master ...\n");
master = ecrt_request_master(0);
if(!master)
{
ret = -EBUSY;
printk(KERN_INFO PFX "Robotics => Requesting master 0 failed ...\n");
goto out_return;
}
printk(KERN_INFO PFX "Robotics => Init Master Callback ...\n");
ecrt_master_callbacks(master, send_callback, receive_callback, master);
printk(KERN_INFO PFX "Robotics => Registering Domain...\n");
domain1 = ecrt_master_create_domain(master);
if(!domain1)
{
printk(KERN_INFO PFX "Robotics => Domain create error... \n");
goto out_release_master;
}
printk(KERN_INFO PFX "Robotics => Master Slave EPOS3_0 config...\n");
sc= ecrt_master_slave_config(master, EPOS3_0_SlavePos, Maxon_EPOS3_0);
if (!sc)
{
printk(KERN_INFO PFX "Robotics => Failed to get EPOS3_0 configuration... \n");
goto out_release_master;
}
printk(KERN_INFO PFX "Robotics => Master Slave EK1100 config...\n");
sc= ecrt_master_slave_config(master,BusCouplerPos, Beckhoff_EK1100);
if (!sc)
{
printk(KERN_INFO PFX "Robotics => Failed to get EK1100 configuration... \n");
goto out_release_master;
}
sc_EPOS3_0 = ecrt_master_slave_config(master, EPOS3_0_SlavePos, Maxon_EPOS3_0);
if(!sc_EPOS3_0)
{
printk(KERN_INFO PFX "Robotics => Failed to get EPOS3_0 slave configuration... \n");
goto out_release_master;
}
printk(KERN_INFO PFX "Robotics => Configuring EPOS3_0 PDOs...\n");
if(ecrt_slave_config_pdos(sc_EPOS3_0, EC_END,EPOS3_0_syncs))
{
printk(KERN_INFO PFX "Robotics=>Failed to configure PDOs \n");
goto out_release_master;
}
/********** rajouter code ici si plusieurs slave ... *********/
printk(KERN_INFO PFX "Robotics => Registering PDO entries...\n");
if(ecrt_domain_reg_pdo_entry_list(domain1, domain1_regs))
{
printk(KERN_INFO PFX "Robotics => Failed to register PDO entries.\n");
goto out_release_master;
}
//Activation du master, ne plus appliquer de configuration aprés, ça ne marchera plus
printk(KERN_INFO PFX "Robotics => Activating master...\n");
if(ecrt_master_activate(master))
{
printk(KERN_INFO PFX "Robotics => Failed to activate master.\n");
goto out_release_master;
}
printk(KERN_INFO PFX "Robotics => Master activate...\n");
//Initialisation du Process Domain Memory (for user_space apps)
if(!(domain1_pd = ecrt_domain_data(domain1)))
{
printk(KERN_INFO PFX "Robotics => Domain data initialisation failed. \n");
goto out_release_master;
}
printk(KERN_INFO PFX "Robotics => Domain data initialisation ok. \n");
printk(KERN_INFO PFX "Robotics => Init Netlink =>Entering: %s\n",__FUNCTION__);
nl_sk=netlink_kernel_create(&init_net, NETLINK_USER, 0, ethercat_nl_recv_msg,
NULL, THIS_MODULE);
if(!nl_sk)
{
printk(KERN_ALERT "Robotics => Netlink Error creating socket.\n");
return -10;
}
printk(KERN_INFO PFX "Robotics => Starting cyclic sample thread... \n");
requested_ticks = nano2count(TIMERTICKS);
tick_period = start_rt_timer(requested_ticks);
printk(KERN_INFO PFX "Robotics => RT timer started with %i/%i ticks. \n",(int) tick_period, (int) requested_ticks);
if (rt_task_init(&task, run,0, 2000, 0, 1,NULL))
{
printk(KERN_INFO PFX "Robotics => Failed to init RTAI task! \n");
goto out_stop_timer;
}
now = rt_get_time();
if (rt_task_make_periodic(&task, now + tick_period, tick_period))
{
printk(KERN_INFO PFX "Robotics => Failed to run RTAI task! \n");
goto out_stop_task;
}
printk(KERN_INFO PFX "Robotics => Initialized. \n");
return 0;
out_stop_task:
rt_task_delete(&task);
out_stop_timer:
stop_rt_timer();
out_release_master:
printk(KERN_INFO PFX "Robotics => Releasing master... \n");
ecrt_release_master(master);
out_return:
rt_sem_delete(&master_sem);
printk(KERN_INFO PFX "Robotics => Failed to load. Aborting. \n");
return ret;
}
void cleanup_mod(void)
{
printk(KERN_INFO PFX "Robotics => Stopping... \n");
netlink_kernel_release(nl_sk);
rt_task_delete(&task);
stop_rt_timer();
ecrt_release_master(master);
rt_sem_delete(&master_sem);
printk(KERN_INFO PFX "Robotics => Unloading... \n");
}
MODULE_LICENSE("GPL");
MODULE_AUTHOR("TO");
module_init(init_mod);
module_exit(cleanup_mod);
//check_master_state(); //optionel
//check_slave_config_states(); //optionel
// printk(KERN_INFO PFX "RxPDOs********************************************************************* \n");
// status=EC_READ_U16(domain1_pd + EPOS3_0_Control_Word);
// printk(KERN_INFO PFX "Robotics => Cyclic_task=>EPOS3_0 Control Word = %d \n",status);
//printk(KERN_INFO PFX "**************************************************************************\n");
//EC_WRITE_S16(domain1_pd + EPOS3_0_Target_Torque,0);
// position=EC_READ_S16(domain1_pd + EPOS3_0_Target_Torque);
// printk(KERN_INFO PFX "3>Robotics => TxPDO =>EPOS3_0 Torque = %d \n",position);
//EC_WRITE_U16(domain1_pd + EPOS3_0_Control_Word,0x00);
//EPOS3_0_Control_Word=0;
// status=EC_READ_U8(domain1_pd + EPOS3_0_Operation_Mode);
// printk(KERN_INFO PFX "Robotics => Cyclic_task=>EPOS3_0 op. mode = %d \n",status);
// printk(KERN_INFO PFX "**************************************************************************\n");
/* printk(KERN_INFO PFX "TxPDOs********************************************************************* \n");
status=EC_READ_U16(domain1_pd + EPOS3_0_Status_Word);
printk(KERN_INFO PFX "Robotics => TxPDO =>EPOS3_0 Status Word = %d \n",status);
position=EC_READ_S32(domain1_pd + EPOS3_0_Position_Actual);
printk(KERN_INFO PFX "Robotics => TxPDO =>EPOS3_0 position = %d \n",position);
position=EC_READ_S32(domain1_pd + EPOS3_0_Velocity_Actual);
printk(KERN_INFO PFX "Robotics => TxPDO =>EPOS3_0 Velocity = %d \n",position);
position=EC_READ_S16(domain1_pd + EPOS3_0_Torque_Actual);
printk(KERN_INFO PFX "Robotics => TxPDO =>EPOS3_0 Torque = %d \n",position);
status=EC_READ_U8(domain1_pd + EPOS3_0_Operation_Display_Mode);
printk(KERN_INFO PFX "Robotics => TxPDO =>EPOS3_0 op. display mode = %d \n",status);
position=EC_READ_U16(domain1_pd + EPOS3_0_Digital_Input_funct);
printk(KERN_INFO PFX "Robotics => TxPDO =>EPOS3_0 Digital input funct = %d \n",position);
printk(KERN_INFO PFX "**************************************************************************\n");
*/
-------------- next part --------------
0 0:0 PREOP + EK1100 EtherCAT-Koppler (2A E-Bus)
1 0:1 PREOP + EPOS3 70/10 EtherCAT (FW 2200h_6440h_0000h_0000h)
More information about the Etherlab-users
mailing list