[etherlab-users] Modifying Domain Data
Graeme Foot
GraemeF at touchcut.com
Mon Mar 19 22:44:21 CET 2012
Hi,
As far as I'm aware the answer is no. ecrt_domain_process() processes the response from the EtherCAT frame and fills in the domain data.
However, I have a similar situation and what I'm doing is wrapping the access to the domain data in objects. On startup I create two extra bits of memory the same size as the domains. One to use as a cache and one to use as a mask. Each of the wrapper objects gets pointers to the memory also.
When an object needs to read its data you can do something like:
value = ( ((*(_type *)cacheAddress) & \
(*(_type *)maskAddress)) | \
((*(_type *)ecAddress) & \
~(*(_type *)maskAddress)) );\
When an object needs to write its data you can do something like:
*(_type *)cacheAddress = value; \
*(_type *)maskAddress = (_type)~0ull; \
Note: if it's a readonly value then you can just of course access the data directly.
The inside the ecrt_domain_process(),ecrt_domain_queue() calls I update the domain data with something like:
cnt = domainSize;
uint8_t *data8 = (uint8_t *)domECAddress;
uint8_t *mask8 = (uint8_t *)domMaskAddress;
uint8_t *cache8 = (uint8_t *)domCacheAddress;
for (i = 0; i < cnt; i++)
{
if (*mask8 != 0)
{
*data8 = ((*cache8) & (*mask8)) | ((*data8) & ~(*mask8));
*mask8 = 0;
}
data8++;
mask8++;
cache8++;
}
Note: In practice I do the majority of the data as uint64's, then revert to uint8's for the remainder.
I wouldn't mind hearing how other people deal with the issue.
Regards,
Graeme.
________________________________
From: etherlab-users-bounces at etherlab.org [mailto:etherlab-users-bounces at etherlab.org] On Behalf Of WIEGAND Ralf
Sent: Tuesday, 20 March 2012 01:03
To: etherlab-users at etherlab.org
Subject: [etherlab-users] Modifying Domain Data
Hello,
i have a problem modifying domain data in my ethercat-app. All the examples provided with the etherlabmaster modify the domain data between ecrt_domain_process() and ecrt_domain_queue(). I have the problem, that I have to modify the domain data outside these functions (in another task), but during ecrt_master_receive() my outputs were overwritten in the domain.
Is there any way to modify the domain data outside the functions ecrt_domain_process() and ecrt_domain_queue() ?
Regards,
Ralf Wiegand
Hexagon Metrology GmbH
Siegmund-Hiepe-Str. 2-12
35578 Wetzlar
Deutschland
Phone: +49 6441 207-410
Fax: +49 6441 207-387
E-Mail: Ralf.Wiegand at hexagonmetrology.com
Hauptgeschäftsführer: Holger Fritze
Geschäftsführer: Per Holmberg - Erik Steinbacher - Arno Seuren
Amtsgericht Wetzlar, HRB 1201
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.etherlab.org/pipermail/etherlab-users/attachments/20120320/1c1fb796/attachment-0005.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.jpg
Type: image/jpeg
Size: 42364 bytes
Desc: image001.jpg
URL: <http://lists.etherlab.org/pipermail/etherlab-users/attachments/20120320/1c1fb796/attachment-0004.jpg>
More information about the Etherlab-users
mailing list