[etherlab-users] Controlled by userspace application
Frank Werner
etherlab at wesoft.de
Mon Feb 4 18:40:38 CET 2008
>> Hi all,
>>
>> I need to control some Beckhoff EL1004/EL2004 (Digital I/O) modules from
>> a
>> Linux userspace application. Realtime is not a request for this projekt.
>>
>> So I wrote a kernel module (ec_control), which talkes via a character
>> device
>> to the userspace application.
>>
>> I use etherlab 1.3.2 and a 2.6.20.21 Kernel.
>>
>> I need some assistance to talk from my ec_control module to the
>> ec_master
>> module. I read the doc generated by doxygen (shipped with etherlab
>> 1.3.2). I
>> miss some infos about how to set the outputs or how to read the inputs.
>> How
>> can I obtain infos about the slaves (inside my kernel module, I know
>> about
>> lsec from etherlab)
>
> You'll have to register the slaves' PDOs inside a domain using
> ecrt_master_create_domain() and ecrt_domain_register_pdo() or -like in
> the minimal example (l. 191ff)- ecrt_domain_register_pdo_list(). Then
> you can access the PDOs with the supplied process data pointers (l.
> 64ff) and the EC_(READ|WRITE)_* macros (l. 94).
>
> If this doesn't help you, consider posting an excerpt of your code, so
> we can have a look at it.
Hi Florian,
ok, here is my code:
...
static void *r_dig_out;
ec_slave_t *slave;
// Request master
if (!(master = ecrt_request_master(master_id))) {
ERROR("Requesting master %i failed!", master_id);
goto out_return;
}
// Install callbacks
ecrt_master_callbacks(master, request_lock, release_lock, NULL);
// Create domain
if (!(domain = ecrt_master_create_domain(master))) {
ERROR("Domain creation failed!");
goto out_release_master;
}
// Get Slave
if (!(slave = ecrt_master_get_slave(master, "1", Beckhoff_EL2004))) {
ERROR("Getting slave failed!");
goto out_release_master;
}
// Register PDOs
if (ecrt_domain_register_pdo(domain, slave, Beckhoff_EL2004_PDO_Outputs,
&r_dig_out)) {
ERROR("PDO registration failed!");
goto out_release_master;
}
// activate master
if (ecrt_master_activate(master)) {
ERROR("Failed to activate master!");
goto out_release_master;
}
//EC_WRITE_U8(r_dig_out, 0x0F);
return SUCCESS;
out_release_master:
ERROR("Releasing master");
ecrt_release_master(master);
out_return:
ERROR("Failed to load. Aborting.");
unregister_chrdev(EC_CONTROL_MAJOR, "ec_control");
return( -EIO );
...
The module loading breaks with 'PDO registration failed!' ... here is the
kernel output ...
...
ec_control: using master 0
EtherCAT: Requesting master 0...
EtherCAT: Successfully requested master 0.
EtherCAT ERROR: PDO entry 0x3001:1 is not mapped in slave 1.
ec_control: ERROR: PDO registration failed!
ec_control: ERROR: Releasing master
EtherCAT: Releasing master 0...
EtherCAT: Master thread exited.
EtherCAT: Starting master thread.
EtherCAT: Released master 0.
ec_control: ERROR: Failed to load. Aborting.
...
Is there any detailed documentation about how to using the ethercat master
module?
Currently I have only the EL2004 module connected. lsec says:
...
0 PREOP EK1100 EtherCAT-Koppler (2A E-Bus)
1 PREOP EL2004 4K. Dig. Ausgang 24V, 0.5A
...
Hope, you can help me.
-Frank-
More information about the Etherlab-users
mailing list